io.appium.settings 4.2.0 → 4.2.2

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,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.receivers;
18
-
19
- import android.app.Activity;
20
- import android.content.BroadcastReceiver;
21
- import android.content.Context;
22
- import android.content.Intent;
23
- import android.location.Location;
24
- import android.util.Log;
25
-
26
- import java.util.Locale;
27
-
28
- import io.appium.settings.LocationTracker;
29
-
30
- public class LocationInfoReceiver extends BroadcastReceiver
31
- implements HasAction {
32
- private static final String TAG = LocationInfoReceiver.class.getSimpleName();
33
- private static final String FORCE_UPDATE = "forceUpdate";
34
-
35
- private static final String ACTION = "io.appium.settings.location";
36
-
37
- /**
38
- * Responds to broadcast requests like
39
- * am broadcast -a io.appium.settings.location
40
- * with location properties separated by a single space
41
- */
42
- @Override
43
- public void onReceive(Context context, Intent intent) {
44
- Log.d(TAG, "Getting current location");
45
- LocationTracker tracker = LocationTracker.getInstance();
46
- if (intent.hasExtra(FORCE_UPDATE)
47
- && intent.getBooleanExtra(FORCE_UPDATE, false)) {
48
- Log.d(TAG, "Initiating forced location update");
49
- tracker.forceLocationUpdate(context);
50
- }
51
- final Location location = tracker.getLocation(context);
52
- if (location != null) {
53
- setResultCode(Activity.RESULT_OK);
54
- // Decimal separator is a dot
55
- setResultData(String.format(Locale.US, "%.7f %.7f %.7f",
56
- location.getLatitude(), location.getLongitude(), location.getAltitude()));
57
- } else {
58
- setResultCode(Activity.RESULT_CANCELED);
59
- setResultData("");
60
- }
61
- }
62
-
63
- @Override
64
- public String getAction() {
65
- return ACTION;
66
- }
67
- }
@@ -1,91 +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.receivers;
18
-
19
- import android.app.Activity;
20
- import android.content.BroadcastReceiver;
21
- import android.content.Context;
22
- import android.content.Intent;
23
- import android.media.MediaScannerConnection;
24
- import android.util.Log;
25
-
26
- import java.io.File;
27
- import java.util.ArrayList;
28
- import java.util.Collections;
29
- import java.util.List;
30
-
31
- public class MediaScannerReceiver extends BroadcastReceiver
32
- implements HasAction {
33
- private static final String TAG = MediaScannerReceiver.class.getSimpleName();
34
- private static final String ACTION = "io.appium.settings.scan_media";
35
- private static final String PATH = "path";
36
-
37
- private List<String> fetchFiles(File root) {
38
- if (root.isFile()) {
39
- return root.canRead()
40
- ? Collections.singletonList(root.toString())
41
- : Collections.emptyList();
42
- }
43
- File[] items = root.listFiles();
44
- if (items == null) {
45
- return Collections.emptyList();
46
- }
47
- List<String> filePaths = new ArrayList<>();
48
- for (File item : items) {
49
- filePaths.addAll(fetchFiles(item));
50
- }
51
- return filePaths;
52
- }
53
-
54
- /**
55
- * Responds to broadcast requests like
56
- * am broadcast -a io.appium.settings.scan_media -e path /sdcard/yolo
57
- * by scanning all files/folders under the given path
58
- */
59
- @Override
60
- public void onReceive(Context context, Intent intent) {
61
- Log.d(TAG, "Scanning the requested media");
62
- if (!intent.hasExtra(PATH)) {
63
- Log.e(TAG, "No path has been provided");
64
- setResultCode(Activity.RESULT_CANCELED);
65
- setResultData("");
66
- return;
67
- }
68
- File item = new File(intent.getStringExtra(PATH));
69
- if (!item.exists()) {
70
- Log.e(TAG, String.format("The item at '%s' does not exist", item.toString()));
71
- setResultCode(Activity.RESULT_CANCELED);
72
- setResultData("");
73
- return;
74
- }
75
- List<String> filePaths = fetchFiles(item);
76
- if (filePaths.isEmpty()) {
77
- Log.i(TAG, String.format("Found no files to scan at '%s'", item.toString()));
78
- } else {
79
- MediaScannerConnection.scanFile(context, filePaths.toArray(new String[0]), null, null);
80
- Log.i(TAG, String.format("Successfully scanned %s file(s) at '%s'",
81
- filePaths.size(), item.toString()));
82
- }
83
- setResultCode(Activity.RESULT_OK);
84
- setResultData("");
85
- }
86
-
87
- @Override
88
- public String getAction() {
89
- return ACTION;
90
- }
91
- }
@@ -1,100 +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.receivers;
18
-
19
- import android.app.Activity;
20
- import android.content.BroadcastReceiver;
21
- import android.content.ComponentName;
22
- import android.content.Context;
23
- import android.content.Intent;
24
- import android.provider.Settings;
25
- import android.text.TextUtils;
26
- import android.util.Log;
27
-
28
- import androidx.annotation.Nullable;
29
-
30
- import io.appium.settings.notifications.StoredNotifications;
31
- import org.json.JSONArray;
32
- import org.json.JSONException;
33
- import org.json.JSONObject;
34
-
35
- public class NotificationsReceiver extends BroadcastReceiver
36
- implements HasAction {
37
- private static final String TAG = NotificationsReceiver.class.getSimpleName();
38
- private static final String ENABLED_NOTIFICATION_LISTENERS = "enabled_notification_listeners";
39
- private static final String ACTION = "io.appium.settings.notifications";
40
-
41
- private boolean isNotificationServiceEnabled(Context context) {
42
- String pkgName = context.getPackageName();
43
- final String enabledListeners = Settings.Secure.getString(context.getContentResolver(),
44
- ENABLED_NOTIFICATION_LISTENERS);
45
- if (TextUtils.isEmpty(enabledListeners)) {
46
- return false;
47
- }
48
- for (String name : enabledListeners.split(":")) {
49
- ComponentName cn = ComponentName.unflattenFromString(name);
50
- if (cn != null && TextUtils.equals(pkgName, cn.getPackageName())) {
51
- return true;
52
- }
53
- }
54
- return false;
55
- }
56
-
57
- @Nullable
58
- private JSONObject getResponse() {
59
- try {
60
- JSONArray notifications = StoredNotifications.getInstance().getNotifications();
61
- JSONObject result = new JSONObject();
62
- result.put("statusBarNotifications", notifications);
63
- return result;
64
- } catch (JSONException e) {
65
- e.printStackTrace();
66
- return null;
67
- }
68
- }
69
-
70
- /**
71
- * Responds to broadcast requests like
72
- * am broadcast -a io.appium.settings.notifications
73
- * with the list of buffered notifications formatted as JSON
74
- */
75
- @Override
76
- public void onReceive(Context context, Intent intent) {
77
- Log.d(TAG, "Getting system notifications");
78
- String result;
79
- if (isNotificationServiceEnabled(context)) {
80
- JSONObject response = getResponse();
81
- if (response == null) {
82
- result = "Cannot parse the resulting notifications list. Check the device log for more details.";
83
- Log.e(TAG, result);
84
- } else {
85
- result = response.toString();
86
- }
87
- } else {
88
- result = "Appium Settings helper has no access to the system notifications. " +
89
- "The access must be granted manually via 'Notification access' page in device Settings.";
90
- Log.e(TAG, result);
91
- }
92
- setResultCode(Activity.RESULT_OK);
93
- setResultData(result);
94
- }
95
-
96
- @Override
97
- public String getAction() {
98
- return ACTION;
99
- }
100
- }
@@ -1,113 +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.receivers;
18
-
19
- import android.app.Activity;
20
- import android.content.BroadcastReceiver;
21
- import android.content.Context;
22
- import android.content.Intent;
23
- import android.database.Cursor;
24
- import android.net.Uri;
25
- import android.util.Log;
26
- import org.json.JSONArray;
27
- import org.json.JSONException;
28
- import org.json.JSONObject;
29
-
30
- import static io.appium.settings.helpers.Utils.formatJsonNull;
31
-
32
- public class SmsReader extends BroadcastReceiver implements HasAction {
33
- private static final String TAG = SmsReader.class.getSimpleName();
34
- private static final Uri INCOMING_SMS = Uri.parse("content://sms/inbox");
35
- private static final String ACTION = "io.appium.settings.sms.read";
36
- private static final int MAX_ITEMS = 100;
37
- private static final String MAX_ITEMS_SETTING_NAME = "max";
38
- private static final String[][] SMS_INFO_MAPPING = new String[][]{
39
- {"_id", "id"},
40
- {"address", "address"},
41
- {"person", "person"},
42
- {"date", "date"},
43
- {"read", "read"},
44
- {"status", "status"},
45
- {"type", "type"},
46
- {"subject", "subject"},
47
- {"body", "body"},
48
- {"service_center", "serviceCenter"}
49
- };
50
-
51
- private JSONObject listSms(Context context, int maxCount) throws JSONException {
52
- Cursor cursor = context.getContentResolver().query(INCOMING_SMS,
53
- null, null, null, "date desc");
54
- //noinspection TryFinallyCanBeTryWithResources
55
- try {
56
- JSONArray items = new JSONArray();
57
- if (cursor != null && cursor.moveToFirst()) {
58
- do {
59
- JSONObject item = new JSONObject();
60
- for (String[] entry : SMS_INFO_MAPPING) {
61
- int columnIndex = cursor.getColumnIndex(entry[0]);
62
- if (columnIndex >= 0) {
63
- item.put(entry[1], formatJsonNull(cursor.getString(columnIndex)));
64
- }
65
- }
66
- items.put(item);
67
- } while (cursor.moveToNext() && items.length() < maxCount);
68
- }
69
- JSONObject result = new JSONObject();
70
- result.put("items", items);
71
- result.put("total", cursor == null ? 0 : cursor.getCount());
72
- return result;
73
- } finally {
74
- if (cursor != null) {
75
- cursor.close();
76
- }
77
- }
78
- }
79
-
80
- /**
81
- * Responds to broadcast requests like
82
- * am broadcast -a io.appium.settings.sms.read --es max 10
83
- * with the list of the recent SMS messages formatted as JSON
84
- */
85
- @Override
86
- public void onReceive(Context context, Intent intent) {
87
- int maxItems = MAX_ITEMS;
88
- if (intent.hasExtra(MAX_ITEMS_SETTING_NAME)) {
89
- try {
90
- maxItems = Integer.parseInt(intent.getStringExtra(MAX_ITEMS_SETTING_NAME));
91
- } catch (NumberFormatException e) {
92
- e.printStackTrace();
93
- }
94
- }
95
- Log.d(TAG, String.format("Getting the recent %s SMS messages", maxItems));
96
- String output;
97
- try {
98
- output = listSms(context, maxItems).toString();
99
- } catch (Exception e) {
100
- e.printStackTrace();
101
- output = "Appium Settings helper is unable to list SMS messages. " +
102
- "Check the logcat output for more details.";
103
- Log.e(TAG, output);
104
- }
105
- setResultCode(Activity.RESULT_OK);
106
- setResultData(output);
107
- }
108
-
109
- @Override
110
- public String getAction() {
111
- return ACTION;
112
- }
113
- }
@@ -1,84 +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.receivers;
18
-
19
- import android.annotation.SuppressLint;
20
- import android.app.Activity;
21
- import android.bluetooth.BluetoothAdapter;
22
- import android.bluetooth.BluetoothDevice;
23
- import android.content.BroadcastReceiver;
24
- import android.content.Context;
25
- import android.content.Intent;
26
- import android.util.Log;
27
-
28
- import java.lang.reflect.InvocationTargetException;
29
- import java.util.Set;
30
-
31
- @SuppressLint("MissingPermission")
32
- public class UnpairBluetoothDevicesReceiver extends BroadcastReceiver implements HasAction {
33
- private static final String TAG = UnpairBluetoothDevicesReceiver.class.getSimpleName();
34
-
35
- private static final String ACTION = "io.appium.settings.unpair_bluetooth";
36
-
37
- /**
38
- * am broadcast -a io.appium.settings.unpair_bluetooth
39
- */
40
- @Override
41
- public void onReceive(Context context, Intent intent) {
42
- Log.d(TAG, "Unpairing bluetooth devices");
43
- BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
44
- if (bluetoothAdapter == null) {
45
- String message = "No Bluetooth adapter found";
46
- Log.e(TAG, message);
47
- setResultCode(Activity.RESULT_CANCELED);
48
- setResultData(message);
49
- return;
50
- }
51
- Set<BluetoothDevice> bondedBluetoothDevices = bluetoothAdapter.getBondedDevices();
52
- if (bondedBluetoothDevices.isEmpty()) {
53
- setResultCode(Activity.RESULT_OK);
54
- setResultData("No paired devices found");
55
- return;
56
- }
57
- unpairBluetoothDevices(bondedBluetoothDevices);
58
- }
59
-
60
- private void unpairBluetoothDevices(Set<BluetoothDevice> bondedDevices) {
61
- try {
62
- for (BluetoothDevice device : bondedDevices) {
63
- unpairBluetoothDevice(device);
64
- }
65
- setResultCode(Activity.RESULT_OK);
66
- } catch (Exception e) {
67
- String message = String.format("Unpairing bluetooth devices failed with exception: %s", e.getMessage());
68
- Log.e(TAG, message);
69
- setResultCode(Activity.RESULT_CANCELED);
70
- setResultData(message);
71
- }
72
- }
73
-
74
- private void unpairBluetoothDevice(BluetoothDevice device)
75
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
76
- //noinspection JavaReflectionMemberAccess
77
- device.getClass().getMethod("removeBond").invoke(device);
78
- }
79
-
80
- @Override
81
- public String getAction() {
82
- return ACTION;
83
- }
84
- }
@@ -1,39 +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.receivers;
18
-
19
- import android.content.Context;
20
-
21
- import io.appium.settings.handlers.WiFiConnectionSettingHandler;
22
-
23
- /**
24
- * am broadcast -a io.appium.settings.wifi --es setstatus [enable|disable]
25
- */
26
- public class WiFiConnectionSettingReceiver extends AbstractSettingReceiver
27
- implements HasAction {
28
- private static final String ACTION = "io.appium.settings.wifi";
29
-
30
- @Override
31
- protected WiFiConnectionSettingHandler getHandler(Context context) {
32
- return new WiFiConnectionSettingHandler(context);
33
- }
34
-
35
- @Override
36
- public String getAction() {
37
- return ACTION;
38
- }
39
- }
@@ -1,94 +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.recorder;
18
-
19
- import android.media.MediaFormat;
20
- import android.os.Build;
21
- import android.util.Size;
22
-
23
- import java.util.Arrays;
24
- import java.util.List;
25
-
26
- import androidx.annotation.RequiresApi;
27
- import io.appium.settings.BuildConfig;
28
-
29
- public class RecorderConstant {
30
- public static final int REQUEST_CODE_SCREEN_CAPTURE = 123;
31
- public static final String ACTION_RECORDING_BASE = BuildConfig.APPLICATION_ID + ".recording";
32
- public static final String ACTION_RECORDING_START = ACTION_RECORDING_BASE + ".ACTION_START";
33
- public static final String ACTION_RECORDING_STOP = ACTION_RECORDING_BASE + ".ACTION_STOP";
34
- public static final String ACTION_RECORDING_RESULT_CODE = "result_code";
35
- public static final String ACTION_RECORDING_ROTATION = "recording_rotation";
36
- public static final String ACTION_RECORDING_FILENAME = "filename";
37
- public static final String ACTION_RECORDING_PRIORITY = "priority";
38
- public static final String ACTION_RECORDING_MAX_DURATION = "max_duration_sec";
39
- public static final String ACTION_RECORDING_RESOLUTION = "resolution";
40
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
41
- public static final String RECORDING_DEFAULT_VIDEO_MIME_TYPE = MediaFormat.MIMETYPE_VIDEO_AVC;
42
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
43
- public static final Size RECORDING_RESOLUTION_FULL_HD = new Size(1920, 1080);
44
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
45
- public static final Size RECORDING_RESOLUTION_HD = new Size(1280, 720);
46
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
47
- public static final Size RECORDING_RESOLUTION_480P = new Size(720, 480);
48
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
49
- public static final Size RECORDING_RESOLUTION_QVGA = new Size(320, 240);
50
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
51
- public static final Size RECORDING_RESOLUTION_QCIF = new Size(176, 144);
52
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
53
- public static final Size RECORDING_RESOLUTION_DEFAULT = new Size(1920, 1080);
54
- public static final float BITRATE_MULTIPLIER = 0.25f;
55
- public static final int AUDIO_CODEC_SAMPLE_RATE_HZ = 44100;
56
- public static final int AUDIO_CODEC_CHANNEL_COUNT = 1;
57
- public static final int AUDIO_CODEC_REPEAT_PREV_FRAME_AFTER_MS = 1000000;
58
- public static final int AUDIO_CODEC_I_FRAME_INTERVAL_MS = 5;
59
- public static final int AUDIO_CODEC_DEFAULT_BITRATE = 64000;
60
- public static final int VIDEO_CODEC_DEFAULT_FRAME_RATE = 30;
61
- public static final long MEDIA_QUEUE_BUFFERING_DEFAULT_TIMEOUT_MS = 10000;
62
- public static final long NANOSECONDS_IN_MICROSECOND = 1000;
63
- public static final String NO_PATH_SET = "";
64
- public static final long NO_TIMESTAMP_SET = -1;
65
- // Assume 0 degree == portrait as default
66
- public static final int RECORDING_ROTATION_DEFAULT_DEGREE = 0;
67
- public static final int NO_TRACK_INDEX_SET = -1;
68
- public static final String NO_RESOLUTION_MODE_SET = "";
69
- public static final String RECORDING_PRIORITY_MAX = "high";
70
- public static final String RECORDING_PRIORITY_NORM = "normal";
71
- public static final String RECORDING_PRIORITY_MIN = "low";
72
- public static final int RECORDING_PRIORITY_DEFAULT = Thread.MAX_PRIORITY;
73
- public static final int RECORDING_MAX_DURATION_DEFAULT_MS = 15 * 60 * 1000; // 15 Minutes, in milliseconds
74
- /*
75
- * Note: Reason we limit recording to following resolution list is that
76
- * android's AVC/H264 video encoder capabilities varies device-to-device (OEM modifications)
77
- * and with values larger than 1920x1080, isSizeSupported(width, height) method (see https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities#isSizeSupported(int,%20int))
78
- * returns false on tested devices and also with arbitrary values between supported range,
79
- * sometimes MediaEncoder.configure() method crashes with an exception on some phones
80
- * also default supported resolutions as per CTS tests are limited to following values (values between 176x144 and 1920x1080)
81
- * see https://android.googlesource.com/platform/cts/+/refs/heads/android12-qpr1-release/tests/tests/media/src/android/media/cts/VideoEncoderTest.java#1766
82
- * because of these reasons, to support wide variety of devices, we pre-limit resolution modes to the following values
83
- */
84
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
85
- public static final List<Size> RECORDING_RESOLUTION_LIST =
86
- Arrays.asList(
87
- new Size(1920, 1080),
88
- new Size(1280, 720),
89
- new Size(720, 480),
90
- new Size(320, 240),
91
- new Size(176, 144));
92
- // 1048576 Bps == 1 Mbps (1024*1024)
93
- public static final float BPS_IN_MBPS = 1048576f;
94
- }