appium-android-driver 15.0.0-beta.2 → 15.0.0

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 (171) hide show
  1. package/CHANGELOG.md +38 -8
  2. package/build/lib/commands/app-management.d.ts +26 -0
  3. package/build/lib/commands/app-management.d.ts.map +1 -1
  4. package/build/lib/commands/app-management.js +4 -3
  5. package/build/lib/commands/app-management.js.map +1 -1
  6. package/build/lib/commands/appearance.d.ts +7 -0
  7. package/build/lib/commands/appearance.d.ts.map +1 -1
  8. package/build/lib/commands/appearance.js.map +1 -1
  9. package/build/lib/commands/bluetooth.d.ts +6 -0
  10. package/build/lib/commands/bluetooth.d.ts.map +1 -1
  11. package/build/lib/commands/bluetooth.js +1 -1
  12. package/build/lib/commands/bluetooth.js.map +1 -1
  13. package/build/lib/commands/context/exports.d.ts +25 -0
  14. package/build/lib/commands/context/exports.d.ts.map +1 -1
  15. package/build/lib/commands/context/exports.js +10 -6
  16. package/build/lib/commands/context/exports.js.map +1 -1
  17. package/build/lib/commands/device/common.d.ts +9 -0
  18. package/build/lib/commands/device/common.d.ts.map +1 -1
  19. package/build/lib/commands/device/common.js +1 -1
  20. package/build/lib/commands/device/common.js.map +1 -1
  21. package/build/lib/commands/device/emulator-actions.d.ts +22 -0
  22. package/build/lib/commands/device/emulator-actions.d.ts.map +1 -1
  23. package/build/lib/commands/device/emulator-actions.js.map +1 -1
  24. package/build/lib/commands/device/emulator-console.d.ts +6 -0
  25. package/build/lib/commands/device/emulator-console.d.ts.map +1 -1
  26. package/build/lib/commands/device/emulator-console.js.map +1 -1
  27. package/build/lib/commands/device/utils.js +3 -3
  28. package/build/lib/commands/device/utils.js.map +1 -1
  29. package/build/lib/commands/deviceidle.d.ts +6 -0
  30. package/build/lib/commands/deviceidle.d.ts.map +1 -1
  31. package/build/lib/commands/deviceidle.js +1 -1
  32. package/build/lib/commands/deviceidle.js.map +1 -1
  33. package/build/lib/commands/element.d.ts +20 -0
  34. package/build/lib/commands/element.d.ts.map +1 -1
  35. package/build/lib/commands/element.js +0 -1
  36. package/build/lib/commands/element.js.map +1 -1
  37. package/build/lib/commands/execute.d.ts +6 -0
  38. package/build/lib/commands/execute.d.ts.map +1 -1
  39. package/build/lib/commands/execute.js.map +1 -1
  40. package/build/lib/commands/file-actions.d.ts +9 -0
  41. package/build/lib/commands/file-actions.d.ts.map +1 -1
  42. package/build/lib/commands/file-actions.js.map +1 -1
  43. package/build/lib/commands/find.d.ts +8 -0
  44. package/build/lib/commands/find.d.ts.map +1 -1
  45. package/build/lib/commands/find.js.map +1 -1
  46. package/build/lib/commands/geolocation.d.ts +13 -0
  47. package/build/lib/commands/geolocation.d.ts.map +1 -1
  48. package/build/lib/commands/geolocation.js +2 -2
  49. package/build/lib/commands/geolocation.js.map +1 -1
  50. package/build/lib/commands/gestures.d.ts +6 -0
  51. package/build/lib/commands/gestures.d.ts.map +1 -1
  52. package/build/lib/commands/gestures.js.map +1 -1
  53. package/build/lib/commands/image-injection.d.ts +6 -0
  54. package/build/lib/commands/image-injection.d.ts.map +1 -1
  55. package/build/lib/commands/image-injection.js.map +1 -1
  56. package/build/lib/commands/ime.d.ts +11 -0
  57. package/build/lib/commands/ime.d.ts.map +1 -1
  58. package/build/lib/commands/ime.js.map +1 -1
  59. package/build/lib/commands/intent.d.ts +10 -0
  60. package/build/lib/commands/intent.d.ts.map +1 -1
  61. package/build/lib/commands/intent.js +4 -4
  62. package/build/lib/commands/intent.js.map +1 -1
  63. package/build/lib/commands/keyboard.d.ts +12 -0
  64. package/build/lib/commands/keyboard.d.ts.map +1 -1
  65. package/build/lib/commands/keyboard.js.map +1 -1
  66. package/build/lib/commands/legacy.d.ts +8 -0
  67. package/build/lib/commands/legacy.d.ts.map +1 -1
  68. package/build/lib/commands/legacy.js.map +1 -1
  69. package/build/lib/commands/lock/exports.d.ts +9 -0
  70. package/build/lib/commands/lock/exports.d.ts.map +1 -1
  71. package/build/lib/commands/lock/exports.js.map +1 -1
  72. package/build/lib/commands/lock/helpers.js +1 -1
  73. package/build/lib/commands/lock/helpers.js.map +1 -1
  74. package/build/lib/commands/log.d.ts +8 -13
  75. package/build/lib/commands/log.d.ts.map +1 -1
  76. package/build/lib/commands/log.js +4 -32
  77. package/build/lib/commands/log.js.map +1 -1
  78. package/build/lib/commands/media-projection.d.ts +8 -0
  79. package/build/lib/commands/media-projection.d.ts.map +1 -1
  80. package/build/lib/commands/media-projection.js.map +1 -1
  81. package/build/lib/commands/memory.d.ts +6 -0
  82. package/build/lib/commands/memory.d.ts.map +1 -1
  83. package/build/lib/commands/memory.js.map +1 -1
  84. package/build/lib/commands/misc.d.ts +12 -0
  85. package/build/lib/commands/misc.d.ts.map +1 -1
  86. package/build/lib/commands/misc.js.map +1 -1
  87. package/build/lib/commands/network.d.ts +15 -0
  88. package/build/lib/commands/network.d.ts.map +1 -1
  89. package/build/lib/commands/network.js +2 -2
  90. package/build/lib/commands/network.js.map +1 -1
  91. package/build/lib/commands/nfc.d.ts +6 -0
  92. package/build/lib/commands/nfc.d.ts.map +1 -1
  93. package/build/lib/commands/nfc.js +1 -1
  94. package/build/lib/commands/nfc.js.map +1 -1
  95. package/build/lib/commands/performance.d.ts +8 -0
  96. package/build/lib/commands/performance.d.ts.map +1 -1
  97. package/build/lib/commands/performance.js.map +1 -1
  98. package/build/lib/commands/permissions.d.ts +7 -0
  99. package/build/lib/commands/permissions.d.ts.map +1 -1
  100. package/build/lib/commands/permissions.js +3 -3
  101. package/build/lib/commands/permissions.js.map +1 -1
  102. package/build/lib/commands/recordscreen.d.ts +7 -0
  103. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  104. package/build/lib/commands/recordscreen.js.map +1 -1
  105. package/build/lib/commands/resources.d.ts +7 -0
  106. package/build/lib/commands/resources.d.ts.map +1 -1
  107. package/build/lib/commands/resources.js +1 -1
  108. package/build/lib/commands/resources.js.map +1 -1
  109. package/build/lib/commands/shell.d.ts +9 -0
  110. package/build/lib/commands/shell.d.ts.map +1 -1
  111. package/build/lib/commands/shell.js.map +1 -1
  112. package/build/lib/commands/streamscreen.d.ts +7 -0
  113. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  114. package/build/lib/commands/streamscreen.js.map +1 -1
  115. package/build/lib/commands/system-bars.d.ts +7 -0
  116. package/build/lib/commands/system-bars.d.ts.map +1 -1
  117. package/build/lib/commands/system-bars.js +2 -2
  118. package/build/lib/commands/system-bars.js.map +1 -1
  119. package/build/lib/commands/time.d.ts +7 -0
  120. package/build/lib/commands/time.d.ts.map +1 -1
  121. package/build/lib/commands/time.js.map +1 -1
  122. package/build/lib/constraints.d.ts +16 -3
  123. package/build/lib/constraints.d.ts.map +1 -1
  124. package/build/lib/constraints.js +16 -3
  125. package/build/lib/constraints.js.map +1 -1
  126. package/build/lib/driver.d.ts +36 -201
  127. package/build/lib/driver.d.ts.map +1 -1
  128. package/build/lib/driver.js +253 -168
  129. package/build/lib/driver.js.map +1 -1
  130. package/build/lib/utils.js +1 -1
  131. package/build/lib/utils.js.map +1 -1
  132. package/lib/commands/app-management.ts +33 -3
  133. package/lib/commands/appearance.ts +8 -0
  134. package/lib/commands/bluetooth.ts +8 -1
  135. package/lib/commands/context/exports.ts +46 -6
  136. package/lib/commands/device/common.ts +11 -1
  137. package/lib/commands/device/emulator-actions.ts +23 -0
  138. package/lib/commands/device/emulator-console.ts +9 -0
  139. package/lib/commands/device/utils.ts +3 -3
  140. package/lib/commands/deviceidle.ts +8 -1
  141. package/lib/commands/element.ts +21 -0
  142. package/lib/commands/execute.ts +7 -0
  143. package/lib/commands/file-actions.ts +10 -0
  144. package/lib/commands/find.ts +9 -0
  145. package/lib/commands/geolocation.ts +22 -2
  146. package/lib/commands/gestures.ts +7 -0
  147. package/lib/commands/image-injection.ts +9 -0
  148. package/lib/commands/ime.ts +12 -0
  149. package/lib/commands/intent.ts +25 -4
  150. package/lib/commands/keyboard.ts +15 -0
  151. package/lib/commands/legacy.ts +9 -0
  152. package/lib/commands/lock/exports.ts +10 -0
  153. package/lib/commands/lock/helpers.ts +1 -1
  154. package/lib/commands/log.ts +20 -35
  155. package/lib/commands/media-projection.ts +15 -0
  156. package/lib/commands/memory.ts +7 -0
  157. package/lib/commands/misc.ts +15 -0
  158. package/lib/commands/network.ts +18 -2
  159. package/lib/commands/nfc.ts +8 -1
  160. package/lib/commands/performance.ts +13 -0
  161. package/lib/commands/permissions.ts +15 -3
  162. package/lib/commands/recordscreen.ts +8 -0
  163. package/lib/commands/resources.ts +9 -1
  164. package/lib/commands/shell.ts +12 -0
  165. package/lib/commands/streamscreen.ts +12 -0
  166. package/lib/commands/system-bars.ts +12 -2
  167. package/lib/commands/time.ts +8 -0
  168. package/lib/constraints.ts +16 -3
  169. package/lib/driver.ts +289 -212
  170. package/lib/utils.ts +1 -1
  171. package/package.json +1 -1
@@ -6,9 +6,24 @@ import type {HTTPMethod, StringRecord} from '@appium/types';
6
6
  import type {ADB} from 'appium-adb';
7
7
  import dayjs from 'dayjs';
8
8
 
9
+ import type {AndroidDriverConstraints} from '../constraints.js';
9
10
  import type {AndroidDriver} from '../driver.js';
10
11
  import type {FormFields} from './types.js';
11
12
 
13
+ declare module '../driver.js' {
14
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
15
+ mobileIsMediaProjectionRecordingRunning(
16
+ ...args: Parameters<typeof mobileIsMediaProjectionRecordingRunning>
17
+ ): ReturnType<typeof mobileIsMediaProjectionRecordingRunning>;
18
+ mobileStartMediaProjectionRecording(
19
+ ...args: Parameters<typeof mobileStartMediaProjectionRecording>
20
+ ): ReturnType<typeof mobileStartMediaProjectionRecording>;
21
+ mobileStopMediaProjectionRecording(
22
+ ...args: Parameters<typeof mobileStopMediaProjectionRecording>
23
+ ): ReturnType<typeof mobileStopMediaProjectionRecording>;
24
+ }
25
+ }
26
+
12
27
  // https://github.com/appium/io.appium.settings#internal-audio--video-recording
13
28
  const DEFAULT_EXT = '.mp4';
14
29
  const MIN_API_LEVEL = 29;
@@ -1,8 +1,15 @@
1
1
  import {errors} from 'appium/driver.js';
2
2
 
3
+ import type {AndroidDriverConstraints} from '../constraints.js';
3
4
  import type {AndroidDriver} from '../driver.js';
4
5
  import type {TrimMemoryLevel} from './types.js';
5
6
 
7
+ declare module '../driver.js' {
8
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
9
+ mobileSendTrimMemory(...args: Parameters<typeof mobileSendTrimMemory>): ReturnType<typeof mobileSendTrimMemory>;
10
+ }
11
+ }
12
+
6
13
  /**
7
14
  * Simulates the onTrimMemory() event for the given package.
8
15
  * Read https://developer.android.com/topic/performance/memory
@@ -1,9 +1,24 @@
1
1
  import type {Size, Rect, StringRecord} from '@appium/types';
2
2
  import {errors} from 'appium/driver.js';
3
3
 
4
+ import type {AndroidDriverConstraints} from '../constraints.js';
4
5
  import type {AndroidDriver} from '../driver.js';
5
6
  import type {SmsListResult, ListSmsOpts} from './types.js';
6
7
 
8
+ declare module '../driver.js' {
9
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
10
+ getWindowRect(...args: Parameters<typeof getWindowRect>): ReturnType<typeof getWindowRect>;
11
+ getWindowSize(...args: Parameters<typeof getWindowSize>): ReturnType<typeof getWindowSize>;
12
+ getDisplayDensity(...args: Parameters<typeof getDisplayDensity>): ReturnType<typeof getDisplayDensity>;
13
+ mobileGetNotifications(
14
+ ...args: Parameters<typeof mobileGetNotifications>
15
+ ): ReturnType<typeof mobileGetNotifications>;
16
+ mobileListSms(...args: Parameters<typeof mobileListSms>): ReturnType<typeof mobileListSms>;
17
+ openNotifications(...args: Parameters<typeof openNotifications>): ReturnType<typeof openNotifications>;
18
+ setUrl(...args: Parameters<typeof setUrl>): ReturnType<typeof setUrl>;
19
+ }
20
+ }
21
+
7
22
  /**
8
23
  * Gets the window size.
9
24
  *
@@ -1,9 +1,25 @@
1
1
  import {util} from '@appium/support';
2
2
  import {errors} from 'appium/driver.js';
3
3
 
4
+ import type {AndroidDriverConstraints} from '../constraints.js';
4
5
  import type {AndroidDriver} from '../driver.js';
5
6
  import type {ServiceType, GetConnectivityResult} from './types.js';
6
7
 
8
+ declare module '../driver.js' {
9
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
10
+ getNetworkConnection(...args: Parameters<typeof getNetworkConnection>): ReturnType<typeof getNetworkConnection>;
11
+ isWifiOn(...args: Parameters<typeof isWifiOn>): ReturnType<typeof isWifiOn>;
12
+ mobileGetConnectivity(...args: Parameters<typeof mobileGetConnectivity>): ReturnType<typeof mobileGetConnectivity>;
13
+ mobileSetConnectivity(...args: Parameters<typeof mobileSetConnectivity>): ReturnType<typeof mobileSetConnectivity>;
14
+ setNetworkConnection(...args: Parameters<typeof setNetworkConnection>): ReturnType<typeof setNetworkConnection>;
15
+ setWifiState(...args: Parameters<typeof setWifiState>): ReturnType<typeof setWifiState>;
16
+ setDataState(...args: Parameters<typeof setDataState>): ReturnType<typeof setDataState>;
17
+ toggleData(...args: Parameters<typeof toggleData>): ReturnType<typeof toggleData>;
18
+ toggleFlightMode(...args: Parameters<typeof toggleFlightMode>): ReturnType<typeof toggleFlightMode>;
19
+ toggleWiFi(...args: Parameters<typeof toggleWiFi>): ReturnType<typeof toggleWiFi>;
20
+ }
21
+ }
22
+
7
23
  const AIRPLANE_MODE_MASK = 0b001;
8
24
  const WIFI_MASK = 0b010;
9
25
  const DATA_MASK = 0b100;
@@ -120,9 +136,9 @@ export async function mobileGetConnectivity(
120
136
  const unsupportedServices = svcs.filter((svc) => !SUPPORTED_SERVICE_NAMES.includes(svc));
121
137
  if (unsupportedServices.length > 0) {
122
138
  throw new errors.InvalidArgumentError(
123
- `${util.pluralize('Service name', unsupportedServices.length, false)} ${unsupportedServices} ` +
139
+ `${util.pluralize('Service name', unsupportedServices.length, false)} ${unsupportedServices.join(', ')} ` +
124
140
  `${unsupportedServices.length === 1 ? 'is' : 'are'} not known. Only the following services are ` +
125
- `suported: ${SUPPORTED_SERVICE_NAMES}`,
141
+ `suported: ${SUPPORTED_SERVICE_NAMES.join(', ')}`,
126
142
  );
127
143
  }
128
144
 
@@ -1,8 +1,15 @@
1
1
  import {errors} from 'appium/driver.js';
2
2
 
3
+ import type {AndroidDriverConstraints} from '../constraints.js';
3
4
  import type {AndroidDriver} from '../driver.js';
4
5
  import type {NfcAction} from './types.js';
5
6
 
7
+ declare module '../driver.js' {
8
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
9
+ mobileNfc(...args: Parameters<typeof mobileNfc>): ReturnType<typeof mobileNfc>;
10
+ }
11
+ }
12
+
6
13
  const SUPPORTED_ACTIONS = {
7
14
  ENABLE: 'enable',
8
15
  DISABLE: 'disable',
@@ -27,7 +34,7 @@ export async function mobileNfc(this: AndroidDriver, action: NfcAction): Promise
27
34
  break;
28
35
  default:
29
36
  throw new errors.InvalidArgumentError(
30
- `You must provide a valid 'action' argument. Supported actions are: ${Object.values(SUPPORTED_ACTIONS)}`,
37
+ `You must provide a valid 'action' argument. Supported actions are: ${Object.values(SUPPORTED_ACTIONS).join(', ')}`,
31
38
  );
32
39
  }
33
40
  }
@@ -2,9 +2,22 @@ import {util} from '@appium/support';
2
2
  import {retryInterval} from 'asyncbox';
3
3
  import type {ExecError} from 'teen_process';
4
4
 
5
+ import type {AndroidDriverConstraints} from '../constraints.js';
5
6
  import type {AndroidDriver} from '../driver.js';
6
7
  import type {PerformanceDataType} from './types.js';
7
8
 
9
+ declare module '../driver.js' {
10
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
11
+ getPerformanceData(...args: Parameters<typeof getPerformanceData>): ReturnType<typeof getPerformanceData>;
12
+ getPerformanceDataTypes(
13
+ ...args: Parameters<typeof getPerformanceDataTypes>
14
+ ): ReturnType<typeof getPerformanceDataTypes>;
15
+ mobileGetPerformanceData(
16
+ ...args: Parameters<typeof mobileGetPerformanceData>
17
+ ): ReturnType<typeof mobileGetPerformanceData>;
18
+ }
19
+ }
20
+
8
21
  export const NETWORK_KEYS = [
9
22
  ['bucketStart', 'activeTime', 'rxBytes', 'rxPackets', 'txBytes', 'txPackets', 'operations', 'bucketDuration'],
10
23
  ['st', 'activeTime', 'rb', 'rp', 'tb', 'tp', 'op', 'bucketDuration'],
@@ -1,9 +1,19 @@
1
1
  import {util} from '@appium/support';
2
2
  import {errors} from 'appium/driver.js';
3
3
 
4
+ import type {AndroidDriverConstraints} from '../constraints.js';
4
5
  import type {AndroidDriver} from '../driver.js';
5
6
  import {ADB_SHELL_FEATURE} from '../utils.js';
6
7
 
8
+ declare module '../driver.js' {
9
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
10
+ mobileChangePermissions(
11
+ ...args: Parameters<typeof mobileChangePermissions>
12
+ ): ReturnType<typeof mobileChangePermissions>;
13
+ mobileGetPermissions(...args: Parameters<typeof mobileGetPermissions>): ReturnType<typeof mobileGetPermissions>;
14
+ }
15
+ }
16
+
7
17
  const ALL_PERMISSIONS_MAGIC = 'all';
8
18
  const PM_ACTION = Object.freeze({
9
19
  GRANT: 'grant',
@@ -87,7 +97,9 @@ export async function mobileChangePermissions(
87
97
  action?.toLowerCase() as AppOpsAction,
88
98
  );
89
99
  default:
90
- throw new errors.InvalidArgumentError(`'target' argument must be one of: ${Object.values(PERMISSION_TARGET)}`);
100
+ throw new errors.InvalidArgumentError(
101
+ `'target' argument must be one of: ${Object.values(PERMISSION_TARGET).join(', ')}`,
102
+ );
91
103
  }
92
104
  }
93
105
  /**
@@ -138,7 +150,7 @@ async function changePermissionsViaPm(
138
150
 
139
151
  let affectedPermissions = Array.isArray(permissions) ? permissions : [permissions];
140
152
  if (typeof permissions === 'string' && permissions.toLowerCase() === ALL_PERMISSIONS_MAGIC) {
141
- const dumpsys = await this.adb.shell(['dumpsys', 'package', appPackage]);
153
+ const dumpsys = await this.adb.shell(['dumpsys', 'package', util.quote(appPackage)]);
142
154
  const grantedPermissions = await this.adb.getGrantedPermissions(appPackage, dumpsys);
143
155
  if (action === PM_ACTION.GRANT) {
144
156
  const reqPermissons = await this.adb.getReqPermissions(appPackage, dumpsys);
@@ -178,7 +190,7 @@ async function changePermissionsViaAppops(
178
190
  }
179
191
 
180
192
  const promises = (Array.isArray(permissions) ? permissions : [permissions]).map((permission) =>
181
- this.adb.shell(['appops', 'set', appPackage, permission, action]),
193
+ this.adb.shell(['appops', 'set', util.quote(appPackage), util.quote(permission), action]),
182
194
  );
183
195
  await Promise.all(promises);
184
196
  }
@@ -6,9 +6,17 @@ import type {ADB} from 'appium-adb';
6
6
  import {waitForCondition} from 'asyncbox';
7
7
  import {exec} from 'teen_process';
8
8
 
9
+ import type {AndroidDriverConstraints} from '../constraints.js';
9
10
  import type {AndroidDriver} from '../driver.js';
10
11
  import type {StartScreenRecordingOpts, StopScreenRecordingOpts, ScreenRecordingProperties} from './types.js';
11
12
 
13
+ declare module '../driver.js' {
14
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
15
+ startRecordingScreen(...args: Parameters<typeof startRecordingScreen>): ReturnType<typeof startRecordingScreen>;
16
+ stopRecordingScreen(...args: Parameters<typeof stopRecordingScreen>): ReturnType<typeof stopRecordingScreen>;
17
+ }
18
+ }
19
+
12
20
  const RETRY_PAUSE = 300;
13
21
  const RETRY_TIMEOUT = 5000;
14
22
  const MAX_RECORDING_TIME_SEC = 60 * 3;
@@ -1,9 +1,17 @@
1
1
  import {fs, tempDir, util} from '@appium/support';
2
2
  import type {StringRecord} from '@appium/types';
3
3
 
4
+ import type {AndroidDriverConstraints} from '../constraints.js';
4
5
  import type {AndroidDriver, AndroidDriverOpts} from '../driver.js';
5
6
  import type {Locale} from './types.js';
6
7
 
8
+ declare module '../driver.js' {
9
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
10
+ getStrings(...args: Parameters<typeof getStrings>): ReturnType<typeof getStrings>;
11
+ ensureDeviceLocale(...args: Parameters<typeof ensureDeviceLocale>): ReturnType<typeof ensureDeviceLocale>;
12
+ }
13
+ }
14
+
7
15
  /**
8
16
  * Gets the localized strings from the application.
9
17
  *
@@ -68,7 +76,7 @@ export async function ensureDeviceLocale(
68
76
  this.log.debug((e1 as Error).stack);
69
77
  }
70
78
  if (suggestions.length > 0) {
71
- errMsg += ` You may want to apply one of the following locales instead: ${suggestions}`;
79
+ errMsg += ` You may want to apply one of the following locales instead: ${suggestions.join(', ')}`;
72
80
  }
73
81
  throw new Error(errMsg, {cause: e});
74
82
  }
@@ -3,9 +3,21 @@ import {errors} from 'appium/driver.js';
3
3
  import {exec} from 'teen_process';
4
4
  import type {ExecError} from 'teen_process';
5
5
 
6
+ import type {AndroidDriverConstraints} from '../constraints.js';
6
7
  import type {AndroidDriver} from '../driver.js';
7
8
  import {ADB_SHELL_FEATURE} from '../utils.js';
8
9
 
10
+ declare module '../driver.js' {
11
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
12
+ mobileShell<T extends boolean>(
13
+ command: string,
14
+ args?: string[],
15
+ timeout?: number,
16
+ includeStderr?: T,
17
+ ): Promise<T extends true ? {stdout: string; stderr: string} : string>;
18
+ }
19
+ }
20
+
9
21
  /**
10
22
  * Executes a shell command on the device via ADB.
11
23
  *
@@ -10,9 +10,21 @@ import {waitForCondition} from 'asyncbox';
10
10
  import {checkPortStatus} from 'portscanner';
11
11
  import {SubProcess, exec} from 'teen_process';
12
12
 
13
+ import type {AndroidDriverConstraints} from '../constraints.js';
13
14
  import type {AndroidDriver} from '../driver.js';
14
15
  import type {DeviceInfo, InitGStreamerPipelineOpts} from './types.js';
15
16
 
17
+ declare module '../driver.js' {
18
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
19
+ mobileStartScreenStreaming(
20
+ ...args: Parameters<typeof mobileStartScreenStreaming>
21
+ ): ReturnType<typeof mobileStartScreenStreaming>;
22
+ mobileStopScreenStreaming(
23
+ ...args: Parameters<typeof mobileStopScreenStreaming>
24
+ ): ReturnType<typeof mobileStopScreenStreaming>;
25
+ }
26
+ }
27
+
16
28
  const RECORDING_INTERVAL_SEC = 5;
17
29
  const STREAMING_STARTUP_TIMEOUT_MS = 5000;
18
30
  const GSTREAMER_BINARY = `gst-launch-1.0${system.isWindows() ? '.exe' : ''}`;
@@ -2,9 +2,19 @@ import {util} from '@appium/support';
2
2
  import type {StringRecord} from '@appium/types';
3
3
  import {errors} from 'appium/driver.js';
4
4
 
5
+ import type {AndroidDriverConstraints} from '../constraints.js';
5
6
  import type {AndroidDriver} from '../driver.js';
6
7
  import type {StatusBarCommand, WindowProperties} from './types.js';
7
8
 
9
+ declare module '../driver.js' {
10
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
11
+ getSystemBars(...args: Parameters<typeof getSystemBars>): ReturnType<typeof getSystemBars>;
12
+ mobilePerformStatusBarCommand(
13
+ ...args: Parameters<typeof mobilePerformStatusBarCommand>
14
+ ): ReturnType<typeof mobilePerformStatusBarCommand>;
15
+ }
16
+ }
17
+
8
18
  const WINDOW_TITLE_PATTERN = /^\s+Window\s#\d+\sWindow\{[0-9a-f]+\s\w+\s([\w-]+)\}:$/;
9
19
  const FRAME_PATTERN = /\bm?[Ff]rame=\[([0-9.-]+),([0-9.-]+)\]\[([0-9.-]+),([0-9.-]+)\]/;
10
20
  // https://github.com/appium/appium-uiautomator2-driver/issues/904
@@ -88,7 +98,7 @@ export async function mobilePerformStatusBarCommand(
88
98
  if (!action) {
89
99
  throw new errors.InvalidArgumentError(
90
100
  `The '${command}' status bar command is unknown. Only the following commands ` +
91
- `are supported: ${Object.keys(statusBarCommands)}`,
101
+ `are supported: ${Object.keys(statusBarCommands).join(', ')}`,
92
102
  );
93
103
  }
94
104
  return await action();
@@ -181,7 +191,7 @@ export function parseWindows(this: AndroidDriver, lines: string): SystemBarsResu
181
191
  this.log.info(
182
192
  `No windows have been found whose title matches to ` +
183
193
  `'${namePrefix}'. Assuming it is invisible. ` +
184
- `Only the following windows are available: ${Object.keys(windows)}`,
194
+ `Only the following windows are available: ${Object.keys(windows).join(', ')}`,
185
195
  );
186
196
  result[window as keyof SystemBarsResult] = structuredClone(DEFAULT_WINDOW_PROPERTIES);
187
197
  }
@@ -2,8 +2,16 @@ import dayjs from 'dayjs';
2
2
  import customParseFormat from 'dayjs/plugin/customParseFormat.js';
3
3
  import utc from 'dayjs/plugin/utc.js';
4
4
 
5
+ import type {AndroidDriverConstraints} from '../constraints.js';
5
6
  import type {AndroidDriver} from '../driver.js';
6
7
 
8
+ declare module '../driver.js' {
9
+ interface AndroidDriver<C extends AndroidDriverConstraints> {
10
+ getDeviceTime(...args: Parameters<typeof getDeviceTime>): ReturnType<typeof getDeviceTime>;
11
+ mobileGetDeviceTime(...args: Parameters<typeof mobileGetDeviceTime>): ReturnType<typeof mobileGetDeviceTime>;
12
+ }
13
+ }
14
+
7
15
  dayjs.extend(utc);
8
16
  dayjs.extend(customParseFormat);
9
17
 
@@ -151,9 +151,6 @@ export const ANDROID_DRIVER_CONSTRAINTS = {
151
151
  recreateChromeDriverSessions: {
152
152
  isBoolean: true,
153
153
  },
154
- autoLaunch: {
155
- isBoolean: true,
156
- },
157
154
  nativeWebScreenshot: {
158
155
  isBoolean: true,
159
156
  },
@@ -209,6 +206,22 @@ export const ANDROID_DRIVER_CONSTRAINTS = {
209
206
  localeScript: {
210
207
  isString: true,
211
208
  },
209
+ locale: {
210
+ isString: true,
211
+ },
212
+ language: {
213
+ isString: true,
214
+ },
215
+ autoWebview: {
216
+ isBoolean: true,
217
+ },
218
+ orientation: {
219
+ isString: true,
220
+ inclusionCaseInsensitive: ['LANDSCAPE', 'PORTRAIT'],
221
+ },
222
+ udid: {
223
+ isString: true,
224
+ },
212
225
  skipDeviceInitialization: {
213
226
  isBoolean: true,
214
227
  },