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.
Files changed (61) hide show
  1. package/apks/settings_apk-debug.apk +0 -0
  2. package/package.json +2 -8
  3. package/app/build.gradle +0 -38
  4. package/app/src/main/AndroidManifest.xml +0 -149
  5. package/app/src/main/java/io/appium/settings/AppiumIME.java +0 -153
  6. package/app/src/main/java/io/appium/settings/ForegroundService.java +0 -70
  7. package/app/src/main/java/io/appium/settings/LocationService.java +0 -215
  8. package/app/src/main/java/io/appium/settings/LocationTracker.java +0 -313
  9. package/app/src/main/java/io/appium/settings/NLService.java +0 -134
  10. package/app/src/main/java/io/appium/settings/Settings.java +0 -260
  11. package/app/src/main/java/io/appium/settings/UnicodeIME.java +0 -187
  12. package/app/src/main/java/io/appium/settings/Unlock.java +0 -75
  13. package/app/src/main/java/io/appium/settings/handlers/AbstractSettingHandler.java +0 -64
  14. package/app/src/main/java/io/appium/settings/handlers/AnimationSettingHandler.java +0 -66
  15. package/app/src/main/java/io/appium/settings/handlers/BluetoothConnectionSettingHandler.java +0 -42
  16. package/app/src/main/java/io/appium/settings/handlers/DataConnectionSettingHandler.java +0 -134
  17. package/app/src/main/java/io/appium/settings/handlers/LocaleSettingHandler.java +0 -86
  18. package/app/src/main/java/io/appium/settings/handlers/WiFiConnectionSettingHandler.java +0 -40
  19. package/app/src/main/java/io/appium/settings/helpers/NotificationHelpers.java +0 -67
  20. package/app/src/main/java/io/appium/settings/helpers/PlayServicesHelpers.java +0 -30
  21. package/app/src/main/java/io/appium/settings/helpers/Utils.java +0 -29
  22. package/app/src/main/java/io/appium/settings/location/FusedLocationProvider.java +0 -99
  23. package/app/src/main/java/io/appium/settings/location/LocationBuilder.java +0 -80
  24. package/app/src/main/java/io/appium/settings/location/LocationManagerProvider.java +0 -97
  25. package/app/src/main/java/io/appium/settings/location/MockLocationProvider.java +0 -31
  26. package/app/src/main/java/io/appium/settings/notifications/StoredNotification.java +0 -103
  27. package/app/src/main/java/io/appium/settings/notifications/StoredNotifications.java +0 -50
  28. package/app/src/main/java/io/appium/settings/receivers/AbstractSettingReceiver.java +0 -62
  29. package/app/src/main/java/io/appium/settings/receivers/AnimationSettingReceiver.java +0 -40
  30. package/app/src/main/java/io/appium/settings/receivers/BluetoothConnectionSettingReceiver.java +0 -49
  31. package/app/src/main/java/io/appium/settings/receivers/ClipboardReceiver.java +0 -91
  32. package/app/src/main/java/io/appium/settings/receivers/DataConnectionSettingReceiver.java +0 -40
  33. package/app/src/main/java/io/appium/settings/receivers/HasAction.java +0 -21
  34. package/app/src/main/java/io/appium/settings/receivers/LocaleSettingReceiver.java +0 -127
  35. package/app/src/main/java/io/appium/settings/receivers/LocationInfoReceiver.java +0 -67
  36. package/app/src/main/java/io/appium/settings/receivers/MediaScannerReceiver.java +0 -91
  37. package/app/src/main/java/io/appium/settings/receivers/NotificationsReceiver.java +0 -100
  38. package/app/src/main/java/io/appium/settings/receivers/SmsReader.java +0 -113
  39. package/app/src/main/java/io/appium/settings/receivers/UnpairBluetoothDevicesReceiver.java +0 -84
  40. package/app/src/main/java/io/appium/settings/receivers/WiFiConnectionSettingReceiver.java +0 -39
  41. package/app/src/main/java/io/appium/settings/recorder/RecorderConstant.java +0 -94
  42. package/app/src/main/java/io/appium/settings/recorder/RecorderService.java +0 -202
  43. package/app/src/main/java/io/appium/settings/recorder/RecorderThread.java +0 -459
  44. package/app/src/main/java/io/appium/settings/recorder/RecorderUtil.java +0 -298
  45. package/app/src/main/res/drawable-hdpi/ic_launcher.png +0 -0
  46. package/app/src/main/res/drawable-ldpi/ic_launcher.png +0 -0
  47. package/app/src/main/res/drawable-mdpi/ic_launcher.png +0 -0
  48. package/app/src/main/res/drawable-xhdpi/ic_launcher.png +0 -0
  49. package/app/src/main/res/drawable-xxhdpi/ic_launcher.png +0 -0
  50. package/app/src/main/res/drawable-xxxhdpi/ic_launcher.png +0 -0
  51. package/app/src/main/res/layout/main.xml +0 -29
  52. package/app/src/main/res/values/dimens.xml +0 -7
  53. package/app/src/main/res/values/strings.xml +0 -9
  54. package/app/src/main/res/xml/method.xml +0 -3
  55. package/build.gradle +0 -17
  56. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  57. package/gradle/wrapper/gradle-wrapper.properties +0 -6
  58. package/gradle.properties +0 -15
  59. package/gradlew +0 -160
  60. package/gradlew.bat +0 -90
  61. package/settings.gradle +0 -1
@@ -1,313 +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;
18
-
19
- import android.content.Context;
20
- import android.location.Location;
21
- import android.location.LocationListener;
22
- import android.location.LocationManager;
23
- import android.os.Build;
24
- import android.os.Bundle;
25
- import android.os.Looper;
26
- import android.util.Log;
27
-
28
- import com.google.android.gms.location.FusedLocationProviderClient;
29
- import com.google.android.gms.location.LocationCallback;
30
- import com.google.android.gms.location.LocationRequest;
31
- import com.google.android.gms.location.LocationResult;
32
- import com.google.android.gms.location.LocationServices;
33
- import com.google.android.gms.tasks.CancellationTokenSource;
34
-
35
- import io.appium.settings.helpers.PlayServicesHelpers;
36
-
37
- import static android.content.Context.LOCATION_SERVICE;
38
-
39
- import androidx.annotation.NonNull;
40
- import androidx.annotation.Nullable;
41
-
42
- import java.util.concurrent.atomic.AtomicBoolean;
43
-
44
- public class LocationTracker implements LocationListener {
45
- private static final String TAG = LocationTracker.class.getSimpleName();
46
- private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 1; // 1 meter
47
- private static final long LOCATION_UPDATES_INTERVAL_MS = 1000 * 60; // 1 minute
48
- private static final long FAST_INTERVAL_MS = 5000;
49
-
50
- private volatile LocationManager mLocationManager;
51
- private volatile FusedLocationProviderClient mFusedLocationProviderClient;
52
- private final LocationCallback locationCallback = new LocationCallback() {
53
- @Override
54
- public void onLocationResult(@NonNull LocationResult locationResult) {
55
- Log.d(TAG, "Got a location update from Play Services");
56
- mLocation = locationResult.getLastLocation();
57
- }
58
- };
59
- private volatile Location mLocation;
60
- private final AtomicBoolean isStarted = new AtomicBoolean(false);
61
- private String mLocationProvider;
62
-
63
- private static LocationTracker instance = null;
64
-
65
- private LocationTracker() {
66
- }
67
-
68
- public synchronized static LocationTracker getInstance() {
69
- if (instance == null) {
70
- instance = new LocationTracker();
71
- }
72
- return instance;
73
- }
74
-
75
- public boolean isRunning() {
76
- return isStarted.get();
77
- }
78
-
79
- private void setIsRunning(boolean value) {
80
- isStarted.set(value);
81
- }
82
-
83
- @Override
84
- public void onLocationChanged(@Nullable Location location) {
85
- if (location == null) {
86
- return;
87
- }
88
-
89
- Log.d(TAG, "Got a location update from Location Manager");
90
- mLocation = location;
91
- }
92
-
93
- @Override
94
- public void onProviderDisabled(@NonNull String provider) {
95
- }
96
-
97
- @Override
98
- public void onProviderEnabled(@NonNull String provider) {
99
- }
100
-
101
- @Override
102
- public void onStatusChanged(String provider, int status, Bundle extras) {
103
- }
104
-
105
- synchronized void start(Context context) {
106
- if (isRunning()) {
107
- return;
108
- }
109
- setIsRunning(true);
110
-
111
- if (PlayServicesHelpers.isAvailable(context)) {
112
- initializePlayServices(context);
113
- } else {
114
- initializeLocationManager(context);
115
- }
116
- }
117
-
118
- synchronized void stop() {
119
- if (!isRunning()) {
120
- return;
121
- }
122
-
123
- try {
124
- stopLocationUpdatesWithPlayServices();
125
- stopLocationUpdatesWithoutPlayServices();
126
- } finally {
127
- setIsRunning(false);
128
- }
129
- }
130
-
131
- private void initializePlayServices(Context context) {
132
- if (isFusedLocationProviderInitialized()) {
133
- return;
134
- }
135
-
136
- Log.d(TAG, "Configuring location provider for Google Play Services");
137
- mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
138
- LocationRequest locationRequest = LocationRequest.create()
139
- .setPriority(LocationRequest.PRIORITY_LOW_POWER)
140
- .setInterval(LOCATION_UPDATES_INTERVAL_MS)
141
- .setFastestInterval(FAST_INTERVAL_MS);
142
- try {
143
- mFusedLocationProviderClient.requestLocationUpdates(
144
- locationRequest, locationCallback, Looper.getMainLooper());
145
- Log.d(TAG, "Google Play Services location provider is connected");
146
- return;
147
- } catch (SecurityException e) {
148
- Log.e(TAG, "Appium Settings has no access to location permission", e);
149
- } catch (Exception e) {
150
- Log.e(TAG, "Cannot connect to Google location service", e);
151
- }
152
- stopLocationUpdatesWithPlayServices();
153
- }
154
-
155
- private void initializeLocationManager(Context context) {
156
- if (isLocationManagerConnected()) {
157
- return;
158
- }
159
-
160
- Log.d(TAG, "Configuring the default Android location provider");
161
- Object locationManager = context.getSystemService(LOCATION_SERVICE);
162
- if (locationManager == null) {
163
- Log.e(TAG, "Cannot retrieve the location manager");
164
- return;
165
- }
166
- mLocationManager = (LocationManager) locationManager;
167
- startLocationUpdatesWithoutPlayServices();
168
- }
169
-
170
- private void stopLocationUpdatesWithPlayServices() {
171
- if (!isFusedLocationProviderInitialized()) {
172
- return;
173
- }
174
-
175
- Log.d(TAG, "Stopping Google Play Services location provider");
176
- mFusedLocationProviderClient.removeLocationUpdates(locationCallback);
177
- if (mFusedLocationProviderClient.asGoogleApiClient().isConnected()) {
178
- mFusedLocationProviderClient.asGoogleApiClient().disconnect();
179
- }
180
- mFusedLocationProviderClient = null;
181
- }
182
-
183
- private void startLocationUpdatesWithoutPlayServices() {
184
- if (mLocationManager == null) {
185
- return;
186
- }
187
-
188
- boolean isGPSEnabled = mLocationManager
189
- .isProviderEnabled(LocationManager.GPS_PROVIDER);
190
- boolean isNetworkEnabled = mLocationManager
191
- .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
192
- if (!isGPSEnabled && !isNetworkEnabled) {
193
- Log.e(TAG, "Both COARSE and GPS location providers are disabled");
194
- return;
195
- }
196
-
197
- if (isGPSEnabled) {
198
- try {
199
- mLocationManager.requestLocationUpdates(
200
- LocationManager.GPS_PROVIDER,
201
- LOCATION_UPDATES_INTERVAL_MS,
202
- MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
203
- mLocationProvider = LocationManager.GPS_PROVIDER;
204
- Log.d(TAG, "GPS location provider is enabled. Getting FINE location");
205
- return;
206
- } catch (SecurityException e) {
207
- Log.e(TAG, "Appium Settings has no access to FINE location permission", e);
208
- }
209
- }
210
- try {
211
- mLocationManager.requestLocationUpdates(
212
- LocationManager.NETWORK_PROVIDER,
213
- LOCATION_UPDATES_INTERVAL_MS,
214
- MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
215
- mLocationProvider = LocationManager.NETWORK_PROVIDER;
216
- Log.d(TAG, "NETWORK location provider is enabled. Getting COARSE location");
217
- } catch (SecurityException e) {
218
- Log.e(TAG, "Appium Settings has no access to COARSE location permission", e);
219
- }
220
- }
221
-
222
- private void stopLocationUpdatesWithoutPlayServices() {
223
- if (mLocationManager == null) {
224
- return;
225
- }
226
-
227
- Log.d(TAG, "Stopping Android location provider");
228
- mLocationManager.removeUpdates(this);
229
- mLocationManager = null;
230
- }
231
-
232
- private boolean isFusedLocationProviderInitialized() {
233
- return mFusedLocationProviderClient != null;
234
- }
235
-
236
- private boolean isLocationManagerConnected() {
237
- return mLocationManager != null && mLocationProvider != null;
238
- }
239
-
240
- @Nullable
241
- private Location getCachedLocation() {
242
- if (mLocation != null) {
243
- Log.d(TAG, "The cached location has been successfully retrieved");
244
- return mLocation;
245
- }
246
- Log.d(TAG, "The cached location has not been retrieved");
247
- return null;
248
- }
249
-
250
- public synchronized void forceLocationUpdate(Context context) {
251
- if (!isRunning()) {
252
- Log.e(TAG, "The location tracker is not running");
253
- return;
254
- }
255
-
256
- if (isFusedLocationProviderInitialized()) {
257
- try {
258
- mFusedLocationProviderClient.getCurrentLocation(
259
- LocationRequest.PRIORITY_HIGH_ACCURACY, new CancellationTokenSource().getToken())
260
- .addOnCompleteListener(t -> {
261
- if (t.isSuccessful()) {
262
- mLocation = t.getResult();
263
- Log.d(TAG, "The current location has been successfully retrieved from " +
264
- "Play Services");
265
- } else {
266
- Log.w(TAG, "Failed to retrieve the current location from Play Services",
267
- t.getException());
268
- }
269
- });
270
- } catch (SecurityException e) {
271
- Log.e(TAG, "Appium Settings has no access to location permission", e);
272
- }
273
- } else if (isLocationManagerConnected() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
274
- try {
275
- mLocationManager.getCurrentLocation(mLocationProvider, null,
276
- context.getMainExecutor(), location -> {
277
- mLocation = location;
278
- Log.d(TAG, "The current location has been successfully retrieved " +
279
- "from Location Manager");
280
- });
281
- } catch (SecurityException e) {
282
- Log.e(TAG, "Appium Settings has no access to location permission", e);
283
- }
284
- }
285
- }
286
-
287
- @Nullable
288
- public synchronized Location getLocation(Context context) {
289
- if (!isRunning()) {
290
- Log.e(TAG, "The location tracker is not running");
291
- return null;
292
- }
293
-
294
- if (isFusedLocationProviderInitialized()) {
295
- Location location = getCachedLocation();
296
- if (location != null) {
297
- // If Play services worked, make sure location manager is disabled
298
- stopLocationUpdatesWithoutPlayServices();
299
- return location;
300
- }
301
- }
302
-
303
- // If Play services didn't work, try location manager
304
- try {
305
- if (!isLocationManagerConnected()) {
306
- initializeLocationManager(context);
307
- }
308
- } catch (SecurityException e) {
309
- Log.e(TAG, "Appium Settings has no access to location permission", e);
310
- }
311
- return isLocationManagerConnected() ? getCachedLocation() : null;
312
- }
313
- }
@@ -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;
18
-
19
- import android.content.Intent;
20
- import android.os.IBinder;
21
- import android.service.notification.NotificationListenerService;
22
- import android.service.notification.StatusBarNotification;
23
- import android.util.Log;
24
-
25
- import androidx.annotation.Nullable;
26
-
27
- import io.appium.settings.notifications.StoredNotification;
28
- import io.appium.settings.notifications.StoredNotifications;
29
-
30
- import java.util.Arrays;
31
- import java.util.LinkedList;
32
- import java.util.List;
33
- import java.util.ListIterator;
34
-
35
- public class NLService extends NotificationListenerService {
36
- private static final String TAG = NLService.class.getSimpleName();
37
- private static final int MAX_BUFFER_SIZE = 100;
38
-
39
- private final List<StoredNotification> notificationsBuffer = new LinkedList<>();
40
-
41
- @Override
42
- public void onCreate() {
43
- super.onCreate();
44
-
45
- synchronized (notificationsBuffer) {
46
- StoredNotifications.getInstance().bindNotificationsBuffer(notificationsBuffer);
47
- }
48
- }
49
-
50
- @Nullable
51
- @Override
52
- public IBinder onBind(Intent intent) {
53
- return super.onBind(intent);
54
- }
55
-
56
- @Override
57
- public void onListenerDisconnected() {
58
- Log.i(TAG, "The notification listener has been disconnected");
59
- synchronized (notificationsBuffer) {
60
- notificationsBuffer.clear();
61
- }
62
-
63
- super.onListenerDisconnected();
64
- }
65
-
66
- @Override
67
- public void onListenerConnected() {
68
- super.onListenerConnected();
69
- Log.i(TAG, "The notification listener is connected");
70
-
71
- synchronized (notificationsBuffer) {
72
- StatusBarNotification[] activeNotifications = getActiveNotifications();
73
- StatusBarNotification[] notificationsSlice = Arrays.copyOfRange(activeNotifications,
74
- 0, Math.min(MAX_BUFFER_SIZE, activeNotifications.length));
75
- notificationsBuffer.clear();
76
- for (StatusBarNotification sbn : notificationsSlice) {
77
- notificationsBuffer.add(new StoredNotification(sbn));
78
- }
79
- Log.d(TAG, String.format("Successfully synchronized %s active notifications", notificationsBuffer.size()));
80
- }
81
- }
82
-
83
- @Override
84
- public void onNotificationPosted(StatusBarNotification sbn) {
85
- synchronized (notificationsBuffer) {
86
- if (notificationsBuffer.size() >= MAX_BUFFER_SIZE) {
87
- Log.d(TAG, String.format("The notifications buffer size has reached its maximum size of %s items. " +
88
- "Shrinking it in order to satisfy the constraints.", notificationsBuffer.size()));
89
- StoredNotification itemToRemove = null;
90
- ListIterator<StoredNotification> iter = notificationsBuffer.listIterator(notificationsBuffer.size());
91
- while (iter.hasPrevious()) {
92
- StoredNotification currentItem = iter.previous();
93
- if (itemToRemove == null) {
94
- // Remove the last item in the list if nothing else matches
95
- itemToRemove = currentItem;
96
- }
97
- if (currentItem.isRemoved()) {
98
- itemToRemove = currentItem;
99
- // Quit the loop as soon as we found the oldest item marked as removed
100
- break;
101
- }
102
- }
103
- if (itemToRemove != null) {
104
- notificationsBuffer.remove(itemToRemove);
105
- }
106
- }
107
- try {
108
- if (notificationsBuffer.isEmpty()) {
109
- notificationsBuffer.add(new StoredNotification((sbn)));
110
- } else {
111
- notificationsBuffer.add(0, new StoredNotification(sbn));
112
- }
113
- Log.d(TAG, String.format("Successfully stored the newly arrived notification identified by %s",
114
- sbn.getId()));
115
- } catch (Exception e) {
116
- Log.e(TAG, "Cannot store the newly arrived notification", e);
117
- }
118
- }
119
- }
120
-
121
- @Override
122
- public void onNotificationRemoved(StatusBarNotification sbn) {
123
- synchronized (notificationsBuffer) {
124
- for (StoredNotification storedNotification : notificationsBuffer) {
125
- if (storedNotification.getNotification().getId() == sbn.getId()) {
126
- storedNotification.setRemoved(true);
127
- Log.d(TAG, String.format("Successfully marked the removed notification identified by %s",
128
- sbn.getId()));
129
- break;
130
- }
131
- }
132
- }
133
- }
134
- }