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
@@ -1,343 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import {util} from '@appium/support';
3
- import {longSleep} from 'asyncbox';
4
- import _ from 'lodash';
5
- import moment from 'moment';
6
- import androidHelpers from '../helpers/android';
7
- import {requireArgs} from '../utils';
8
- import {mixin} from './mixins';
9
- import {errors} from 'appium/driver';
10
-
11
- const MOMENT_FORMAT_ISO8601 = 'YYYY-MM-DDTHH:mm:ssZ';
12
-
13
- /**
14
- * @type {import('./mixins').GeneralMixin & ThisType<import('../driver').AndroidDriver>}
15
- * @satisfies {import('@appium/types').ExternalDriver}
16
- */
17
- const GeneralMixin = {
18
- _cachedActivityArgs: {},
19
- async keys(keys) {
20
- // Protocol sends an array; rethink approach
21
- keys = _.isArray(keys) ? keys.join('') : keys;
22
- await this.doSendKeys({
23
- text: keys,
24
- replace: false,
25
- });
26
- },
27
-
28
- async doSendKeys(params) {
29
- throw new errors.NotImplementedError('Not implemented');
30
- },
31
-
32
- async getDeviceTime(format = MOMENT_FORMAT_ISO8601) {
33
- this.log.debug(
34
- 'Attempting to capture android device date and time. ' + `The format specifier is '${format}'`
35
- );
36
- const deviceTimestamp = (
37
- await this.adb.shell(['date', '+%Y-%m-%dT%T%z'])
38
- ).trim();
39
- this.log.debug(`Got device timestamp: ${deviceTimestamp}`);
40
- const parsedTimestamp = moment.utc(deviceTimestamp, 'YYYY-MM-DDTHH:mm:ssZZ');
41
- if (!parsedTimestamp.isValid()) {
42
- this.log.warn('Cannot parse the returned timestamp. Returning as is');
43
- return deviceTimestamp;
44
- }
45
- // @ts-expect-error private API
46
- return parsedTimestamp.utcOffset(parsedTimestamp._tzm || 0).format(format);
47
- },
48
-
49
- async mobileGetDeviceTime(opts = {}) {
50
- return await this.getDeviceTime(opts.format);
51
- },
52
-
53
- async getPageSource() {
54
- throw new errors.NotImplementedError('Not implemented');
55
- },
56
-
57
- async back() {
58
- throw new errors.NotImplementedError('Not implemented');
59
- },
60
-
61
- async openSettingsActivity(setting) {
62
- let {appPackage, appActivity} = await this.adb.getFocusedPackageAndActivity();
63
- await this.adb.shell(['am', 'start', '-a', `android.settings.${setting}`]);
64
- await this.adb.waitForNotActivity(
65
- /** @type {string} */ (appPackage),
66
- /** @type {string} */ (appActivity),
67
- 5000
68
- );
69
- },
70
-
71
- async getWindowSize() {
72
- throw new errors.NotImplementedError('Not implemented');
73
- },
74
-
75
- // For W3C
76
- async getWindowRect() {
77
- const {width, height} = await this.getWindowSize();
78
- return {
79
- width,
80
- height,
81
- x: 0,
82
- y: 0,
83
- };
84
- },
85
-
86
- /**
87
- * @returns {Promise<string>}
88
- */
89
- async getCurrentActivity() {
90
- return /** @type {string} */ ((await this.adb.getFocusedPackageAndActivity()).appActivity);
91
- },
92
-
93
- /**
94
- * @returns {Promise<string>}
95
- */
96
- async getCurrentPackage() {
97
- return /** @type {string} */ ((await this.adb.getFocusedPackageAndActivity()).appPackage);
98
- },
99
-
100
- async background(seconds) {
101
- if (seconds < 0) {
102
- // if user passes in a negative seconds value, interpret that as the instruction
103
- // to not bring the app back at all
104
- await this.adb.goToHome();
105
- return true;
106
- }
107
- let {appPackage, appActivity} = await this.adb.getFocusedPackageAndActivity();
108
- await this.adb.goToHome();
109
-
110
- // people can wait for a long time, so to be safe let's use the longSleep function and log
111
- // progress periodically.
112
- const sleepMs = seconds * 1000;
113
- const thresholdMs = 30 * 1000; // use the spin-wait for anything over this threshold
114
- // for our spin interval, use 1% of the total wait time, but nothing bigger than 30s
115
- const intervalMs = _.min([30 * 1000, parseInt(String(sleepMs / 100), 10)]);
116
- /**
117
- *
118
- * @param {{elapsedMs: number, progress: number}} param0
119
- */
120
- const progressCb = ({elapsedMs, progress}) => {
121
- const waitSecs = (elapsedMs / 1000).toFixed(0);
122
- const progressPct = (progress * 100).toFixed(2);
123
- this.log.debug(`Waited ${waitSecs}s so far (${progressPct}%)`);
124
- };
125
- await longSleep(sleepMs, {thresholdMs, intervalMs, progressCb});
126
-
127
- /** @type {import('appium-adb').StartAppOptions} */
128
- let args;
129
- if (this._cachedActivityArgs && this._cachedActivityArgs[`${appPackage}/${appActivity}`]) {
130
- // the activity was started with `startActivity`, so use those args to restart
131
- args = this._cachedActivityArgs[`${appPackage}/${appActivity}`];
132
- } else {
133
- try {
134
- this.log.debug(`Activating app '${appPackage}' in order to restore it`);
135
- await this.activateApp(/** @type {string} */ (appPackage));
136
- return true;
137
- } catch (ign) {}
138
- args =
139
- (appPackage === this.opts.appPackage && appActivity === this.opts.appActivity) ||
140
- (appPackage === this.opts.appWaitPackage &&
141
- (this.opts.appWaitActivity || '').split(',').includes(String(appActivity)))
142
- ? {
143
- // the activity is the original session activity, so use the original args
144
- pkg: /** @type {string} */ (this.opts.appPackage),
145
- activity: this.opts.appActivity ?? undefined,
146
- action: this.opts.intentAction,
147
- category: this.opts.intentCategory,
148
- flags: this.opts.intentFlags,
149
- waitPkg: this.opts.appWaitPackage ?? undefined,
150
- waitActivity: this.opts.appWaitActivity ?? undefined,
151
- waitForLaunch: this.opts.appWaitForLaunch,
152
- waitDuration: this.opts.appWaitDuration,
153
- optionalIntentArguments: this.opts.optionalIntentArguments,
154
- stopApp: false,
155
- user: this.opts.userProfile,
156
- }
157
- : {
158
- // the activity was started some other way, so use defaults
159
- pkg: /** @type {string} */ (appPackage),
160
- activity: appActivity ?? undefined,
161
- waitPkg: appPackage ?? undefined,
162
- waitActivity: appActivity ?? undefined,
163
- stopApp: false,
164
- };
165
- }
166
- args = /** @type {import('appium-adb').StartAppOptions} */ (
167
- _.pickBy(args, (value) => !_.isUndefined(value))
168
- );
169
- this.log.debug(
170
- `Bringing application back to foreground with arguments: ${JSON.stringify(args)}`
171
- );
172
- return await this.adb.startApp(args);
173
- },
174
-
175
- async getStrings(language) {
176
- if (!language) {
177
- language = await this.adb.getDeviceLanguage();
178
- this.log.info(`No language specified, returning strings for: ${language}`);
179
- }
180
-
181
- // Clients require the resulting mapping to have both keys
182
- // and values of type string
183
- /** @param {StringRecord} mapping */
184
- const preprocessStringsMap = (mapping) => {
185
- /** @type {StringRecord} */
186
- const result = {};
187
- for (const [key, value] of _.toPairs(mapping)) {
188
- result[key] = _.isString(value) ? value : JSON.stringify(value);
189
- }
190
- return result;
191
- };
192
-
193
- if (this.apkStrings[language]) {
194
- // Return cached strings
195
- return preprocessStringsMap(this.apkStrings[language]);
196
- }
197
-
198
- this.apkStrings[language] = await androidHelpers.pushStrings(language, this.adb, this.opts);
199
-
200
- return preprocessStringsMap(this.apkStrings[language]);
201
- },
202
-
203
- async launchApp() {
204
- throw new errors.NotImplementedError('Not implemented');
205
- },
206
-
207
- async startActivity(
208
- appPackage,
209
- appActivity,
210
- appWaitPackage,
211
- appWaitActivity,
212
- intentAction,
213
- intentCategory,
214
- intentFlags,
215
- optionalIntentArguments,
216
- dontStopAppOnReset
217
- ) {
218
- this.log.debug(`Starting package '${appPackage}' and activity '${appActivity}'`);
219
-
220
- // dontStopAppOnReset is both an argument here, and a desired capability
221
- // if the argument is set, use it, otherwise use the cap
222
- if (!util.hasValue(dontStopAppOnReset)) {
223
- dontStopAppOnReset = !!this.opts.dontStopAppOnReset;
224
- }
225
-
226
- /** @type {import('appium-adb').StartAppOptions} */
227
- let args = {
228
- pkg: appPackage,
229
- activity: appActivity,
230
- waitPkg: appWaitPackage || appPackage,
231
- waitActivity: appWaitActivity || appActivity,
232
- action: intentAction,
233
- category: intentCategory,
234
- flags: intentFlags,
235
- optionalIntentArguments,
236
- stopApp: !dontStopAppOnReset,
237
- };
238
- this._cachedActivityArgs = this._cachedActivityArgs || {};
239
- this._cachedActivityArgs[`${args.waitPkg}/${args.waitActivity}`] = args;
240
- await this.adb.startApp(args);
241
- },
242
-
243
- async reset() {
244
- await androidHelpers.resetApp(
245
- this.adb,
246
- Object.assign({}, this.opts, {fastReset: true})
247
- );
248
- // reset context since we don't know what kind on context we will end up after app launch.
249
- await this.setContext();
250
- return this.isChromeSession ? this.startChromeSession() : this.startAUT();
251
- },
252
-
253
- async startAUT() {
254
- await this.adb.startApp({
255
- pkg: /** @type {string} */ (this.opts.appPackage),
256
- activity: this.opts.appActivity,
257
- action: this.opts.intentAction,
258
- category: this.opts.intentCategory,
259
- flags: this.opts.intentFlags,
260
- waitPkg: this.opts.appWaitPackage,
261
- waitActivity: this.opts.appWaitActivity,
262
- waitForLaunch: this.opts.appWaitForLaunch,
263
- waitDuration: this.opts.appWaitDuration,
264
- optionalIntentArguments: this.opts.optionalIntentArguments,
265
- stopApp: !this.opts.dontStopAppOnReset,
266
- user: this.opts.userProfile,
267
- });
268
- },
269
-
270
- // we override setUrl to take an android URI which can be used for deep-linking
271
- // inside an app, similar to starting an intent
272
- async setUrl(uri) {
273
- await this.adb.startUri(uri, /** @type {string} */ (this.opts.appPackage));
274
- },
275
-
276
- // closing app using force stop
277
- async closeApp() {
278
- await this.adb.forceStop(/** @type {string} */ (this.opts.appPackage));
279
- // reset context since we don't know what kind on context we will end up after app launch.
280
- await this.setContext();
281
- },
282
-
283
- async getDisplayDensity() {
284
- // first try the property for devices
285
- let out = await this.adb.shell(['getprop', 'ro.sf.lcd_density']);
286
- if (out) {
287
- let val = parseInt(out, 10);
288
- // if the value is NaN, try getting the emulator property
289
- if (!isNaN(val)) {
290
- return val;
291
- }
292
- this.log.debug(`Parsed density value was NaN: "${out}"`);
293
- }
294
- // fallback to trying property for emulators
295
- out = await this.adb.shell(['getprop', 'qemu.sf.lcd_density']);
296
- if (out) {
297
- let val = parseInt(out, 10);
298
- if (!isNaN(val)) {
299
- return val;
300
- }
301
- this.log.debug(`Parsed density value was NaN: "${out}"`);
302
- }
303
- // couldn't get anything, so error out
304
- throw this.log.errorAndThrow('Failed to get display density property.');
305
- },
306
-
307
- async mobilePerformEditorAction(opts) {
308
- const {action} = requireArgs('action', opts);
309
- await this.settingsApp.performEditorAction(action);
310
- },
311
-
312
- async mobileGetNotifications() {
313
- return await this.settingsApp.getNotifications();
314
- },
315
-
316
- async mobileListSms(opts) {
317
- return await this.settingsApp.getSmsList(opts);
318
- },
319
-
320
- async mobileUnlock(opts = {}) {
321
- const {key, type, strategy, timeoutMs} = opts;
322
- if (!key && !type) {
323
- await this.unlock();
324
- } else {
325
- // @ts-expect-error XXX: these caps should be defined in the constraints!!
326
- await androidHelpers.unlock(this, this.adb, {
327
- unlockKey: key,
328
- unlockType: type,
329
- unlockStrategy: strategy,
330
- unlockSuccessTimeout: timeoutMs,
331
- });
332
- }
333
- },
334
- };
335
-
336
- mixin(GeneralMixin);
337
-
338
- export default GeneralMixin;
339
-
340
- /**
341
- * @typedef {import('appium-adb').ADB} ADB
342
- * @typedef {import('@appium/types').StringRecord} StringRecord
343
- */
@@ -1,54 +0,0 @@
1
- import actionCmds from './actions';
2
- import alertCmds from './alert';
3
- import appManagementCmds from './app-management';
4
- import contextCmds from './context';
5
- import elementCmds from './element';
6
- import emuConsoleCmds from './emu-console';
7
- import executeCmds from './execute';
8
- import fileActionsCmds from './file-actions';
9
- import findCmds from './find';
10
- import generalCmds from './general';
11
- import imeCmds from './ime';
12
- import intentCmds from './intent';
13
- import keyboardCmds from './keyboard';
14
- import logCmds from './log';
15
- import mediaProjectionCmds from './media-projection';
16
- import networkCmds from './network';
17
- import performanceCmds from './performance';
18
- import permissionsCmds from './permissions';
19
- import recordscreenCmds from './recordscreen';
20
- import shellCmds from './shell';
21
- import screenStreamCmds from './streamscreen';
22
- import systemBarsCmds from './system-bars';
23
- import touchCmds from './touch';
24
-
25
- const commands = {
26
- findCmds,
27
- generalCmds,
28
- alertCmds,
29
- elementCmds,
30
- contextCmds,
31
- actionCmds,
32
- touchCmds,
33
- imeCmds,
34
- networkCmds,
35
- recordscreenCmds,
36
- intentCmds,
37
- screenStreamCmds,
38
- performanceCmds,
39
- executeCmds,
40
- shellCmds,
41
- emuConsoleCmds,
42
- systemBarsCmds,
43
- appManagementCmds,
44
- fileActionsCmds,
45
- logCmds,
46
- mediaProjectionCmds,
47
- permissionsCmds,
48
- keyboardCmds,
49
- // add other command types here
50
- };
51
-
52
- export {commands};
53
-
54
- export type * from './mixins';