io.appium.settings 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apks/settings_apk-debug.apk +0 -0
- package/package.json +2 -8
- package/app/build.gradle +0 -38
- package/app/src/main/AndroidManifest.xml +0 -149
- package/app/src/main/java/io/appium/settings/AppiumIME.java +0 -153
- package/app/src/main/java/io/appium/settings/ForegroundService.java +0 -70
- package/app/src/main/java/io/appium/settings/LocationService.java +0 -215
- package/app/src/main/java/io/appium/settings/LocationTracker.java +0 -313
- package/app/src/main/java/io/appium/settings/NLService.java +0 -134
- package/app/src/main/java/io/appium/settings/Settings.java +0 -260
- package/app/src/main/java/io/appium/settings/UnicodeIME.java +0 -187
- package/app/src/main/java/io/appium/settings/Unlock.java +0 -75
- package/app/src/main/java/io/appium/settings/handlers/AbstractSettingHandler.java +0 -64
- package/app/src/main/java/io/appium/settings/handlers/AnimationSettingHandler.java +0 -66
- package/app/src/main/java/io/appium/settings/handlers/BluetoothConnectionSettingHandler.java +0 -42
- package/app/src/main/java/io/appium/settings/handlers/DataConnectionSettingHandler.java +0 -134
- package/app/src/main/java/io/appium/settings/handlers/LocaleSettingHandler.java +0 -86
- package/app/src/main/java/io/appium/settings/handlers/WiFiConnectionSettingHandler.java +0 -40
- package/app/src/main/java/io/appium/settings/helpers/NotificationHelpers.java +0 -67
- package/app/src/main/java/io/appium/settings/helpers/PlayServicesHelpers.java +0 -30
- package/app/src/main/java/io/appium/settings/helpers/Utils.java +0 -29
- package/app/src/main/java/io/appium/settings/location/FusedLocationProvider.java +0 -99
- package/app/src/main/java/io/appium/settings/location/LocationBuilder.java +0 -80
- package/app/src/main/java/io/appium/settings/location/LocationManagerProvider.java +0 -97
- package/app/src/main/java/io/appium/settings/location/MockLocationProvider.java +0 -31
- package/app/src/main/java/io/appium/settings/notifications/StoredNotification.java +0 -103
- package/app/src/main/java/io/appium/settings/notifications/StoredNotifications.java +0 -50
- package/app/src/main/java/io/appium/settings/receivers/AbstractSettingReceiver.java +0 -62
- package/app/src/main/java/io/appium/settings/receivers/AnimationSettingReceiver.java +0 -40
- package/app/src/main/java/io/appium/settings/receivers/BluetoothConnectionSettingReceiver.java +0 -49
- package/app/src/main/java/io/appium/settings/receivers/ClipboardReceiver.java +0 -91
- package/app/src/main/java/io/appium/settings/receivers/DataConnectionSettingReceiver.java +0 -40
- package/app/src/main/java/io/appium/settings/receivers/HasAction.java +0 -21
- package/app/src/main/java/io/appium/settings/receivers/LocaleSettingReceiver.java +0 -127
- package/app/src/main/java/io/appium/settings/receivers/LocationInfoReceiver.java +0 -67
- package/app/src/main/java/io/appium/settings/receivers/MediaScannerReceiver.java +0 -91
- package/app/src/main/java/io/appium/settings/receivers/NotificationsReceiver.java +0 -100
- package/app/src/main/java/io/appium/settings/receivers/SmsReader.java +0 -113
- package/app/src/main/java/io/appium/settings/receivers/UnpairBluetoothDevicesReceiver.java +0 -84
- package/app/src/main/java/io/appium/settings/receivers/WiFiConnectionSettingReceiver.java +0 -39
- package/app/src/main/java/io/appium/settings/recorder/RecorderConstant.java +0 -94
- package/app/src/main/java/io/appium/settings/recorder/RecorderService.java +0 -202
- package/app/src/main/java/io/appium/settings/recorder/RecorderThread.java +0 -459
- package/app/src/main/java/io/appium/settings/recorder/RecorderUtil.java +0 -298
- package/app/src/main/res/drawable-hdpi/ic_launcher.png +0 -0
- package/app/src/main/res/drawable-ldpi/ic_launcher.png +0 -0
- package/app/src/main/res/drawable-mdpi/ic_launcher.png +0 -0
- package/app/src/main/res/drawable-xhdpi/ic_launcher.png +0 -0
- package/app/src/main/res/drawable-xxhdpi/ic_launcher.png +0 -0
- package/app/src/main/res/drawable-xxxhdpi/ic_launcher.png +0 -0
- package/app/src/main/res/layout/main.xml +0 -29
- package/app/src/main/res/values/dimens.xml +0 -7
- package/app/src/main/res/values/strings.xml +0 -9
- package/app/src/main/res/xml/method.xml +0 -3
- package/build.gradle +0 -17
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -6
- package/gradle.properties +0 -15
- package/gradlew +0 -160
- package/gradlew.bat +0 -90
- package/settings.gradle +0 -1
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.handlers;
|
|
18
|
-
|
|
19
|
-
import android.annotation.SuppressLint;
|
|
20
|
-
import android.content.Context;
|
|
21
|
-
import android.net.ConnectivityManager;
|
|
22
|
-
import android.os.Build;
|
|
23
|
-
import android.telephony.SubscriptionManager;
|
|
24
|
-
import android.telephony.TelephonyManager;
|
|
25
|
-
import android.util.Log;
|
|
26
|
-
|
|
27
|
-
import java.io.IOException;
|
|
28
|
-
import java.lang.reflect.Field;
|
|
29
|
-
import java.lang.reflect.Method;
|
|
30
|
-
import java.util.Arrays;
|
|
31
|
-
|
|
32
|
-
public class DataConnectionSettingHandler extends AbstractSettingHandler {
|
|
33
|
-
private static final String TAG = "APPIUM SETTINGS (DATA)";
|
|
34
|
-
private static final String NETWORK_PERMISSION = "android.permission.CHANGE_NETWORK_STATE";
|
|
35
|
-
|
|
36
|
-
public DataConnectionSettingHandler(Context context) {
|
|
37
|
-
super(context, NETWORK_PERMISSION);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private static boolean executeCommandViaSu(String command) {
|
|
41
|
-
final String[] suPaths = new String[]{"su", "/system/xbin/su", "/system/bin/su"};
|
|
42
|
-
for (String su : suPaths) {
|
|
43
|
-
try {
|
|
44
|
-
Runtime.getRuntime().exec(new String[]{su, "-c", command});
|
|
45
|
-
return true;
|
|
46
|
-
} catch (IOException e) {
|
|
47
|
-
// ignore
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
Log.e(TAG, String.format("'su' binary is not available at %s. Is the phone rooted?",
|
|
51
|
-
Arrays.toString(suPaths)));
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private static String getTransactionCode(Context context) throws Exception {
|
|
56
|
-
final TelephonyManager mTelephonyManager =
|
|
57
|
-
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
58
|
-
final Class<?> mTelephonyClass = Class.forName(mTelephonyManager.getClass().getName());
|
|
59
|
-
final Method mTelephonyMethod = mTelephonyClass.getDeclaredMethod("getITelephony");
|
|
60
|
-
mTelephonyMethod.setAccessible(true);
|
|
61
|
-
final Object mTelephonyStub = mTelephonyMethod.invoke(mTelephonyManager);
|
|
62
|
-
final Class<?> mTelephonyStubClass = Class.forName(mTelephonyStub.getClass().getName());
|
|
63
|
-
final Class<?> mClass = mTelephonyStubClass.getDeclaringClass();
|
|
64
|
-
final Field field = mClass.getDeclaredField("TRANSACTION_setDataEnabled");
|
|
65
|
-
field.setAccessible(true);
|
|
66
|
-
return String.valueOf(field.getInt(null));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private static void setMobileNetworkFromLollipop(Context context, boolean isEnabled)
|
|
70
|
-
throws Exception {
|
|
71
|
-
final int state = isEnabled ? 1 : 0;
|
|
72
|
-
final String transactionCode = getTransactionCode(context);
|
|
73
|
-
if (transactionCode.length() == 0) {
|
|
74
|
-
throw new IllegalStateException("The transaction code should not be empty");
|
|
75
|
-
}
|
|
76
|
-
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
|
77
|
-
final SubscriptionManager mSubscriptionManager = (SubscriptionManager) context
|
|
78
|
-
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
79
|
-
for (int i = 0; i < mSubscriptionManager.getActiveSubscriptionInfoCountMax(); i++) {
|
|
80
|
-
if (transactionCode.length() > 0) {
|
|
81
|
-
@SuppressLint("MissingPermission") final int subscriptionId = mSubscriptionManager
|
|
82
|
-
.getActiveSubscriptionInfoList().get(i).getSubscriptionId();
|
|
83
|
-
final String command = String.format("service call phone %s i32 %s i32 %s",
|
|
84
|
-
transactionCode, subscriptionId, state);
|
|
85
|
-
executeCommandViaSu(command);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
|
|
89
|
-
if (transactionCode.length() > 0) {
|
|
90
|
-
final String command = String.format("service call phone %s i32 %s",
|
|
91
|
-
transactionCode, state);
|
|
92
|
-
executeCommandViaSu(command);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private static void setMobileNetworkFromGingerbreadToLollipop(
|
|
98
|
-
Context mContext, boolean isEnabled) throws Exception {
|
|
99
|
-
final ConnectivityManager conman =
|
|
100
|
-
(ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
101
|
-
final Class<?> conmanClass = Class.forName(conman.getClass().getName());
|
|
102
|
-
final Field iConnectivityManagerField = conmanClass.getDeclaredField("mService");
|
|
103
|
-
iConnectivityManagerField.setAccessible(true);
|
|
104
|
-
final Object iConnectivityManager = iConnectivityManagerField.get(conman);
|
|
105
|
-
final Class<?> iConnectivityManagerClass =
|
|
106
|
-
Class.forName(iConnectivityManager.getClass().getName());
|
|
107
|
-
final Method setMobileDataEnabledMethod =
|
|
108
|
-
iConnectivityManagerClass.getDeclaredMethod("setMobileDataEnabled", Boolean.TYPE);
|
|
109
|
-
setMobileDataEnabledMethod.setAccessible(true);
|
|
110
|
-
setMobileDataEnabledMethod.invoke(iConnectivityManager, isEnabled);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@Override
|
|
114
|
-
protected boolean setState(boolean on) {
|
|
115
|
-
try {
|
|
116
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
117
|
-
setMobileNetworkFromGingerbreadToLollipop(mContext, on);
|
|
118
|
-
} else {
|
|
119
|
-
// http://stackoverflow.com/questions/26539445/the-setmobiledataenabled-method-is-no-longer-callable-as-of-android-l-and-later
|
|
120
|
-
setMobileNetworkFromLollipop(mContext, on);
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
123
|
-
} catch (Exception e) {
|
|
124
|
-
Log.e(TAG, String.format(
|
|
125
|
-
"Error turning %s mobile data: %s", on ? "on" : "off", e.getMessage()));
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@Override
|
|
131
|
-
protected String getSettingDescription() {
|
|
132
|
-
return "mobile data";
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.handlers;
|
|
18
|
-
|
|
19
|
-
import android.content.Context;
|
|
20
|
-
import android.content.res.Configuration;
|
|
21
|
-
import android.os.Build;
|
|
22
|
-
import android.util.Log;
|
|
23
|
-
|
|
24
|
-
import java.lang.reflect.Field;
|
|
25
|
-
import java.lang.reflect.InvocationTargetException;
|
|
26
|
-
import java.lang.reflect.Method;
|
|
27
|
-
import java.util.Locale;
|
|
28
|
-
|
|
29
|
-
public class LocaleSettingHandler extends AbstractSettingHandler {
|
|
30
|
-
private static final String TAG = "APPIUM SETTINGS(LOCALE)";
|
|
31
|
-
private static final String CHANGE_CONFIGURATION = "android.permission.CHANGE_CONFIGURATION";
|
|
32
|
-
|
|
33
|
-
public LocaleSettingHandler(Context context) {
|
|
34
|
-
super(context, CHANGE_CONFIGURATION);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public void setLocale(Locale locale) {
|
|
38
|
-
try {
|
|
39
|
-
if(hasPermissions()) {
|
|
40
|
-
setLocaleWith(locale);
|
|
41
|
-
}
|
|
42
|
-
} catch (Exception e) {
|
|
43
|
-
Log.e(TAG, "Failed to set locale", e);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private void setLocaleWith(Locale locale) throws
|
|
48
|
-
ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
|
|
49
|
-
Class<?> activityManagerNativeClass = Class.forName("android.app.ActivityManagerNative");
|
|
50
|
-
|
|
51
|
-
Method methodGetDefault = activityManagerNativeClass.getMethod("getDefault");
|
|
52
|
-
methodGetDefault.setAccessible(true);
|
|
53
|
-
Object amn = methodGetDefault.invoke(activityManagerNativeClass);
|
|
54
|
-
|
|
55
|
-
// Build.VERSION_CODES.O
|
|
56
|
-
if (Build.VERSION.SDK_INT >= 26) {
|
|
57
|
-
// getConfiguration moved from ActivityManagerNative to ActivityManagerProxy
|
|
58
|
-
activityManagerNativeClass = Class.forName(amn.getClass().getName());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
Method methodGetConfiguration = activityManagerNativeClass.getMethod("getConfiguration");
|
|
62
|
-
methodGetConfiguration.setAccessible(true);
|
|
63
|
-
Configuration config = (Configuration) methodGetConfiguration.invoke(amn);
|
|
64
|
-
|
|
65
|
-
Class<?> configClass = config.getClass();
|
|
66
|
-
Field f = configClass.getField("userSetLocale");
|
|
67
|
-
f.setBoolean(config, true);
|
|
68
|
-
|
|
69
|
-
config.locale = locale;
|
|
70
|
-
config.setLayoutDirection(locale);
|
|
71
|
-
|
|
72
|
-
Method methodUpdateConfiguration = activityManagerNativeClass.getMethod("updateConfiguration", Configuration.class);
|
|
73
|
-
methodUpdateConfiguration.setAccessible(true);
|
|
74
|
-
methodUpdateConfiguration.invoke(amn, config);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Override
|
|
78
|
-
protected boolean setState(boolean state) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@Override
|
|
83
|
-
protected String getSettingDescription() {
|
|
84
|
-
return "locale";
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.handlers;
|
|
18
|
-
|
|
19
|
-
import android.content.Context;
|
|
20
|
-
import android.net.wifi.WifiManager;
|
|
21
|
-
|
|
22
|
-
public class WiFiConnectionSettingHandler extends AbstractSettingHandler {
|
|
23
|
-
private static final String WIFI_PERMISSION = "android.permission.CHANGE_WIFI_STATE";
|
|
24
|
-
|
|
25
|
-
public WiFiConnectionSettingHandler(Context context) {
|
|
26
|
-
super(context, WIFI_PERMISSION);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Override
|
|
30
|
-
protected boolean setState(boolean state) {
|
|
31
|
-
WifiManager mWifiManager =
|
|
32
|
-
(WifiManager) mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
|
33
|
-
return mWifiManager.setWifiEnabled(state);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Override
|
|
37
|
-
protected String getSettingDescription() {
|
|
38
|
-
return "Wi-Fi";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.helpers;
|
|
18
|
-
|
|
19
|
-
import android.app.Notification;
|
|
20
|
-
import android.app.NotificationChannel;
|
|
21
|
-
import android.app.NotificationManager;
|
|
22
|
-
import android.content.Context;
|
|
23
|
-
import android.graphics.BitmapFactory;
|
|
24
|
-
import android.os.Build;
|
|
25
|
-
|
|
26
|
-
import io.appium.settings.R;
|
|
27
|
-
|
|
28
|
-
import static android.content.Context.NOTIFICATION_SERVICE;
|
|
29
|
-
|
|
30
|
-
import androidx.annotation.RequiresApi;
|
|
31
|
-
import androidx.core.app.NotificationCompat;
|
|
32
|
-
|
|
33
|
-
public class NotificationHelpers {
|
|
34
|
-
public static final int APPIUM_NOTIFICATION_IDENTIFIER = 1;
|
|
35
|
-
private static final String CHANNEL_ID = "main_channel";
|
|
36
|
-
private static final String CHANNEL_NAME = "Appium Settings";
|
|
37
|
-
private static final String CHANNEL_DESCRIPTION = "Keep this service running, " +
|
|
38
|
-
"so Appium for Android can properly interact with several system APIs";
|
|
39
|
-
|
|
40
|
-
@RequiresApi(Build.VERSION_CODES.O)
|
|
41
|
-
private static void createChannel(Context context) {
|
|
42
|
-
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
|
|
43
|
-
if (mNotificationManager == null) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
|
|
47
|
-
mChannel.setDescription(CHANNEL_DESCRIPTION);
|
|
48
|
-
mChannel.setShowBadge(true);
|
|
49
|
-
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
|
|
50
|
-
mNotificationManager.createNotificationChannel(mChannel);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public static Notification getNotification(Context context) {
|
|
54
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
55
|
-
createChannel(context);
|
|
56
|
-
}
|
|
57
|
-
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
|
|
58
|
-
bigTextStyle.setBigContentTitle(CHANNEL_NAME);
|
|
59
|
-
bigTextStyle.bigText(CHANNEL_DESCRIPTION);
|
|
60
|
-
return new NotificationCompat.Builder(context, CHANNEL_ID)
|
|
61
|
-
.setStyle(bigTextStyle)
|
|
62
|
-
.setWhen(System.currentTimeMillis())
|
|
63
|
-
.setSmallIcon(R.drawable.ic_launcher)
|
|
64
|
-
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
|
|
65
|
-
.build();
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.helpers;
|
|
18
|
-
|
|
19
|
-
import android.content.Context;
|
|
20
|
-
|
|
21
|
-
import com.google.android.gms.common.ConnectionResult;
|
|
22
|
-
import com.google.android.gms.common.GoogleApiAvailability;
|
|
23
|
-
|
|
24
|
-
public class PlayServicesHelpers {
|
|
25
|
-
public static boolean isAvailable(Context context) {
|
|
26
|
-
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
|
27
|
-
int resultCode = apiAvailability.isGooglePlayServicesAvailable(context);
|
|
28
|
-
return resultCode == ConnectionResult.SUCCESS;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.helpers;
|
|
18
|
-
|
|
19
|
-
import org.json.JSONObject;
|
|
20
|
-
|
|
21
|
-
public class Utils {
|
|
22
|
-
public static Object formatJsonNull(Object o) {
|
|
23
|
-
return o == null ? JSONObject.NULL : o;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public static String toNullableString(CharSequence cs) {
|
|
27
|
-
return cs == null ? null : cs.toString();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.location;
|
|
18
|
-
|
|
19
|
-
import android.Manifest;
|
|
20
|
-
import android.annotation.SuppressLint;
|
|
21
|
-
import android.content.Context;
|
|
22
|
-
import android.location.Location;
|
|
23
|
-
import android.util.Log;
|
|
24
|
-
|
|
25
|
-
import com.google.android.gms.location.FusedLocationProviderClient;
|
|
26
|
-
|
|
27
|
-
import static androidx.core.content.PermissionChecker.PERMISSION_GRANTED;
|
|
28
|
-
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
|
29
|
-
|
|
30
|
-
import androidx.annotation.NonNull;
|
|
31
|
-
|
|
32
|
-
public class FusedLocationProvider implements MockLocationProvider {
|
|
33
|
-
|
|
34
|
-
private final static String TAG = FusedLocationProvider.class.getSimpleName();
|
|
35
|
-
|
|
36
|
-
private final static String PROVIDER_NAME = "fused";
|
|
37
|
-
|
|
38
|
-
private final FusedLocationProviderClient fusedLocationProviderClient;
|
|
39
|
-
private final Context context;
|
|
40
|
-
|
|
41
|
-
public FusedLocationProvider(FusedLocationProviderClient fusedLocationProviderClient, Context context) {
|
|
42
|
-
this.fusedLocationProviderClient = fusedLocationProviderClient;
|
|
43
|
-
this.context = context;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@Override
|
|
47
|
-
public String getProviderName() {
|
|
48
|
-
return PROVIDER_NAME;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@SuppressLint("MissingPermission")
|
|
52
|
-
@Override
|
|
53
|
-
public void setLocation(Location location) {
|
|
54
|
-
if (!hasPermissions()) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!fusedLocationProviderClient.asGoogleApiClient().isConnected()) {
|
|
58
|
-
Log.d(TAG, "GoogleApiClient is not connected");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
fusedLocationProviderClient.setMockLocation(location);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@SuppressLint("MissingPermission")
|
|
65
|
-
@Override
|
|
66
|
-
public void enable() {
|
|
67
|
-
if (!hasPermissions()) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
fusedLocationProviderClient.asGoogleApiClient().connect();
|
|
71
|
-
fusedLocationProviderClient.setMockMode(true);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@SuppressLint("MissingPermission")
|
|
75
|
-
@Override
|
|
76
|
-
public void disable() {
|
|
77
|
-
if (!hasPermissions()) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
fusedLocationProviderClient.setMockMode(false);
|
|
81
|
-
fusedLocationProviderClient.asGoogleApiClient().disconnect();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Override
|
|
85
|
-
@NonNull
|
|
86
|
-
public String toString() {
|
|
87
|
-
return "FusedLocationProvider{" +
|
|
88
|
-
"name='" + PROVIDER_NAME + '\'' +
|
|
89
|
-
'}';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private boolean hasPermissions() {
|
|
93
|
-
if (checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
|
|
94
|
-
Log.e(TAG, String.format("Missing permission: '%s'", Manifest.permission.ACCESS_FINE_LOCATION));
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.location;
|
|
18
|
-
|
|
19
|
-
import android.content.Intent;
|
|
20
|
-
import android.location.Criteria;
|
|
21
|
-
import android.location.Location;
|
|
22
|
-
import android.os.SystemClock;
|
|
23
|
-
import android.util.Log;
|
|
24
|
-
|
|
25
|
-
import androidx.annotation.Nullable;
|
|
26
|
-
|
|
27
|
-
public class LocationBuilder {
|
|
28
|
-
|
|
29
|
-
private static final String TAG = "MOCKED LOCATION BUILDER";
|
|
30
|
-
private static final String LONGITUDE_PARAMETER_KEY = "longitude";
|
|
31
|
-
private static final String LATITUDE_PARAMETER_KEY = "latitude";
|
|
32
|
-
private static final String ALTITUDE_PARAMETER_KEY = "altitude";
|
|
33
|
-
private static final String SPEED_PARAMETER_KEY = "speed";
|
|
34
|
-
private static final String BEARING_PARAMETER_KEY = "bearing";
|
|
35
|
-
|
|
36
|
-
@Nullable
|
|
37
|
-
private static Double extractParam(Intent intent, String paramKey) {
|
|
38
|
-
Double value = null;
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
if (intent.hasExtra(paramKey)) {
|
|
42
|
-
value = Double.parseDouble(intent.getStringExtra(paramKey));
|
|
43
|
-
Log.i(TAG, String.format("Received parameter: %s, value: %s", paramKey, value));
|
|
44
|
-
}
|
|
45
|
-
} catch (NumberFormatException e) {
|
|
46
|
-
Log.e(TAG, String.format("%s should be a valid number. '%s' is given instead",
|
|
47
|
-
paramKey, intent.getStringExtra(paramKey)));
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public static Location buildFromIntent(Intent intent, String providerName) {
|
|
53
|
-
Double longitude = extractParam(intent, LONGITUDE_PARAMETER_KEY);
|
|
54
|
-
Double latitude = extractParam(intent, LATITUDE_PARAMETER_KEY);
|
|
55
|
-
Double altitude = extractParam(intent, ALTITUDE_PARAMETER_KEY);
|
|
56
|
-
Double speed = extractParam(intent, SPEED_PARAMETER_KEY);
|
|
57
|
-
Double bearing = extractParam(intent, BEARING_PARAMETER_KEY);
|
|
58
|
-
Location location = new Location(providerName);
|
|
59
|
-
location.setAccuracy(Criteria.ACCURACY_FINE);
|
|
60
|
-
if (longitude != null) {
|
|
61
|
-
location.setLongitude(longitude);
|
|
62
|
-
}
|
|
63
|
-
if (latitude != null) {
|
|
64
|
-
location.setLatitude(latitude);
|
|
65
|
-
}
|
|
66
|
-
if (altitude != null) {
|
|
67
|
-
location.setAltitude(altitude);
|
|
68
|
-
}
|
|
69
|
-
if (speed != null) {
|
|
70
|
-
location.setSpeed(speed.floatValue());
|
|
71
|
-
}
|
|
72
|
-
if (bearing != null) {
|
|
73
|
-
location.setBearing(bearing.floatValue());
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
location.setTime(System.currentTimeMillis());
|
|
77
|
-
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
|
78
|
-
return location;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2012-present Appium Committers
|
|
3
|
-
<p>
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
<p>
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
<p>
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
package io.appium.settings.location;
|
|
18
|
-
|
|
19
|
-
import android.location.Location;
|
|
20
|
-
import android.location.LocationManager;
|
|
21
|
-
|
|
22
|
-
public class LocationManagerProvider implements MockLocationProvider {
|
|
23
|
-
|
|
24
|
-
private final LocationManager locationManager;
|
|
25
|
-
|
|
26
|
-
private final String name;
|
|
27
|
-
private final boolean requiresNetwork;
|
|
28
|
-
private final boolean requiresSatellite;
|
|
29
|
-
private final boolean requiresCell;
|
|
30
|
-
private final boolean hasMonetaryCost;
|
|
31
|
-
private final boolean supportsAltitude;
|
|
32
|
-
private final boolean supportsSpeed;
|
|
33
|
-
private final boolean supportsBearing;
|
|
34
|
-
private final int powerRequirement;
|
|
35
|
-
private final int accuracy;
|
|
36
|
-
|
|
37
|
-
public LocationManagerProvider(LocationManager locationManager, String name, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy) {
|
|
38
|
-
this.locationManager = locationManager;
|
|
39
|
-
this.name = name;
|
|
40
|
-
this.requiresNetwork = requiresNetwork;
|
|
41
|
-
this.requiresSatellite = requiresSatellite;
|
|
42
|
-
this.requiresCell = requiresCell;
|
|
43
|
-
this.hasMonetaryCost = hasMonetaryCost;
|
|
44
|
-
this.supportsAltitude = supportsAltitude;
|
|
45
|
-
this.supportsSpeed = supportsSpeed;
|
|
46
|
-
this.supportsBearing = supportsBearing;
|
|
47
|
-
this.powerRequirement = powerRequirement;
|
|
48
|
-
this.accuracy = accuracy;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@Override
|
|
52
|
-
public void setLocation(Location location) {
|
|
53
|
-
locationManager.setTestProviderLocation(name, location);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@Override
|
|
57
|
-
public void enable() {
|
|
58
|
-
locationManager.addTestProvider(name,
|
|
59
|
-
requiresNetwork,
|
|
60
|
-
requiresSatellite,
|
|
61
|
-
requiresCell,
|
|
62
|
-
hasMonetaryCost,
|
|
63
|
-
supportsAltitude,
|
|
64
|
-
supportsSpeed,
|
|
65
|
-
supportsBearing,
|
|
66
|
-
powerRequirement,
|
|
67
|
-
accuracy);
|
|
68
|
-
locationManager.setTestProviderEnabled(name, true);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@Override
|
|
72
|
-
public void disable() {
|
|
73
|
-
locationManager.setTestProviderEnabled(name, false);
|
|
74
|
-
locationManager.removeTestProvider(name);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Override
|
|
78
|
-
public String getProviderName() {
|
|
79
|
-
return name;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
@Override
|
|
83
|
-
public String toString() {
|
|
84
|
-
return "LocationManagerProvider{" +
|
|
85
|
-
"name='" + name + '\'' +
|
|
86
|
-
", requiresNetwork=" + requiresNetwork +
|
|
87
|
-
", requiresSatellite=" + requiresSatellite +
|
|
88
|
-
", requiresCell=" + requiresCell +
|
|
89
|
-
", hasMonetaryCost=" + hasMonetaryCost +
|
|
90
|
-
", supportsAltitude=" + supportsAltitude +
|
|
91
|
-
", supportsSpeed=" + supportsSpeed +
|
|
92
|
-
", supportsBearing=" + supportsBearing +
|
|
93
|
-
", powerRequirement=" + powerRequirement +
|
|
94
|
-
", accuracy=" + accuracy +
|
|
95
|
-
'}';
|
|
96
|
-
}
|
|
97
|
-
}
|