appium-android-driver 7.8.3 → 8.0.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 (261) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/lib/commands/app-management.d.ts +129 -5
  3. package/build/lib/commands/app-management.d.ts.map +1 -1
  4. package/build/lib/commands/app-management.js +433 -128
  5. package/build/lib/commands/app-management.js.map +1 -1
  6. package/build/lib/commands/appearance.d.ts +17 -4
  7. package/build/lib/commands/appearance.d.ts.map +1 -1
  8. package/build/lib/commands/appearance.js +32 -33
  9. package/build/lib/commands/appearance.js.map +1 -1
  10. package/build/lib/commands/context/cache.d.ts +19 -0
  11. package/build/lib/commands/context/cache.d.ts.map +1 -0
  12. package/build/lib/commands/context/cache.js +32 -0
  13. package/build/lib/commands/context/cache.js.map +1 -0
  14. package/build/lib/commands/context/exports.d.ts +141 -0
  15. package/build/lib/commands/context/exports.d.ts.map +1 -0
  16. package/build/lib/commands/context/exports.js +351 -0
  17. package/build/lib/commands/context/exports.js.map +1 -0
  18. package/build/lib/commands/context/helpers.d.ts +98 -0
  19. package/build/lib/commands/context/helpers.d.ts.map +1 -0
  20. package/build/lib/commands/context/helpers.js +715 -0
  21. package/build/lib/commands/context/helpers.js.map +1 -0
  22. package/build/lib/commands/device/common.d.ts +23 -0
  23. package/build/lib/commands/device/common.d.ts.map +1 -0
  24. package/build/lib/commands/device/common.js +230 -0
  25. package/build/lib/commands/device/common.js.map +1 -0
  26. package/build/lib/commands/device/emulator-actions.d.ts +114 -0
  27. package/build/lib/commands/device/emulator-actions.d.ts.map +1 -0
  28. package/build/lib/commands/device/emulator-actions.js +197 -0
  29. package/build/lib/commands/device/emulator-actions.js.map +1 -0
  30. package/build/lib/commands/device/emulator-console.d.ts +7 -0
  31. package/build/lib/commands/device/emulator-console.d.ts.map +1 -0
  32. package/build/lib/commands/device/emulator-console.js +24 -0
  33. package/build/lib/commands/device/emulator-console.js.map +1 -0
  34. package/build/lib/commands/device/utils.d.ts +50 -0
  35. package/build/lib/commands/device/utils.d.ts.map +1 -0
  36. package/build/lib/commands/device/utils.js +238 -0
  37. package/build/lib/commands/device/utils.js.map +1 -0
  38. package/build/lib/commands/deviceidle.d.ts +8 -5
  39. package/build/lib/commands/deviceidle.d.ts.map +1 -1
  40. package/build/lib/commands/deviceidle.js +31 -37
  41. package/build/lib/commands/deviceidle.js.map +1 -1
  42. package/build/lib/commands/element.d.ts +99 -5
  43. package/build/lib/commands/element.d.ts.map +1 -1
  44. package/build/lib/commands/element.js +152 -116
  45. package/build/lib/commands/element.js.map +1 -1
  46. package/build/lib/commands/execute.d.ts +12 -4
  47. package/build/lib/commands/execute.d.ts.map +1 -1
  48. package/build/lib/commands/execute.js +83 -78
  49. package/build/lib/commands/execute.js.map +1 -1
  50. package/build/lib/commands/file-actions.d.ts +42 -5
  51. package/build/lib/commands/file-actions.d.ts.map +1 -1
  52. package/build/lib/commands/file-actions.js +230 -194
  53. package/build/lib/commands/file-actions.js.map +1 -1
  54. package/build/lib/commands/find.d.ts +5 -4
  55. package/build/lib/commands/find.d.ts.map +1 -1
  56. package/build/lib/commands/find.js +7 -10
  57. package/build/lib/commands/find.js.map +1 -1
  58. package/build/lib/commands/geolocation.d.ts +45 -0
  59. package/build/lib/commands/geolocation.d.ts.map +1 -0
  60. package/build/lib/commands/geolocation.js +182 -0
  61. package/build/lib/commands/geolocation.js.map +1 -0
  62. package/build/lib/commands/ime.d.ts +25 -5
  63. package/build/lib/commands/ime.d.ts.map +1 -1
  64. package/build/lib/commands/ime.js +59 -42
  65. package/build/lib/commands/ime.js.map +1 -1
  66. package/build/lib/commands/intent.d.ts +56 -5
  67. package/build/lib/commands/intent.d.ts.map +1 -1
  68. package/build/lib/commands/intent.js +135 -83
  69. package/build/lib/commands/intent.js.map +1 -1
  70. package/build/lib/commands/keyboard.d.ts +58 -4
  71. package/build/lib/commands/keyboard.d.ts.map +1 -1
  72. package/build/lib/commands/keyboard.js +119 -17
  73. package/build/lib/commands/keyboard.js.map +1 -1
  74. package/build/lib/commands/lock/exports.d.ts +301 -0
  75. package/build/lib/commands/lock/exports.d.ts.map +1 -0
  76. package/build/lib/commands/lock/exports.js +121 -0
  77. package/build/lib/commands/lock/exports.js.map +1 -0
  78. package/build/lib/commands/lock/helpers.d.ts +349 -0
  79. package/build/lib/commands/lock/helpers.d.ts.map +1 -0
  80. package/build/lib/commands/lock/helpers.js +375 -0
  81. package/build/lib/commands/lock/helpers.js.map +1 -0
  82. package/build/lib/commands/log.d.ts +59 -5
  83. package/build/lib/commands/log.d.ts.map +1 -1
  84. package/build/lib/commands/log.js +150 -140
  85. package/build/lib/commands/log.js.map +1 -1
  86. package/build/lib/commands/media-projection.d.ts +16 -5
  87. package/build/lib/commands/media-projection.d.ts.map +1 -1
  88. package/build/lib/commands/media-projection.js +69 -58
  89. package/build/lib/commands/media-projection.js.map +1 -1
  90. package/build/lib/commands/memory.d.ts +9 -5
  91. package/build/lib/commands/memory.d.ts.map +1 -1
  92. package/build/lib/commands/memory.js +19 -24
  93. package/build/lib/commands/memory.js.map +1 -1
  94. package/build/lib/commands/misc.d.ts +42 -0
  95. package/build/lib/commands/misc.d.ts.map +1 -0
  96. package/build/lib/commands/misc.js +100 -0
  97. package/build/lib/commands/misc.js.map +1 -0
  98. package/build/lib/commands/network.d.ts +61 -5
  99. package/build/lib/commands/network.d.ts.map +1 -1
  100. package/build/lib/commands/network.js +196 -189
  101. package/build/lib/commands/network.js.map +1 -1
  102. package/build/lib/commands/performance.d.ts +67 -27
  103. package/build/lib/commands/performance.d.ts.map +1 -1
  104. package/build/lib/commands/performance.js +105 -80
  105. package/build/lib/commands/performance.js.map +1 -1
  106. package/build/lib/commands/permissions.d.ts +12 -6
  107. package/build/lib/commands/permissions.d.ts.map +1 -1
  108. package/build/lib/commands/permissions.js +65 -62
  109. package/build/lib/commands/permissions.js.map +1 -1
  110. package/build/lib/commands/recordscreen.d.ts +44 -5
  111. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  112. package/build/lib/commands/recordscreen.js +131 -126
  113. package/build/lib/commands/recordscreen.js.map +1 -1
  114. package/build/lib/commands/resources.d.ts +16 -0
  115. package/build/lib/commands/resources.d.ts.map +1 -0
  116. package/build/lib/commands/resources.js +91 -0
  117. package/build/lib/commands/resources.js.map +1 -0
  118. package/build/lib/commands/shell.d.ts +8 -5
  119. package/build/lib/commands/shell.d.ts.map +1 -1
  120. package/build/lib/commands/shell.js +29 -33
  121. package/build/lib/commands/shell.js.map +1 -1
  122. package/build/lib/commands/streamscreen.d.ts +34 -6
  123. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  124. package/build/lib/commands/streamscreen.js +166 -162
  125. package/build/lib/commands/streamscreen.js.map +1 -1
  126. package/build/lib/commands/system-bars.d.ts +18 -13
  127. package/build/lib/commands/system-bars.d.ts.map +1 -1
  128. package/build/lib/commands/system-bars.js +68 -64
  129. package/build/lib/commands/system-bars.js.map +1 -1
  130. package/build/lib/commands/time.d.ts +14 -0
  131. package/build/lib/commands/time.d.ts.map +1 -0
  132. package/build/lib/commands/time.js +39 -0
  133. package/build/lib/commands/time.js.map +1 -0
  134. package/build/lib/commands/touch.d.ts +99 -6
  135. package/build/lib/commands/touch.d.ts.map +1 -1
  136. package/build/lib/commands/touch.js +399 -280
  137. package/build/lib/commands/touch.js.map +1 -1
  138. package/build/lib/commands/types.d.ts +110 -2
  139. package/build/lib/commands/types.d.ts.map +1 -1
  140. package/build/lib/doctor/checks.d.ts.map +1 -1
  141. package/build/lib/doctor/checks.js +4 -4
  142. package/build/lib/doctor/checks.js.map +1 -1
  143. package/build/lib/driver.d.ts +224 -27
  144. package/build/lib/driver.d.ts.map +1 -1
  145. package/build/lib/driver.js +232 -7
  146. package/build/lib/driver.js.map +1 -1
  147. package/build/lib/index.d.ts +1 -4
  148. package/build/lib/index.d.ts.map +1 -1
  149. package/build/lib/index.js +1 -13
  150. package/build/lib/index.js.map +1 -1
  151. package/build/lib/logger.js.map +1 -1
  152. package/build/lib/method-map.d.ts +0 -23
  153. package/build/lib/method-map.d.ts.map +1 -1
  154. package/build/lib/method-map.js +0 -11
  155. package/build/lib/method-map.js.map +1 -1
  156. package/build/lib/utils.d.ts +12 -0
  157. package/build/lib/utils.d.ts.map +1 -1
  158. package/build/lib/utils.js +38 -2
  159. package/build/lib/utils.js.map +1 -1
  160. package/lib/commands/app-management.js +470 -145
  161. package/lib/commands/appearance.js +29 -36
  162. package/lib/commands/context/cache.js +29 -0
  163. package/lib/commands/context/exports.js +379 -0
  164. package/lib/commands/context/helpers.js +802 -0
  165. package/lib/commands/device/common.js +264 -0
  166. package/lib/commands/device/emulator-actions.js +194 -0
  167. package/lib/commands/device/emulator-console.js +24 -0
  168. package/lib/commands/device/utils.js +285 -0
  169. package/lib/commands/deviceidle.js +31 -44
  170. package/lib/commands/element.js +149 -142
  171. package/lib/commands/execute.js +86 -87
  172. package/lib/commands/file-actions.js +249 -222
  173. package/lib/commands/find.ts +13 -19
  174. package/lib/commands/geolocation.js +179 -0
  175. package/lib/commands/ime.js +53 -45
  176. package/lib/commands/intent.js +149 -91
  177. package/lib/commands/keyboard.js +114 -17
  178. package/lib/commands/lock/exports.js +139 -0
  179. package/lib/commands/lock/helpers.js +379 -0
  180. package/lib/commands/log.js +170 -166
  181. package/lib/commands/media-projection.js +75 -70
  182. package/lib/commands/memory.js +17 -29
  183. package/lib/commands/misc.js +94 -0
  184. package/lib/commands/network.js +209 -223
  185. package/lib/commands/performance.js +88 -73
  186. package/lib/commands/permissions.js +83 -84
  187. package/lib/commands/recordscreen.js +171 -170
  188. package/lib/commands/resources.js +96 -0
  189. package/lib/commands/shell.js +28 -42
  190. package/lib/commands/streamscreen.js +207 -206
  191. package/lib/commands/system-bars.js +76 -77
  192. package/lib/commands/time.js +36 -0
  193. package/lib/commands/touch.js +442 -346
  194. package/lib/commands/types.ts +123 -2
  195. package/lib/doctor/checks.js +24 -16
  196. package/lib/driver.ts +454 -12
  197. package/lib/index.ts +1 -13
  198. package/lib/logger.js +1 -1
  199. package/lib/method-map.js +0 -11
  200. package/lib/utils.js +40 -3
  201. package/package.json +2 -2
  202. package/build/lib/commands/actions.d.ts +0 -8
  203. package/build/lib/commands/actions.d.ts.map +0 -1
  204. package/build/lib/commands/actions.js +0 -207
  205. package/build/lib/commands/actions.js.map +0 -1
  206. package/build/lib/commands/alert.d.ts +0 -8
  207. package/build/lib/commands/alert.d.ts.map +0 -1
  208. package/build/lib/commands/alert.js +0 -29
  209. package/build/lib/commands/alert.js.map +0 -1
  210. package/build/lib/commands/context.d.ts +0 -10
  211. package/build/lib/commands/context.d.ts.map +0 -1
  212. package/build/lib/commands/context.js +0 -431
  213. package/build/lib/commands/context.js.map +0 -1
  214. package/build/lib/commands/emu-console.d.ts +0 -7
  215. package/build/lib/commands/emu-console.d.ts.map +0 -1
  216. package/build/lib/commands/emu-console.js +0 -27
  217. package/build/lib/commands/emu-console.js.map +0 -1
  218. package/build/lib/commands/general.d.ts +0 -9
  219. package/build/lib/commands/general.d.ts.map +0 -1
  220. package/build/lib/commands/general.js +0 -293
  221. package/build/lib/commands/general.js.map +0 -1
  222. package/build/lib/commands/index.d.ts +0 -28
  223. package/build/lib/commands/index.d.ts.map +0 -1
  224. package/build/lib/commands/index.js +0 -57
  225. package/build/lib/commands/index.js.map +0 -1
  226. package/build/lib/commands/mixins.d.ts +0 -747
  227. package/build/lib/commands/mixins.d.ts.map +0 -1
  228. package/build/lib/commands/mixins.js +0 -19
  229. package/build/lib/commands/mixins.js.map +0 -1
  230. package/build/lib/helpers/android.d.ts +0 -163
  231. package/build/lib/helpers/android.d.ts.map +0 -1
  232. package/build/lib/helpers/android.js +0 -818
  233. package/build/lib/helpers/android.js.map +0 -1
  234. package/build/lib/helpers/index.d.ts +0 -7
  235. package/build/lib/helpers/index.d.ts.map +0 -1
  236. package/build/lib/helpers/index.js +0 -29
  237. package/build/lib/helpers/index.js.map +0 -1
  238. package/build/lib/helpers/types.d.ts +0 -122
  239. package/build/lib/helpers/types.d.ts.map +0 -1
  240. package/build/lib/helpers/types.js +0 -3
  241. package/build/lib/helpers/types.js.map +0 -1
  242. package/build/lib/helpers/unlock.d.ts +0 -32
  243. package/build/lib/helpers/unlock.d.ts.map +0 -1
  244. package/build/lib/helpers/unlock.js +0 -273
  245. package/build/lib/helpers/unlock.js.map +0 -1
  246. package/build/lib/helpers/webview.d.ts +0 -74
  247. package/build/lib/helpers/webview.d.ts.map +0 -1
  248. package/build/lib/helpers/webview.js +0 -448
  249. package/build/lib/helpers/webview.js.map +0 -1
  250. package/lib/commands/actions.js +0 -244
  251. package/lib/commands/alert.js +0 -34
  252. package/lib/commands/context.js +0 -507
  253. package/lib/commands/emu-console.js +0 -31
  254. package/lib/commands/general.js +0 -343
  255. package/lib/commands/index.ts +0 -54
  256. package/lib/commands/mixins.ts +0 -976
  257. package/lib/helpers/android.ts +0 -1153
  258. package/lib/helpers/index.ts +0 -6
  259. package/lib/helpers/types.ts +0 -136
  260. package/lib/helpers/unlock.ts +0 -329
  261. package/lib/helpers/webview.ts +0 -610
package/lib/driver.ts CHANGED
@@ -11,17 +11,205 @@ import type {
11
11
  } from '@appium/types';
12
12
  import _ from 'lodash';
13
13
  import ADB from 'appium-adb';
14
+ import type {LogcatListener} from 'appium-adb';
14
15
  import type {default as AppiumChromedriver} from 'appium-chromedriver';
15
16
  import {BaseDriver} from 'appium/driver';
16
17
  import ANDROID_DRIVER_CONSTRAINTS, {AndroidDriverConstraints} from './constraints';
17
- import {helpers} from './helpers';
18
18
  import {newMethodMap} from './method-map';
19
- import { SettingsApp } from 'io.appium.settings';
19
+ import {SettingsApp} from 'io.appium.settings';
20
+ import {parseArray, removeAllSessionWebSocketHandlers} from './utils';
21
+ import {CHROME_BROWSER_PACKAGE_ACTIVITY} from './commands/context/helpers';
22
+ import {
23
+ getContexts,
24
+ setContext,
25
+ getCurrentContext,
26
+ defaultContextName,
27
+ assignContexts,
28
+ switchContext,
29
+ defaultWebviewName,
30
+ isWebContext,
31
+ isChromedriverContext,
32
+ startChromedriverProxy,
33
+ onChromedriverStop,
34
+ stopChromedriverProxies,
35
+ suspendChromedriverProxy,
36
+ startChromeSession,
37
+ mobileGetContexts,
38
+ } from './commands/context/exports';
39
+ import {
40
+ getDeviceInfoFromCaps,
41
+ createADB,
42
+ getLaunchInfo,
43
+ initDevice,
44
+ } from './commands/device/common';
45
+ import {
46
+ fingerprint,
47
+ mobileFingerprint,
48
+ sendSMS,
49
+ mobileSendSms,
50
+ gsmCall,
51
+ mobileGsmCall,
52
+ gsmSignal,
53
+ mobileGsmSignal,
54
+ gsmVoice,
55
+ mobileGsmVoice,
56
+ powerAC,
57
+ mobilePowerAc,
58
+ powerCapacity,
59
+ mobilePowerCapacity,
60
+ networkSpeed,
61
+ mobileNetworkSpeed,
62
+ sensorSet,
63
+ } from './commands/device/emulator-actions';
64
+ import {mobileExecEmuConsoleCommand} from './commands/device/emulator-console';
65
+ import {
66
+ getThirdPartyPackages,
67
+ uninstallOtherPackages,
68
+ installOtherApks,
69
+ installApk,
70
+ resetApp,
71
+ background,
72
+ getCurrentActivity,
73
+ getCurrentPackage,
74
+ mobileClearApp,
75
+ mobileInstallApp,
76
+ installApp,
77
+ mobileActivateApp,
78
+ mobileIsAppInstalled,
79
+ mobileQueryAppState,
80
+ mobileRemoveApp,
81
+ mobileTerminateApp,
82
+ terminateApp,
83
+ removeApp,
84
+ activateApp,
85
+ queryAppState,
86
+ isAppInstalled,
87
+ } from './commands/app-management';
88
+ import {mobileGetUiMode, mobileSetUiMode} from './commands/appearance';
89
+ import {mobileDeviceidle} from './commands/deviceidle';
90
+ import {
91
+ getAttribute,
92
+ getName,
93
+ elementDisplayed,
94
+ elementEnabled,
95
+ elementSelected,
96
+ setElementValue,
97
+ doSetElementValue,
98
+ replaceValue,
99
+ setValueImmediate,
100
+ click,
101
+ getLocationInView,
102
+ getText,
103
+ getLocation,
104
+ getSize,
105
+ } from './commands/element';
106
+ import {execute, executeMobile} from './commands/execute';
107
+ import {
108
+ pullFile,
109
+ mobilePullFile,
110
+ pullFolder,
111
+ mobilePullFolder,
112
+ pushFile,
113
+ mobilePushFile,
114
+ mobileDeleteFile,
115
+ } from './commands/file-actions';
116
+ import {findElOrEls, doFindElementOrEls} from './commands/find';
117
+ import {
118
+ setGeoLocation,
119
+ getGeoLocation,
120
+ mobileRefreshGpsCache,
121
+ toggleLocationServices,
122
+ isLocationServicesEnabled,
123
+ } from './commands/geolocation';
124
+ import {
125
+ isIMEActivated,
126
+ availableIMEEngines,
127
+ getActiveIMEEngine,
128
+ activateIMEEngine,
129
+ deactivateIMEEngine,
130
+ } from './commands/ime';
131
+ import {
132
+ startActivity,
133
+ mobileBroadcast,
134
+ mobileStartService,
135
+ mobileStopService,
136
+ } from './commands/intent';
137
+ import {
138
+ hideKeyboard,
139
+ isKeyboardShown,
140
+ keys,
141
+ doSendKeys,
142
+ pressKeyCode,
143
+ longPressKeyCode,
144
+ mobilePerformEditorAction,
145
+ } from './commands/keyboard';
146
+ import {lock, unlock, mobileLock, mobileUnlock, isLocked} from './commands/lock/exports';
147
+ import {
148
+ supportedLogTypes,
149
+ mobileStartLogsBroadcast,
150
+ mobileStopLogsBroadcast,
151
+ getLogTypes,
152
+ getLog,
153
+ } from './commands/log';
154
+ import {
155
+ mobileIsMediaProjectionRecordingRunning,
156
+ mobileStartMediaProjectionRecording,
157
+ mobileStopMediaProjectionRecording,
158
+ } from './commands/media-projection';
159
+ import {mobileSendTrimMemory} from './commands/memory';
160
+ import {
161
+ getWindowRect,
162
+ getWindowSize,
163
+ getDisplayDensity,
164
+ mobileGetNotifications,
165
+ mobileListSms,
166
+ openNotifications,
167
+ setUrl,
168
+ } from './commands/misc';
169
+ import {
170
+ getNetworkConnection,
171
+ isWifiOn,
172
+ mobileGetConnectivity,
173
+ mobileSetConnectivity,
174
+ setNetworkConnection,
175
+ setWifiState,
176
+ setDataState,
177
+ toggleData,
178
+ toggleFlightMode,
179
+ toggleWiFi,
180
+ } from './commands/network';
181
+ import {
182
+ getPerformanceData,
183
+ getPerformanceDataTypes,
184
+ mobileGetPerformanceData,
185
+ } from './commands/performance';
186
+ import {mobileChangePermissions, mobileGetPermissions} from './commands/permissions';
187
+ import {startRecordingScreen, stopRecordingScreen} from './commands/recordscreen';
188
+ import {getStrings, ensureDeviceLocale} from './commands/resources';
189
+ import {mobileShell} from './commands/shell';
190
+ import {mobileStartScreenStreaming, mobileStopScreenStreaming} from './commands/streamscreen';
191
+ import {getSystemBars, mobilePerformStatusBarCommand} from './commands/system-bars';
192
+ import {getDeviceTime, mobileGetDeviceTime} from './commands/time';
193
+ import {
194
+ tap,
195
+ touchLongClick,
196
+ touchDown,
197
+ touchUp,
198
+ touchMove,
199
+ doSwipe,
200
+ doTouchDrag,
201
+ doTouchAction,
202
+ performMultiAction,
203
+ performTouch,
204
+ doPerformMultiAction,
205
+ } from './commands/touch';
20
206
 
21
207
  export type AndroidDriverCaps = DriverCaps<AndroidDriverConstraints>;
22
208
  export type W3CAndroidDriverCaps = W3CDriverCaps<AndroidDriverConstraints>;
23
209
  export type AndroidDriverOpts = DriverOpts<AndroidDriverConstraints>;
24
210
 
211
+ const EMULATOR_PATTERN = /\bemulator\b/i;
212
+
25
213
  type AndroidExternalDriver = ExternalDriver<AndroidDriverConstraints>;
26
214
  class AndroidDriver
27
215
  extends BaseDriver<AndroidDriverConstraints, StringRecord>
@@ -34,9 +222,7 @@ class AndroidDriver
34
222
 
35
223
  _settingsApp: SettingsApp;
36
224
 
37
- unlocker: typeof helpers.unlocker;
38
-
39
- apkStrings: StringRecord<StringRecord<string>>;
225
+ apkStrings: StringRecord;
40
226
 
41
227
  proxyReqRes?: (...args: any) => any;
42
228
 
@@ -56,6 +242,14 @@ class AndroidDriver
56
242
 
57
243
  _wasWindowAnimationDisabled?: boolean;
58
244
 
245
+ _cachedActivityArgs: StringRecord;
246
+
247
+ _screenStreamingProps?: StringRecord;
248
+
249
+ _screenRecordingProperties?: StringRecord;
250
+
251
+ _logcatWebsocketListener?: LogcatListener;
252
+
59
253
  opts: AndroidDriverOpts;
60
254
 
61
255
  constructor(opts: InitialOpts = {} as InitialOpts, shouldValidateCaps = true) {
@@ -72,27 +266,275 @@ class AndroidDriver
72
266
  this.sessionChromedrivers = {};
73
267
  this.jwpProxyActive = false;
74
268
  this.apkStrings = {};
75
- this.unlocker = helpers.unlocker;
76
269
 
77
270
  this.curContext = this.defaultContextName();
78
271
  this.opts = opts as AndroidDriverOpts;
272
+ this._cachedActivityArgs = {};
79
273
  }
80
274
 
81
- get settingsApp() {
275
+ get settingsApp(): SettingsApp {
82
276
  if (!this._settingsApp) {
83
277
  this._settingsApp = new SettingsApp({adb: this.adb});
84
278
  }
85
279
  return this._settingsApp;
86
280
  }
87
281
 
88
- isEmulator() {
89
- return helpers.isEmulator(this.adb, this.opts);
282
+ isEmulator(): boolean {
283
+ const possibleNames = [this.opts?.udid, this.adb?.curDeviceId];
284
+ return !!this.opts?.avd || possibleNames.some((x) => EMULATOR_PATTERN.test(String(x)));
285
+ }
286
+
287
+ get isChromeSession(): boolean {
288
+ return _.includes(
289
+ Object.keys(CHROME_BROWSER_PACKAGE_ACTIVITY),
290
+ (this.opts.browserName || '').toLowerCase(),
291
+ );
292
+ }
293
+
294
+ override validateDesiredCaps(caps: any): caps is AndroidDriverCaps {
295
+ if (!super.validateDesiredCaps(caps)) {
296
+ return false;
297
+ }
298
+
299
+ if (caps.browserName) {
300
+ if (caps.app) {
301
+ // warn if the capabilities have both `app` and `browser, although this is common with selenium grid
302
+ this.log.warn(
303
+ `The desired capabilities should generally not include both an 'app' and a 'browserName'`,
304
+ );
305
+ }
306
+ if (caps.appPackage) {
307
+ throw this.log.errorAndThrow(
308
+ `The desired should not include both of an 'appPackage' and a 'browserName'`,
309
+ );
310
+ }
311
+ }
312
+
313
+ if (caps.uninstallOtherPackages) {
314
+ try {
315
+ parseArray(caps.uninstallOtherPackages);
316
+ } catch (e) {
317
+ throw this.log.errorAndThrow(
318
+ `Could not parse "uninstallOtherPackages" capability: ${(e as Error).message}`,
319
+ );
320
+ }
321
+ }
322
+
323
+ return true;
90
324
  }
91
325
 
92
- get isChromeSession() {
93
- return helpers.isChromeBrowser(String(this.opts.browserName));
326
+ override async deleteSession(sessionId?: string | null) {
327
+ if (this.server) {
328
+ await removeAllSessionWebSocketHandlers(this.server, sessionId);
329
+ }
330
+
331
+ await super.deleteSession(sessionId);
94
332
  }
333
+
334
+ getContexts = getContexts;
335
+ getCurrentContext = getCurrentContext;
336
+ defaultContextName = defaultContextName;
337
+ assignContexts = assignContexts;
338
+ switchContext = switchContext;
339
+ defaultWebviewName = defaultWebviewName;
340
+ isChromedriverContext = isChromedriverContext;
341
+ startChromedriverProxy = startChromedriverProxy;
342
+ stopChromedriverProxies = stopChromedriverProxies;
343
+ suspendChromedriverProxy = suspendChromedriverProxy;
344
+ startChromeSession = startChromeSession;
345
+ onChromedriverStop = onChromedriverStop;
346
+ isWebContext = isWebContext;
347
+ mobileGetContexts = mobileGetContexts;
348
+ setContext = setContext as any as (this: AndroidDriver, name?: string) => Promise<void>;
349
+
350
+ getDeviceInfoFromCaps = getDeviceInfoFromCaps;
351
+ createADB = createADB;
352
+ getLaunchInfo = getLaunchInfo;
353
+ initDevice = initDevice;
354
+
355
+ fingerprint = fingerprint;
356
+ mobileFingerprint = mobileFingerprint;
357
+ sendSMS = sendSMS;
358
+ mobileSendSms = mobileSendSms;
359
+ gsmCall = gsmCall;
360
+ mobileGsmCall = mobileGsmCall;
361
+ gsmSignal = gsmSignal;
362
+ mobileGsmSignal = mobileGsmSignal;
363
+ gsmVoice = gsmVoice;
364
+ mobileGsmVoice = mobileGsmVoice;
365
+ powerAC = powerAC;
366
+ mobilePowerAc = mobilePowerAc;
367
+ powerCapacity = powerCapacity;
368
+ mobilePowerCapacity = mobilePowerCapacity;
369
+ networkSpeed = networkSpeed;
370
+ mobileNetworkSpeed = mobileNetworkSpeed;
371
+ sensorSet = sensorSet;
372
+
373
+ mobileExecEmuConsoleCommand = mobileExecEmuConsoleCommand;
374
+
375
+ getThirdPartyPackages = getThirdPartyPackages;
376
+ uninstallOtherPackages = uninstallOtherPackages;
377
+ installOtherApks = installOtherApks;
378
+ installApk = installApk;
379
+ resetApp = resetApp;
380
+ background = background;
381
+ getCurrentActivity = getCurrentActivity;
382
+ getCurrentPackage = getCurrentPackage;
383
+ mobileClearApp = mobileClearApp;
384
+ mobileInstallApp = mobileInstallApp;
385
+ installApp = installApp;
386
+ mobileActivateApp = mobileActivateApp;
387
+ mobileIsAppInstalled = mobileIsAppInstalled;
388
+ mobileQueryAppState = mobileQueryAppState;
389
+ mobileRemoveApp = mobileRemoveApp;
390
+ mobileTerminateApp = mobileTerminateApp;
391
+ terminateApp = terminateApp;
392
+ removeApp = removeApp;
393
+ activateApp = activateApp;
394
+ queryAppState = queryAppState;
395
+ isAppInstalled = isAppInstalled;
396
+
397
+ mobileGetUiMode = mobileGetUiMode;
398
+ mobileSetUiMode = mobileSetUiMode;
399
+
400
+ mobileDeviceidle = mobileDeviceidle;
401
+
402
+ getAttribute = getAttribute;
403
+ getName = getName;
404
+ elementDisplayed = elementDisplayed;
405
+ elementEnabled = elementEnabled;
406
+ elementSelected = elementSelected;
407
+ setElementValue = setElementValue;
408
+ doSetElementValue = doSetElementValue;
409
+ replaceValue = replaceValue;
410
+ setValueImmediate = setValueImmediate;
411
+ click = click;
412
+ getLocationInView = getLocationInView;
413
+ getText = getText;
414
+ getLocation = getLocation;
415
+ getSize = getSize;
416
+
417
+ execute = execute;
418
+ executeMobile = executeMobile;
419
+
420
+ pullFile = pullFile;
421
+ mobilePullFile = mobilePullFile;
422
+ pullFolder = pullFolder;
423
+ mobilePullFolder = mobilePullFolder;
424
+ pushFile = pushFile;
425
+ mobilePushFile = mobilePushFile;
426
+ mobileDeleteFile = mobileDeleteFile;
427
+
428
+ findElOrEls = findElOrEls;
429
+ doFindElementOrEls = doFindElementOrEls;
430
+
431
+ setGeoLocation = setGeoLocation;
432
+ getGeoLocation = getGeoLocation;
433
+ mobileRefreshGpsCache = mobileRefreshGpsCache;
434
+ toggleLocationServices = toggleLocationServices;
435
+ isLocationServicesEnabled = isLocationServicesEnabled;
436
+
437
+ isIMEActivated = isIMEActivated;
438
+ availableIMEEngines = availableIMEEngines;
439
+ getActiveIMEEngine = getActiveIMEEngine;
440
+ activateIMEEngine = activateIMEEngine;
441
+ deactivateIMEEngine = deactivateIMEEngine;
442
+
443
+ startActivity = startActivity as unknown as (
444
+ appPackage: string,
445
+ appActivity: string,
446
+ appWaitPackage?: string,
447
+ appWaitActivity?: string,
448
+ intentAction?: string,
449
+ intentCategory?: string,
450
+ intentFlags?: string,
451
+ optionalIntentArguments?: string,
452
+ dontStopAppOnReset?: boolean,
453
+ ) => Promise<void>;
454
+ mobileBroadcast = mobileBroadcast;
455
+ mobileStartService = mobileStartService;
456
+ mobileStopService = mobileStopService;
457
+
458
+ hideKeyboard = hideKeyboard;
459
+ isKeyboardShown = isKeyboardShown;
460
+ keys = keys;
461
+ doSendKeys = doSendKeys;
462
+ pressKeyCode = pressKeyCode;
463
+ longPressKeyCode = longPressKeyCode;
464
+ mobilePerformEditorAction = mobilePerformEditorAction;
465
+
466
+ lock = lock;
467
+ unlock = unlock;
468
+ mobileLock = mobileLock;
469
+ mobileUnlock = mobileUnlock;
470
+ isLocked = isLocked;
471
+
472
+ supportedLogTypes = supportedLogTypes;
473
+ mobileStartLogsBroadcast = mobileStartLogsBroadcast;
474
+ mobileStopLogsBroadcast = mobileStopLogsBroadcast;
475
+ getLogTypes = getLogTypes;
476
+ getLog = getLog;
477
+
478
+ mobileIsMediaProjectionRecordingRunning = mobileIsMediaProjectionRecordingRunning;
479
+ mobileStartMediaProjectionRecording = mobileStartMediaProjectionRecording;
480
+ mobileStopMediaProjectionRecording = mobileStopMediaProjectionRecording;
481
+
482
+ mobileSendTrimMemory = mobileSendTrimMemory;
483
+
484
+ getWindowRect = getWindowRect;
485
+ getWindowSize = getWindowSize;
486
+ getDisplayDensity = getDisplayDensity;
487
+ mobileGetNotifications = mobileGetNotifications;
488
+ mobileListSms = mobileListSms;
489
+ openNotifications = openNotifications;
490
+ setUrl = setUrl;
491
+
492
+ getNetworkConnection = getNetworkConnection;
493
+ isWifiOn = isWifiOn;
494
+ mobileGetConnectivity = mobileGetConnectivity;
495
+ mobileSetConnectivity = mobileSetConnectivity;
496
+ setNetworkConnection = setNetworkConnection;
497
+ setWifiState = setWifiState;
498
+ setDataState = setDataState;
499
+ toggleData = toggleData;
500
+ toggleFlightMode = toggleFlightMode;
501
+ toggleWiFi = toggleWiFi;
502
+
503
+ getPerformanceData = getPerformanceData;
504
+ getPerformanceDataTypes = getPerformanceDataTypes;
505
+ mobileGetPerformanceData = mobileGetPerformanceData;
506
+
507
+ mobileChangePermissions = mobileChangePermissions;
508
+ mobileGetPermissions = mobileGetPermissions;
509
+
510
+ startRecordingScreen = startRecordingScreen;
511
+ stopRecordingScreen = stopRecordingScreen;
512
+
513
+ getStrings = getStrings;
514
+ ensureDeviceLocale = ensureDeviceLocale;
515
+
516
+ mobileShell = mobileShell;
517
+
518
+ mobileStartScreenStreaming = mobileStartScreenStreaming;
519
+ mobileStopScreenStreaming = mobileStopScreenStreaming;
520
+
521
+ getSystemBars = getSystemBars;
522
+ mobilePerformStatusBarCommand = mobilePerformStatusBarCommand;
523
+
524
+ getDeviceTime = getDeviceTime;
525
+ mobileGetDeviceTime = mobileGetDeviceTime;
526
+
527
+ tap = tap;
528
+ touchLongClick = touchLongClick;
529
+ touchDown = touchDown;
530
+ touchUp = touchUp;
531
+ touchMove = touchMove;
532
+ doSwipe = doSwipe;
533
+ doTouchDrag = doTouchDrag;
534
+ doTouchAction = doTouchAction;
535
+ performMultiAction = performMultiAction;
536
+ performTouch = performTouch;
537
+ doPerformMultiAction = doPerformMultiAction;
95
538
  }
96
539
 
97
- export {commands as androidCommands} from './commands';
98
540
  export {AndroidDriver};
package/lib/index.ts CHANGED
@@ -2,21 +2,9 @@ import {install} from 'source-map-support';
2
2
  install();
3
3
 
4
4
  import {AndroidDriver} from './driver';
5
- export type * from './commands';
5
+ export type * from './commands/types';
6
6
  export {ANDROID_DRIVER_CONSTRAINTS as commonCapConstraints} from './constraints';
7
7
  export * from './driver';
8
8
  export * as doctor from './doctor/checks';
9
- export {
10
- SETTINGS_HELPER_ID as SETTINGS_HELPER_PKG_ID,
11
- default as androidHelpers
12
- } from './helpers/android';
13
- export type * from './helpers/types';
14
- export {
15
- CHROMIUM_WIN,
16
- NATIVE_WIN,
17
- WEBVIEW_BASE,
18
- WEBVIEW_WIN,
19
- default as webviewHelpers,
20
- } from './helpers/webview';
21
9
 
22
10
  export default AndroidDriver;
package/lib/logger.js CHANGED
@@ -1,4 +1,4 @@
1
- import { logger } from '@appium/support';
1
+ import {logger} from '@appium/support';
2
2
  const log = logger.getLogger('AndroidDriver');
3
3
 
4
4
  export default log;
package/lib/method-map.js CHANGED
@@ -37,14 +37,6 @@ export const newMethodMap = /** @type {const} */ ({
37
37
  payloadParams: {required: ['elements']},
38
38
  },
39
39
  },
40
- '/session/:sessionId/touch/flick': {
41
- POST: {
42
- command: 'flick',
43
- payloadParams: {
44
- optional: ['element', 'xspeed', 'yspeed', 'xoffset', 'yoffset', 'speed'],
45
- },
46
- },
47
- },
48
40
  '/session/:sessionId/touch/perform': {
49
41
  POST: {
50
42
  command: 'performTouch',
@@ -178,9 +170,6 @@ export const newMethodMap = /** @type {const} */ ({
178
170
  },
179
171
  '/session/:sessionId/appium/device/system_bars': {GET: {command: 'getSystemBars'}},
180
172
  '/session/:sessionId/appium/device/display_density': {GET: {command: 'getDisplayDensity'}},
181
- '/session/:sessionId/appium/app/launch': {POST: {command: 'launchApp'}},
182
- '/session/:sessionId/appium/app/close': {POST: {command: 'closeApp'}},
183
- '/session/:sessionId/appium/app/reset': {POST: {command: 'reset'}},
184
173
  '/session/:sessionId/appium/app/background': {
185
174
  POST: {
186
175
  command: 'background',
package/lib/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { errors } from 'appium/driver';
2
+ import {errors} from 'appium/driver';
3
3
 
4
4
  export const ADB_SHELL_FEATURE = 'adb_shell';
5
5
 
@@ -10,11 +10,48 @@ export const ADB_SHELL_FEATURE = 'adb_shell';
10
10
  * @param {any} opts the object to check
11
11
  * @returns {Record<string, any>} the same given object
12
12
  */
13
- export function requireArgs (argNames, opts) {
14
- for (const argName of (_.isArray(argNames) ? argNames : [argNames])) {
13
+ export function requireArgs(argNames, opts) {
14
+ for (const argName of _.isArray(argNames) ? argNames : [argNames]) {
15
15
  if (!_.has(opts, argName)) {
16
16
  throw new errors.InvalidArgumentError(`'${argName}' argument must be provided`);
17
17
  }
18
18
  }
19
19
  return opts;
20
20
  }
21
+
22
+ /**
23
+ *
24
+ * @param {string | string[]} cap
25
+ * @returns {string[]}
26
+ */
27
+ export function parseArray(cap) {
28
+ let parsedCaps;
29
+ try {
30
+ // @ts-ignore this is fine
31
+ parsedCaps = JSON.parse(cap);
32
+ } catch (ign) {}
33
+
34
+ if (_.isArray(parsedCaps)) {
35
+ return parsedCaps;
36
+ } else if (_.isString(cap)) {
37
+ return [cap];
38
+ }
39
+
40
+ throw new Error(`must provide a string or JSON Array; received ${cap}`);
41
+ }
42
+
43
+ /**
44
+ * @param {import('@appium/types').AppiumServer} server
45
+ * @param {string?} [sessionId]
46
+ * @returns {Promise<void>}
47
+ */
48
+ export async function removeAllSessionWebSocketHandlers(server, sessionId) {
49
+ if (!server || !_.isFunction(server.getWebSocketHandlers)) {
50
+ return;
51
+ }
52
+
53
+ const activeHandlers = await server.getWebSocketHandlers(sessionId);
54
+ for (const pathname of _.keys(activeHandlers)) {
55
+ await server.removeWebSocketHandler(pathname);
56
+ }
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-android-driver",
3
- "version": "7.8.3",
3
+ "version": "8.0.1",
4
4
  "description": "Android UiAutomator and Chrome support for Appium",
5
5
  "keywords": [
6
6
  "appium",
@@ -115,7 +115,7 @@
115
115
  "mocha": "^10.0.0",
116
116
  "prettier": "^3.0.1",
117
117
  "rimraf": "^5.0.0",
118
- "semantic-release": "^22.0.5",
118
+ "semantic-release": "^23.0.0",
119
119
  "sinon": "^17.0.0",
120
120
  "ts-node": "^10.9.1",
121
121
  "typescript": "~5.2",
@@ -1,8 +0,0 @@
1
- export default ActionsMixin;
2
- export type ADB = import('appium-adb').ADB;
3
- /**
4
- * @type {import('./mixins').ActionsMixin & ThisType<import('../driver').AndroidDriver>}
5
- * @satisfies {import('@appium/types').ExternalDriver}
6
- */
7
- declare const ActionsMixin: import('./mixins').ActionsMixin & ThisType<import('../driver').AndroidDriver>;
8
- //# sourceMappingURL=actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../lib/commands/actions.js"],"names":[],"mappings":";kBAkPa,OAAO,YAAY,EAAE,GAAG;AAvOrC;;;GAGG;AACH,4BAHU,OAAO,UAAU,EAAE,YAAY,GAAG,SAAS,OAAO,WAAW,EAAE,aAAa,CAAC,CA+NrF"}