appium-android-driver 13.3.4 → 14.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 (236) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/lib/commands/app-management.d.ts +2 -2
  3. package/build/lib/commands/app-management.d.ts.map +1 -1
  4. package/build/lib/commands/app-management.js +41 -67
  5. package/build/lib/commands/app-management.js.map +1 -1
  6. package/build/lib/commands/appearance.d.ts +1 -1
  7. package/build/lib/commands/appearance.d.ts.map +1 -1
  8. package/build/lib/commands/appearance.js +2 -6
  9. package/build/lib/commands/appearance.js.map +1 -1
  10. package/build/lib/commands/bidi/constants.js +4 -8
  11. package/build/lib/commands/bidi/constants.js.map +1 -1
  12. package/build/lib/commands/bidi/models.d.ts +1 -1
  13. package/build/lib/commands/bidi/models.d.ts.map +1 -1
  14. package/build/lib/commands/bidi/models.js +7 -13
  15. package/build/lib/commands/bidi/models.js.map +1 -1
  16. package/build/lib/commands/bidi/types.js +1 -2
  17. package/build/lib/commands/bluetooth.d.ts +1 -1
  18. package/build/lib/commands/bluetooth.d.ts.map +1 -1
  19. package/build/lib/commands/bluetooth.js +3 -6
  20. package/build/lib/commands/bluetooth.js.map +1 -1
  21. package/build/lib/commands/context/cache.d.ts +1 -1
  22. package/build/lib/commands/context/cache.d.ts.map +1 -1
  23. package/build/lib/commands/context/cache.js +5 -10
  24. package/build/lib/commands/context/cache.js.map +1 -1
  25. package/build/lib/commands/context/exports.d.ts +2 -2
  26. package/build/lib/commands/context/exports.d.ts.map +1 -1
  27. package/build/lib/commands/context/exports.js +64 -86
  28. package/build/lib/commands/context/exports.js.map +1 -1
  29. package/build/lib/commands/context/helpers.d.ts +2 -2
  30. package/build/lib/commands/context/helpers.d.ts.map +1 -1
  31. package/build/lib/commands/context/helpers.js +69 -82
  32. package/build/lib/commands/context/helpers.js.map +1 -1
  33. package/build/lib/commands/device/common.d.ts +2 -2
  34. package/build/lib/commands/device/common.d.ts.map +1 -1
  35. package/build/lib/commands/device/common.js +47 -77
  36. package/build/lib/commands/device/common.js.map +1 -1
  37. package/build/lib/commands/device/emulator-actions.d.ts +2 -2
  38. package/build/lib/commands/device/emulator-actions.d.ts.map +1 -1
  39. package/build/lib/commands/device/emulator-actions.js +33 -52
  40. package/build/lib/commands/device/emulator-actions.js.map +1 -1
  41. package/build/lib/commands/device/emulator-console.d.ts +1 -1
  42. package/build/lib/commands/device/emulator-console.d.ts.map +1 -1
  43. package/build/lib/commands/device/emulator-console.js +3 -6
  44. package/build/lib/commands/device/emulator-console.js.map +1 -1
  45. package/build/lib/commands/device/utils.d.ts +1 -1
  46. package/build/lib/commands/device/utils.d.ts.map +1 -1
  47. package/build/lib/commands/device/utils.js +27 -37
  48. package/build/lib/commands/device/utils.js.map +1 -1
  49. package/build/lib/commands/deviceidle.d.ts +1 -1
  50. package/build/lib/commands/deviceidle.d.ts.map +1 -1
  51. package/build/lib/commands/deviceidle.js +4 -7
  52. package/build/lib/commands/deviceidle.js.map +1 -1
  53. package/build/lib/commands/element.d.ts +2 -2
  54. package/build/lib/commands/element.d.ts.map +1 -1
  55. package/build/lib/commands/element.js +22 -39
  56. package/build/lib/commands/element.js.map +1 -1
  57. package/build/lib/commands/execute.d.ts +1 -1
  58. package/build/lib/commands/execute.d.ts.map +1 -1
  59. package/build/lib/commands/execute.js +6 -9
  60. package/build/lib/commands/execute.js.map +1 -1
  61. package/build/lib/commands/file-actions.d.ts +1 -1
  62. package/build/lib/commands/file-actions.d.ts.map +1 -1
  63. package/build/lib/commands/file-actions.js +25 -34
  64. package/build/lib/commands/file-actions.js.map +1 -1
  65. package/build/lib/commands/find.d.ts +2 -2
  66. package/build/lib/commands/find.d.ts.map +1 -1
  67. package/build/lib/commands/find.js +10 -14
  68. package/build/lib/commands/find.js.map +1 -1
  69. package/build/lib/commands/geolocation.d.ts +1 -1
  70. package/build/lib/commands/geolocation.d.ts.map +1 -1
  71. package/build/lib/commands/geolocation.js +21 -35
  72. package/build/lib/commands/geolocation.js.map +1 -1
  73. package/build/lib/commands/gestures.d.ts +1 -1
  74. package/build/lib/commands/gestures.d.ts.map +1 -1
  75. package/build/lib/commands/gestures.js +4 -7
  76. package/build/lib/commands/gestures.js.map +1 -1
  77. package/build/lib/commands/image-injection.d.ts +1 -1
  78. package/build/lib/commands/image-injection.d.ts.map +1 -1
  79. package/build/lib/commands/image-injection.js +16 -23
  80. package/build/lib/commands/image-injection.js.map +1 -1
  81. package/build/lib/commands/ime.d.ts +1 -1
  82. package/build/lib/commands/ime.d.ts.map +1 -1
  83. package/build/lib/commands/ime.js +10 -18
  84. package/build/lib/commands/ime.js.map +1 -1
  85. package/build/lib/commands/intent.d.ts +1 -1
  86. package/build/lib/commands/intent.d.ts.map +1 -1
  87. package/build/lib/commands/intent.js +22 -29
  88. package/build/lib/commands/intent.js.map +1 -1
  89. package/build/lib/commands/keyboard.d.ts +2 -2
  90. package/build/lib/commands/keyboard.d.ts.map +1 -1
  91. package/build/lib/commands/keyboard.js +21 -33
  92. package/build/lib/commands/keyboard.js.map +1 -1
  93. package/build/lib/commands/legacy.d.ts +1 -1
  94. package/build/lib/commands/legacy.d.ts.map +1 -1
  95. package/build/lib/commands/legacy.js +7 -12
  96. package/build/lib/commands/legacy.js.map +1 -1
  97. package/build/lib/commands/lock/exports.d.ts +2 -2
  98. package/build/lib/commands/lock/exports.d.ts.map +1 -1
  99. package/build/lib/commands/lock/exports.js +18 -25
  100. package/build/lib/commands/lock/exports.js.map +1 -1
  101. package/build/lib/commands/lock/helpers.d.ts +2 -2
  102. package/build/lib/commands/lock/helpers.d.ts.map +1 -1
  103. package/build/lib/commands/lock/helpers.js +48 -64
  104. package/build/lib/commands/lock/helpers.js.map +1 -1
  105. package/build/lib/commands/log.d.ts +2 -2
  106. package/build/lib/commands/log.d.ts.map +1 -1
  107. package/build/lib/commands/log.js +38 -42
  108. package/build/lib/commands/log.js.map +1 -1
  109. package/build/lib/commands/media-projection.d.ts +2 -2
  110. package/build/lib/commands/media-projection.d.ts.map +1 -1
  111. package/build/lib/commands/media-projection.js +14 -22
  112. package/build/lib/commands/media-projection.js.map +1 -1
  113. package/build/lib/commands/memory.d.ts +2 -2
  114. package/build/lib/commands/memory.d.ts.map +1 -1
  115. package/build/lib/commands/memory.js +4 -7
  116. package/build/lib/commands/memory.js.map +1 -1
  117. package/build/lib/commands/misc.d.ts +2 -2
  118. package/build/lib/commands/misc.d.ts.map +1 -1
  119. package/build/lib/commands/misc.js +10 -19
  120. package/build/lib/commands/misc.js.map +1 -1
  121. package/build/lib/commands/network.d.ts +2 -2
  122. package/build/lib/commands/network.d.ts.map +1 -1
  123. package/build/lib/commands/network.js +14 -26
  124. package/build/lib/commands/network.js.map +1 -1
  125. package/build/lib/commands/nfc.d.ts +2 -2
  126. package/build/lib/commands/nfc.d.ts.map +1 -1
  127. package/build/lib/commands/nfc.js +3 -6
  128. package/build/lib/commands/nfc.js.map +1 -1
  129. package/build/lib/commands/performance.d.ts +2 -2
  130. package/build/lib/commands/performance.d.ts.map +1 -1
  131. package/build/lib/commands/performance.js +48 -58
  132. package/build/lib/commands/performance.js.map +1 -1
  133. package/build/lib/commands/permissions.d.ts +1 -1
  134. package/build/lib/commands/permissions.d.ts.map +1 -1
  135. package/build/lib/commands/permissions.js +16 -20
  136. package/build/lib/commands/permissions.js.map +1 -1
  137. package/build/lib/commands/recordscreen.d.ts +2 -2
  138. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  139. package/build/lib/commands/recordscreen.js +32 -39
  140. package/build/lib/commands/recordscreen.js.map +1 -1
  141. package/build/lib/commands/resources.d.ts +1 -1
  142. package/build/lib/commands/resources.d.ts.map +1 -1
  143. package/build/lib/commands/resources.js +7 -11
  144. package/build/lib/commands/resources.js.map +1 -1
  145. package/build/lib/commands/shell.d.ts +1 -1
  146. package/build/lib/commands/shell.d.ts.map +1 -1
  147. package/build/lib/commands/shell.js +9 -12
  148. package/build/lib/commands/shell.js.map +1 -1
  149. package/build/lib/commands/streamscreen.d.ts +1 -1
  150. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  151. package/build/lib/commands/streamscreen.js +32 -37
  152. package/build/lib/commands/streamscreen.js.map +1 -1
  153. package/build/lib/commands/system-bars.d.ts +2 -2
  154. package/build/lib/commands/system-bars.d.ts.map +1 -1
  155. package/build/lib/commands/system-bars.js +10 -16
  156. package/build/lib/commands/system-bars.js.map +1 -1
  157. package/build/lib/commands/time.d.ts +1 -1
  158. package/build/lib/commands/time.d.ts.map +1 -1
  159. package/build/lib/commands/time.js +9 -17
  160. package/build/lib/commands/time.js.map +1 -1
  161. package/build/lib/commands/types.d.ts +15 -1
  162. package/build/lib/commands/types.d.ts.map +1 -1
  163. package/build/lib/commands/types.js +1 -2
  164. package/build/lib/constraints.d.ts +3 -0
  165. package/build/lib/constraints.d.ts.map +1 -1
  166. package/build/lib/constraints.js +5 -5
  167. package/build/lib/constraints.js.map +1 -1
  168. package/build/lib/doctor/checks.js +54 -65
  169. package/build/lib/doctor/checks.js.map +1 -1
  170. package/build/lib/doctor/utils.js +4 -7
  171. package/build/lib/doctor/utils.js.map +1 -1
  172. package/build/lib/driver.d.ts +39 -39
  173. package/build/lib/driver.d.ts.map +1 -1
  174. package/build/lib/driver.js +220 -223
  175. package/build/lib/driver.js.map +1 -1
  176. package/build/lib/execute-method-map.js +1 -4
  177. package/build/lib/execute-method-map.js.map +1 -1
  178. package/build/lib/index.d.ts +7 -7
  179. package/build/lib/index.d.ts.map +1 -1
  180. package/build/lib/index.js +11 -51
  181. package/build/lib/index.js.map +1 -1
  182. package/build/lib/logger.js +2 -5
  183. package/build/lib/logger.js.map +1 -1
  184. package/build/lib/method-map.js +1 -4
  185. package/build/lib/method-map.js.map +1 -1
  186. package/build/lib/utils.d.ts +9 -7
  187. package/build/lib/utils.d.ts.map +1 -1
  188. package/build/lib/utils.js +22 -28
  189. package/build/lib/utils.js.map +1 -1
  190. package/lib/commands/app-management.ts +5 -11
  191. package/lib/commands/appearance.ts +1 -1
  192. package/lib/commands/bidi/models.ts +3 -3
  193. package/lib/commands/bluetooth.ts +2 -2
  194. package/lib/commands/context/cache.ts +1 -1
  195. package/lib/commands/context/exports.ts +7 -7
  196. package/lib/commands/context/helpers.ts +4 -4
  197. package/lib/commands/device/common.ts +36 -20
  198. package/lib/commands/device/emulator-actions.ts +4 -4
  199. package/lib/commands/device/emulator-console.ts +2 -2
  200. package/lib/commands/device/utils.ts +3 -3
  201. package/lib/commands/deviceidle.ts +2 -2
  202. package/lib/commands/element.ts +3 -3
  203. package/lib/commands/execute.ts +2 -2
  204. package/lib/commands/file-actions.ts +2 -2
  205. package/lib/commands/find.ts +4 -4
  206. package/lib/commands/geolocation.ts +2 -2
  207. package/lib/commands/gestures.ts +3 -3
  208. package/lib/commands/image-injection.ts +2 -2
  209. package/lib/commands/ime.ts +3 -3
  210. package/lib/commands/intent.ts +3 -3
  211. package/lib/commands/keyboard.ts +3 -3
  212. package/lib/commands/legacy.ts +2 -2
  213. package/lib/commands/lock/exports.ts +3 -3
  214. package/lib/commands/lock/helpers.ts +2 -2
  215. package/lib/commands/log.ts +18 -11
  216. package/lib/commands/media-projection.ts +2 -2
  217. package/lib/commands/memory.ts +3 -3
  218. package/lib/commands/misc.ts +3 -3
  219. package/lib/commands/network.ts +3 -3
  220. package/lib/commands/nfc.ts +3 -3
  221. package/lib/commands/performance.ts +4 -4
  222. package/lib/commands/permissions.ts +3 -3
  223. package/lib/commands/recordscreen.ts +5 -5
  224. package/lib/commands/resources.ts +2 -2
  225. package/lib/commands/shell.ts +3 -3
  226. package/lib/commands/streamscreen.ts +6 -4
  227. package/lib/commands/system-bars.ts +6 -6
  228. package/lib/commands/time.ts +3 -3
  229. package/lib/commands/types.ts +15 -1
  230. package/lib/constraints.ts +3 -0
  231. package/lib/doctor/checks.ts +1 -1
  232. package/lib/driver.ts +44 -44
  233. package/lib/index.ts +7 -7
  234. package/lib/method-map.ts +1 -1
  235. package/lib/utils.ts +10 -8
  236. package/package.json +12 -3
@@ -2,9 +2,9 @@ import {asyncmap} from 'asyncbox';
2
2
  import {fs, tempDir} from '@appium/support';
3
3
  import path from 'node:path';
4
4
  import type {Location} from '@appium/types';
5
+ import {getThirdPartyPackages} from './app-management.js';
6
+ import type {AndroidDriver} from '../driver.js';
5
7
  import {SETTINGS_HELPER_ID} from 'io.appium.settings';
6
- import {getThirdPartyPackages} from './app-management';
7
- import type {AndroidDriver} from '../driver';
8
8
 
9
9
  // The value close to zero, but not zero, is needed
10
10
  // to trick JSON generation and send a float value instead of an integer,
@@ -1,7 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
3
2
  import type {StringRecord} from '@appium/types';
4
- import type {AndroidDriver} from '../driver';
3
+ import type {AndroidDriver} from '../driver.js';
5
4
 
6
5
  /**
7
6
  * Performs a series of actions (gestures) on the device.
@@ -11,5 +10,6 @@ import type {AndroidDriver} from '../driver';
11
10
  * @throws {errors.NotImplementedError} This method is not implemented.
12
11
  */
13
12
  export async function performActions(this: AndroidDriver, actions: StringRecord[]): Promise<void> {
13
+ void actions;
14
14
  throw new errors.NotImplementedError('Not implemented');
15
15
  }
@@ -1,8 +1,8 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import path from 'node:path';
3
3
  import {fs, tempDir} from '@appium/support';
4
4
  import crypto from 'node:crypto';
5
- import type {AndroidDriver} from '../driver';
5
+ import type {AndroidDriver} from '../driver.js';
6
6
 
7
7
  const EMULATOR_RESOURCES_ROOT = ['emulator', 'resources'];
8
8
  const CONFIG_NAME = 'Toren1BD.posters';
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
3
- import {SET_STYLUS_HANDWRITING_FEATURE} from '../utils';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
+ import {SET_STYLUS_HANDWRITING_FEATURE} from '../utils.js';
4
4
 
5
5
  /**
6
6
  * Checks if an IME (Input Method Editor) is activated.
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {util} from '@appium/support';
3
- import type {AndroidDriver} from '../driver';
4
- import type {IntentOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {IntentOpts} from './types.js';
5
5
 
6
6
  const NO_VALUE_ARG_TYPE = 'sn';
7
7
  const SUPPORTED_EXTRA_TYPES = [
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {UNICODE_IME, EMPTY_IME} from 'io.appium.settings';
3
- import type {AndroidDriver} from '../driver';
4
- import type {SendKeysOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {SendKeysOpts} from './types.js';
5
5
 
6
6
  /**
7
7
  * Hides the on-screen keyboard.
@@ -1,5 +1,5 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
3
 
4
4
  const ISSUE_URL = 'https://github.com/appium/appium/issues/15807';
5
5
 
@@ -14,9 +14,9 @@ import {
14
14
  fingerprintUnlock,
15
15
  toCredentialType,
16
16
  verifyUnlock,
17
- } from './helpers';
18
- import type {AndroidDriver, AndroidDriverCaps} from '../../driver';
19
- import type {UnlockType} from '../types';
17
+ } from './helpers.js';
18
+ import type {AndroidDriver, AndroidDriverCaps} from '../../driver.js';
19
+ import type {UnlockType} from '../types.js';
20
20
 
21
21
  /**
22
22
  * Locks the device and optionally unlocks it after a specified number of seconds.
@@ -2,8 +2,8 @@ import {util} from '@appium/support';
2
2
  import {sleep, waitForCondition} from 'asyncbox';
3
3
  import type {ADB} from 'appium-adb';
4
4
  import type {Position, StringRecord} from '@appium/types';
5
- import type {AndroidDriver, AndroidDriverCaps} from '../../driver';
6
- import type {UnlockType, FastUnlockOptions} from '../types';
5
+ import type {AndroidDriver, AndroidDriverCaps} from '../../driver.js';
6
+ import type {UnlockType, FastUnlockOptions} from '../types.js';
7
7
 
8
8
  export const PIN_UNLOCK = 'pin';
9
9
  export const PIN_UNLOCK_KEY_EVENT = 'pinWithKeyEvent';
@@ -1,6 +1,6 @@
1
- import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver';
1
+ import {DEFAULT_WS_PATHNAME_PREFIX, BaseDriver} from 'appium/driver.js';
2
2
  import os from 'node:os';
3
- import WebSocket from 'ws';
3
+ import {WebSocket, WebSocketServer} from 'ws';
4
4
  import type {AppiumServer, WSServer} from '@appium/types';
5
5
  import type {EventEmitter} from 'node:events';
6
6
  import type {ADB} from 'appium-adb';
@@ -10,11 +10,11 @@ import {
10
10
  toLogRecord,
11
11
  nativeLogEntryToSeleniumEntry,
12
12
  type LogEntry,
13
- } from '../utils';
14
- import {NATIVE_WIN} from './context/helpers';
15
- import {BIDI_EVENT_NAME} from './bidi/constants';
16
- import {makeLogEntryAddedEvent} from './bidi/models';
17
- import type {AndroidDriver} from '../driver';
13
+ } from '../utils.js';
14
+ import {NATIVE_WIN} from './context/helpers.js';
15
+ import {BIDI_EVENT_NAME} from './bidi/constants.js';
16
+ import {makeLogEntryAddedEvent} from './bidi/models.js';
17
+ import type {AndroidDriver} from '../driver.js';
18
18
  import {util} from '@appium/support';
19
19
 
20
20
  export const supportedLogTypes = {
@@ -62,9 +62,12 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
62
62
  `${JSON.stringify(server.address())} to ${pathname}`,
63
63
  );
64
64
  // https://github.com/websockets/ws/blob/master/doc/ws.md
65
- const wss = new WebSocket.Server({
65
+ const wss = new WebSocketServer({
66
66
  noServer: true,
67
67
  });
68
+ // Tracks every currently connected listener socket so log lines get
69
+ // broadcast to all of them, not just the one that connected first.
70
+ const connectedSockets = new Set<WebSocket>();
68
71
  wss.on('connection', (ws, req) => {
69
72
  if (req) {
70
73
  const remoteIp = util.isEmpty(req.headers['x-forwarded-for'])
@@ -75,17 +78,21 @@ export async function mobileStartLogsBroadcast(this: AndroidDriver): Promise<voi
75
78
  this.log.debug('Established a new logcat listener web socket connection');
76
79
  }
77
80
 
81
+ connectedSockets.add(ws);
78
82
  if (!this._logcatWebsocketListener) {
79
83
  this._logcatWebsocketListener = (logRecord: LogEntry) => {
80
- if (ws?.readyState === WebSocket.OPEN) {
81
- ws.send(logRecord.message);
84
+ for (const socket of connectedSockets) {
85
+ if (socket.readyState === WebSocket.OPEN) {
86
+ socket.send(logRecord.message);
87
+ }
82
88
  }
83
89
  };
84
90
  }
85
91
  this.adb.setLogcatListener(this._logcatWebsocketListener);
86
92
 
87
93
  ws.on('close', (code, reason) => {
88
- if (this._logcatWebsocketListener) {
94
+ connectedSockets.delete(ws);
95
+ if (connectedSockets.size === 0 && this._logcatWebsocketListener) {
89
96
  try {
90
97
  this.adb.removeLogcatListener(this._logcatWebsocketListener);
91
98
  } catch {}
@@ -3,9 +3,9 @@ import type {NetOptions, HttpUploadOptions} from '@appium/support';
3
3
  import dayjs from 'dayjs';
4
4
  import path from 'node:path';
5
5
  import type {HTTPMethod, StringRecord} from '@appium/types';
6
- import type {AndroidDriver} from '../driver';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
  import type {ADB} from 'appium-adb';
8
- import type {FormFields} from './types';
8
+ import type {FormFields} from './types.js';
9
9
 
10
10
  // https://github.com/appium/io.appium.settings#internal-audio--video-recording
11
11
  const DEFAULT_EXT = '.mp4';
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
3
- import type {TrimMemoryLevel} from './types';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
+ import type {TrimMemoryLevel} from './types.js';
4
4
 
5
5
  /**
6
6
  * Simulates the onTrimMemory() event for the given package.
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import type {Size, Rect, StringRecord} from '@appium/types';
3
- import type {AndroidDriver} from '../driver';
4
- import type {SmsListResult, ListSmsOpts} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {SmsListResult, ListSmsOpts} from './types.js';
5
5
 
6
6
  /**
7
7
  * Gets the window size.
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import {util} from '@appium/support';
3
- import type {AndroidDriver} from '../driver';
4
- import type {ServiceType, GetConnectivityResult} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {ServiceType, GetConnectivityResult} from './types.js';
5
5
 
6
6
  const AIRPLANE_MODE_MASK = 0b001;
7
7
  const WIFI_MASK = 0b010;
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import type {AndroidDriver} from '../driver';
3
- import type {NfcAction} from './types';
1
+ import {errors} from 'appium/driver.js';
2
+ import type {AndroidDriver} from '../driver.js';
3
+ import type {NfcAction} from './types.js';
4
4
 
5
5
  const SUPPORTED_ACTIONS = {
6
6
  ENABLE: 'enable',
@@ -1,7 +1,7 @@
1
1
  import {retryInterval} from 'asyncbox';
2
2
  import type {ExecError} from 'teen_process';
3
- import type {AndroidDriver} from '../driver';
4
- import type {PerformanceDataType} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {PerformanceDataType} from './types.js';
5
5
  import {util} from '@appium/support';
6
6
 
7
7
  export const NETWORK_KEYS = [
@@ -187,7 +187,7 @@ export async function getMemoryInfo(
187
187
  }
188
188
  }
189
189
  if (valDict.totalPrivateDirty && valDict.totalPrivateDirty !== 'nodex') {
190
- const headers = structuredClone(MEMORY_KEYS);
190
+ const headers = [...MEMORY_KEYS];
191
191
  const values = headers.map((header) => valDict[header]);
192
192
  return [headers, values];
193
193
  }
@@ -458,7 +458,7 @@ export async function getBatteryInfo(this: AndroidDriver, retries: number = 2):
458
458
  const power = parseInt((data.split(':')[1] || '').trim(), 10);
459
459
 
460
460
  if (!Number.isNaN(power)) {
461
- return [structuredClone(BATTERY_KEYS), [power.toString()]];
461
+ return [[...BATTERY_KEYS], [power.toString()]];
462
462
  } else {
463
463
  throw new Error(`Unable to parse battery data: '${data}'`);
464
464
  }
@@ -1,6 +1,6 @@
1
- import {errors} from 'appium/driver';
2
- import {ADB_SHELL_FEATURE} from '../utils';
3
- import type {AndroidDriver} from '../driver';
1
+ import {errors} from 'appium/driver.js';
2
+ import {ADB_SHELL_FEATURE} from '../utils.js';
3
+ import type {AndroidDriver} from '../driver.js';
4
4
  import {util} from '@appium/support';
5
5
 
6
6
  const ALL_PERMISSIONS_MAGIC = 'all';
@@ -3,13 +3,13 @@ import type {NetOptions, HttpUploadOptions} from '@appium/support';
3
3
  import {waitForCondition} from 'asyncbox';
4
4
  import path from 'node:path';
5
5
  import {exec} from 'teen_process';
6
- import type {AndroidDriver} from '../driver';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
  import type {ADB} from 'appium-adb';
8
8
  import type {
9
9
  StartScreenRecordingOpts,
10
10
  StopScreenRecordingOpts,
11
11
  ScreenRecordingProperties,
12
- } from './types';
12
+ } from './types.js';
13
13
 
14
14
  const RETRY_PAUSE = 300;
15
15
  const RETRY_TIMEOUT = 5000;
@@ -65,7 +65,7 @@ export async function startRecordingScreen(
65
65
  if (this._screenRecordingProperties) {
66
66
  // XXX: this doesn't need to be done in serial, does it?
67
67
  const props = this._screenRecordingProperties;
68
- for (const record of props.records || []) {
68
+ for (const record of props?.records || []) {
69
69
  await this.adb.rimraf(record);
70
70
  }
71
71
  this._screenRecordingProperties = undefined;
@@ -136,7 +136,7 @@ export async function stopRecordingScreen(
136
136
  return '';
137
137
  }
138
138
 
139
- if (props.recordingProcess?.isRunning) {
139
+ if (props?.recordingProcess?.isRunning) {
140
140
  try {
141
141
  await props.recordingProcess.stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT);
142
142
  } catch {
@@ -157,7 +157,7 @@ export async function stopRecordingScreen(
157
157
  const tmpRoot = await tempDir.openDir();
158
158
  try {
159
159
  const localRecords: string[] = [];
160
- for (const pathOnDevice of props.records) {
160
+ for (const pathOnDevice of props?.records || []) {
161
161
  const relativePath = path.resolve(tmpRoot, path.posix.basename(pathOnDevice));
162
162
  localRecords.push(relativePath);
163
163
  await this.adb.pull(pathOnDevice, relativePath, {timeout: ADB_PULL_TIMEOUT});
@@ -1,7 +1,7 @@
1
1
  import {fs, tempDir, util} from '@appium/support';
2
2
  import type {StringRecord} from '@appium/types';
3
- import type {AndroidDriver, AndroidDriverOpts} from '../driver';
4
- import type {Locale} from './types';
3
+ import type {AndroidDriver, AndroidDriverOpts} from '../driver.js';
4
+ import type {Locale} from './types.js';
5
5
 
6
6
  /**
7
7
  * Gets the localized strings from the application.
@@ -1,9 +1,9 @@
1
1
  import {util} from '@appium/support';
2
- import {errors} from 'appium/driver';
2
+ import {errors} from 'appium/driver.js';
3
3
  import {exec} from 'teen_process';
4
4
  import type {ExecError} from 'teen_process';
5
- import {ADB_SHELL_FEATURE} from '../utils';
6
- import type {AndroidDriver} from '../driver';
5
+ import {ADB_SHELL_FEATURE} from '../utils.js';
6
+ import type {AndroidDriver} from '../driver.js';
7
7
 
8
8
  /**
9
9
  * Executes a shell command on the device via ADB.
@@ -6,10 +6,10 @@ import net from 'node:net';
6
6
  import url from 'node:url';
7
7
  import {checkPortStatus} from 'portscanner';
8
8
  import {SubProcess, exec} from 'teen_process';
9
- import type {AndroidDriver} from '../driver';
9
+ import type {AndroidDriver} from '../driver.js';
10
10
  import type {ADB} from 'appium-adb';
11
11
  import type {AppiumLogger} from '@appium/types';
12
- import type {DeviceInfo, InitGStreamerPipelineOpts} from './types';
12
+ import type {DeviceInfo, InitGStreamerPipelineOpts} from './types.js';
13
13
 
14
14
  const RECORDING_INTERVAL_SEC = 5;
15
15
  const STREAMING_STARTUP_TIMEOUT_MS = 5000;
@@ -225,11 +225,13 @@ export async function mobileStartScreenStreaming(
225
225
  }
226
226
  }
227
227
 
228
+ // Both are guaranteed to be set at this point, since mjpegServerReadyPromise
229
+ // only resolves after the MJPEG server has started listening.
228
230
  this._screenStreamingProps = {
229
231
  deviceStreamingProc,
230
232
  gstreamerPipeline,
231
- mjpegSocket,
232
- mjpegServer,
233
+ mjpegSocket: mjpegSocket as net.Socket,
234
+ mjpegServer: mjpegServer as http.Server,
233
235
  };
234
236
  }
235
237
 
@@ -1,7 +1,7 @@
1
- import {errors} from 'appium/driver';
1
+ import {errors} from 'appium/driver.js';
2
2
  import type {StringRecord} from '@appium/types';
3
- import type {AndroidDriver} from '../driver';
4
- import type {StatusBarCommand, WindowProperties} from './types';
3
+ import type {AndroidDriver} from '../driver.js';
4
+ import type {StatusBarCommand, WindowProperties} from './types.js';
5
5
  import {util} from '@appium/support';
6
6
 
7
7
  const WINDOW_TITLE_PATTERN = /^\s+Window\s#\d+\sWindow\{[0-9a-f]+\s\w+\s([\w-]+)\}:$/;
@@ -142,14 +142,14 @@ export function parseWindowProperties(
142
142
  export function parseWindows(this: AndroidDriver, lines: string): SystemBarsResult {
143
143
  const windows: StringRecord<string[]> = {};
144
144
  let currentWindowName: string | null = null;
145
- for (const line of lines.split('\n').map((line) => String(line)?.trimEnd())) {
146
- const match = WINDOW_TITLE_PATTERN.exec(line as any);
145
+ for (const line of lines.split('\n').map((line) => line.trimEnd())) {
146
+ const match = WINDOW_TITLE_PATTERN.exec(line);
147
147
  if (match) {
148
148
  currentWindowName = match[1];
149
149
  windows[currentWindowName] = [];
150
150
  continue;
151
151
  }
152
- if (String(line)?.trim()?.length === 0) {
152
+ if (line.trim().length === 0) {
153
153
  currentWindowName = null;
154
154
  continue;
155
155
  }
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
- import utc from 'dayjs/plugin/utc';
3
- import customParseFormat from 'dayjs/plugin/customParseFormat';
4
- import type {AndroidDriver} from '../driver';
2
+ import utc from 'dayjs/plugin/utc.js';
3
+ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
4
+ import type {AndroidDriver} from '../driver.js';
5
5
 
6
6
  dayjs.extend(utc);
7
7
  dayjs.extend(customParseFormat);
@@ -1,7 +1,10 @@
1
1
  import type {HTTPMethod, StringRecord} from '@appium/types';
2
- import type {AndroidDriverCaps} from '../driver';
2
+ import type {AndroidDriverCaps} from '../driver.js';
3
3
  import type {SubProcess} from 'teen_process';
4
4
  import type {timing} from '@appium/support';
5
+ import type {ChildProcess} from 'node:child_process';
6
+ import type {Socket} from 'node:net';
7
+ import type {Server} from 'node:http';
5
8
 
6
9
  /**
7
10
  * @privateRemarks probably better defined in `appium-adb`
@@ -451,6 +454,17 @@ export interface InitGStreamerPipelineOpts {
451
454
  considerRotation?: boolean;
452
455
  logPipelineDetails?: boolean;
453
456
  }
457
+
458
+ /**
459
+ * The screen streaming process handles cached on the driver instance
460
+ * while a `mobile: startScreenStreaming` session is active.
461
+ */
462
+ export interface ScreenStreamingProps {
463
+ deviceStreamingProc: ChildProcess;
464
+ gstreamerPipeline: SubProcess;
465
+ mjpegSocket: Socket;
466
+ mjpegServer: Server;
467
+ }
454
468
  export interface WindowProperties {
455
469
  /**
456
470
  * Whether the window is visible
@@ -212,6 +212,9 @@ export const ANDROID_DRIVER_CONSTRAINTS = {
212
212
  skipDeviceInitialization: {
213
213
  isBoolean: true,
214
214
  },
215
+ skipSettingsAppReinstall: {
216
+ isBoolean: true,
217
+ },
215
218
  remoteAppsCacheLimit: {
216
219
  isNumber: true,
217
220
  },
@@ -1,4 +1,4 @@
1
- import {resolveExecutablePath} from './utils';
1
+ import {resolveExecutablePath} from './utils.js';
2
2
  import {system, fs, doctor, console} from '@appium/support';
3
3
  import path from 'node:path';
4
4
  import {getAndroidBinaryPath, getSdkRootFromEnv} from 'appium-adb';