appium-android-driver 5.14.7 → 6.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 (192) hide show
  1. package/build/index.d.ts +282 -0
  2. package/build/index.d.ts.map +1 -0
  3. package/build/index.js.map +1 -0
  4. package/build/lib/commands/actions.d.ts +6 -224
  5. package/build/lib/commands/actions.d.ts.map +1 -1
  6. package/build/lib/commands/actions.js +306 -405
  7. package/build/lib/commands/actions.js.map +1 -1
  8. package/build/lib/commands/alert.d.ts +7 -9
  9. package/build/lib/commands/alert.d.ts.map +1 -1
  10. package/build/lib/commands/alert.js +24 -18
  11. package/build/lib/commands/alert.js.map +1 -1
  12. package/build/lib/commands/app-management.d.ts +7 -313
  13. package/build/lib/commands/app-management.d.ts.map +1 -1
  14. package/build/lib/commands/app-management.js +135 -293
  15. package/build/lib/commands/app-management.js.map +1 -1
  16. package/build/lib/commands/context.d.ts +8 -92
  17. package/build/lib/commands/context.d.ts.map +1 -1
  18. package/build/lib/commands/context.js +381 -439
  19. package/build/lib/commands/context.js.map +1 -1
  20. package/build/lib/commands/element.d.ts +8 -35
  21. package/build/lib/commands/element.d.ts.map +1 -1
  22. package/build/lib/commands/element.js +153 -136
  23. package/build/lib/commands/element.js.map +1 -1
  24. package/build/lib/commands/emu-console.d.ts +6 -48
  25. package/build/lib/commands/emu-console.d.ts.map +1 -1
  26. package/build/lib/commands/emu-console.js +19 -34
  27. package/build/lib/commands/emu-console.js.map +1 -1
  28. package/build/lib/commands/execute.d.ts +6 -5
  29. package/build/lib/commands/execute.d.ts.map +1 -1
  30. package/build/lib/commands/execute.js +77 -66
  31. package/build/lib/commands/execute.js.map +1 -1
  32. package/build/lib/commands/file-actions.d.ts +7 -128
  33. package/build/lib/commands/file-actions.d.ts.map +1 -1
  34. package/build/lib/commands/file-actions.js +183 -219
  35. package/build/lib/commands/file-actions.js.map +1 -1
  36. package/build/lib/commands/find.d.ts +8 -12
  37. package/build/lib/commands/find.d.ts.map +1 -1
  38. package/build/lib/commands/find.js +19 -23
  39. package/build/lib/commands/find.js.map +1 -1
  40. package/build/lib/commands/general.d.ts +9 -132
  41. package/build/lib/commands/general.d.ts.map +1 -1
  42. package/build/lib/commands/general.js +281 -312
  43. package/build/lib/commands/general.js.map +1 -1
  44. package/build/lib/commands/ime.d.ts +7 -10
  45. package/build/lib/commands/ime.d.ts.map +1 -1
  46. package/build/lib/commands/ime.js +47 -35
  47. package/build/lib/commands/ime.js.map +1 -1
  48. package/build/lib/commands/index.d.ts +27 -2
  49. package/build/lib/commands/index.d.ts.map +1 -1
  50. package/build/lib/commands/index.js +41 -19
  51. package/build/lib/commands/index.js.map +1 -1
  52. package/build/lib/commands/intent.d.ts +7 -417
  53. package/build/lib/commands/intent.d.ts.map +1 -1
  54. package/build/lib/commands/intent.js +104 -216
  55. package/build/lib/commands/intent.js.map +1 -1
  56. package/build/lib/commands/keyboard.d.ts +6 -5
  57. package/build/lib/commands/keyboard.d.ts.map +1 -1
  58. package/build/lib/commands/keyboard.js +16 -8
  59. package/build/lib/commands/keyboard.js.map +1 -1
  60. package/build/lib/commands/log.d.ts +7 -44
  61. package/build/lib/commands/log.d.ts.map +1 -1
  62. package/build/lib/commands/log.js +146 -108
  63. package/build/lib/commands/log.js.map +1 -1
  64. package/build/lib/commands/media-projection.d.ts +7 -143
  65. package/build/lib/commands/media-projection.d.ts.map +1 -1
  66. package/build/lib/commands/media-projection.js +113 -140
  67. package/build/lib/commands/media-projection.js.map +1 -1
  68. package/build/lib/commands/mixins.d.ts +740 -0
  69. package/build/lib/commands/mixins.d.ts.map +1 -0
  70. package/build/lib/commands/mixins.js +19 -0
  71. package/build/lib/commands/mixins.js.map +1 -0
  72. package/build/lib/commands/network.d.ts +7 -138
  73. package/build/lib/commands/network.d.ts.map +1 -1
  74. package/build/lib/commands/network.js +212 -254
  75. package/build/lib/commands/network.js.map +1 -1
  76. package/build/lib/commands/performance.d.ts +24 -70
  77. package/build/lib/commands/performance.d.ts.map +1 -1
  78. package/build/lib/commands/performance.js +144 -100
  79. package/build/lib/commands/performance.js.map +1 -1
  80. package/build/lib/commands/permissions.d.ts +8 -92
  81. package/build/lib/commands/permissions.d.ts.map +1 -1
  82. package/build/lib/commands/permissions.js +75 -87
  83. package/build/lib/commands/permissions.js.map +1 -1
  84. package/build/lib/commands/recordscreen.d.ts +7 -193
  85. package/build/lib/commands/recordscreen.d.ts.map +1 -1
  86. package/build/lib/commands/recordscreen.js +151 -182
  87. package/build/lib/commands/recordscreen.js.map +1 -1
  88. package/build/lib/commands/shell.d.ts +7 -7
  89. package/build/lib/commands/shell.d.ts.map +1 -1
  90. package/build/lib/commands/shell.js +40 -33
  91. package/build/lib/commands/shell.js.map +1 -1
  92. package/build/lib/commands/streamscreen.d.ts +9 -103
  93. package/build/lib/commands/streamscreen.d.ts.map +1 -1
  94. package/build/lib/commands/streamscreen.js +261 -218
  95. package/build/lib/commands/streamscreen.js.map +1 -1
  96. package/build/lib/commands/system-bars.d.ts +22 -90
  97. package/build/lib/commands/system-bars.d.ts.map +1 -1
  98. package/build/lib/commands/system-bars.js +76 -74
  99. package/build/lib/commands/system-bars.js.map +1 -1
  100. package/build/lib/commands/touch.d.ts +10 -29
  101. package/build/lib/commands/touch.d.ts.map +1 -1
  102. package/build/lib/commands/touch.js +301 -285
  103. package/build/lib/commands/touch.js.map +1 -1
  104. package/build/lib/commands/types.d.ts +978 -0
  105. package/build/lib/commands/types.d.ts.map +1 -0
  106. package/build/lib/commands/types.js +3 -0
  107. package/build/lib/commands/types.js.map +1 -0
  108. package/build/lib/constraints.d.ts +291 -0
  109. package/build/lib/constraints.d.ts.map +1 -0
  110. package/build/lib/constraints.js +300 -0
  111. package/build/lib/constraints.js.map +1 -0
  112. package/build/lib/driver.d.ts +68 -37
  113. package/build/lib/driver.d.ts.map +1 -1
  114. package/build/lib/driver.js +123 -80
  115. package/build/lib/driver.js.map +1 -1
  116. package/build/lib/helpers/android.d.ts +164 -0
  117. package/build/lib/helpers/android.d.ts.map +1 -0
  118. package/build/lib/helpers/android.js +819 -0
  119. package/build/lib/helpers/android.js.map +1 -0
  120. package/build/lib/helpers/index.d.ts +7 -0
  121. package/build/lib/helpers/index.d.ts.map +1 -0
  122. package/build/lib/helpers/index.js +29 -0
  123. package/build/lib/helpers/index.js.map +1 -0
  124. package/build/lib/helpers/types.d.ts +121 -0
  125. package/build/lib/helpers/types.d.ts.map +1 -0
  126. package/build/lib/helpers/types.js +3 -0
  127. package/build/lib/helpers/types.js.map +1 -0
  128. package/build/lib/helpers/unlock.d.ts +32 -0
  129. package/build/lib/helpers/unlock.d.ts.map +1 -0
  130. package/build/lib/helpers/unlock.js +273 -0
  131. package/build/lib/helpers/unlock.js.map +1 -0
  132. package/build/lib/helpers/webview.d.ts +74 -0
  133. package/build/lib/helpers/webview.d.ts.map +1 -0
  134. package/build/lib/helpers/webview.js +421 -0
  135. package/build/lib/helpers/webview.js.map +1 -0
  136. package/build/lib/index.d.ts +9 -0
  137. package/build/lib/index.d.ts.map +1 -0
  138. package/build/lib/index.js +37 -0
  139. package/build/lib/index.js.map +1 -0
  140. package/build/lib/method-map.d.ts +0 -8
  141. package/build/lib/method-map.d.ts.map +1 -1
  142. package/build/lib/method-map.js +63 -74
  143. package/build/lib/method-map.js.map +1 -1
  144. package/build/lib/stubs.d.ts +0 -1
  145. package/build/lib/stubs.d.ts.map +1 -1
  146. package/build/lib/stubs.js +1 -0
  147. package/build/lib/stubs.js.map +1 -1
  148. package/build/lib/utils.d.ts +1 -1
  149. package/build/lib/utils.d.ts.map +1 -1
  150. package/lib/commands/actions.js +351 -464
  151. package/lib/commands/alert.js +27 -17
  152. package/lib/commands/app-management.js +156 -314
  153. package/lib/commands/context.js +457 -441
  154. package/lib/commands/element.js +201 -157
  155. package/lib/commands/emu-console.js +25 -45
  156. package/lib/commands/execute.js +106 -90
  157. package/lib/commands/file-actions.js +222 -240
  158. package/lib/commands/find.ts +103 -0
  159. package/lib/commands/general.js +327 -339
  160. package/lib/commands/ime.js +50 -34
  161. package/lib/commands/{index.js → index.ts} +20 -24
  162. package/lib/commands/intent.js +108 -249
  163. package/lib/commands/keyboard.js +20 -8
  164. package/lib/commands/log.js +172 -116
  165. package/lib/commands/media-projection.js +134 -161
  166. package/lib/commands/mixins.ts +966 -0
  167. package/lib/commands/network.js +252 -281
  168. package/lib/commands/performance.js +203 -132
  169. package/lib/commands/permissions.js +108 -109
  170. package/lib/commands/recordscreen.js +212 -209
  171. package/lib/commands/shell.js +51 -40
  172. package/lib/commands/streamscreen.js +355 -289
  173. package/lib/commands/system-bars.js +92 -83
  174. package/lib/commands/touch.js +357 -294
  175. package/lib/commands/types.ts +1097 -0
  176. package/lib/{desired-caps.js → constraints.ts} +106 -103
  177. package/lib/{driver.js → driver.ts} +278 -132
  178. package/lib/helpers/android.ts +1143 -0
  179. package/lib/helpers/index.ts +6 -0
  180. package/lib/helpers/types.ts +134 -0
  181. package/lib/helpers/unlock.ts +329 -0
  182. package/lib/helpers/webview.ts +582 -0
  183. package/lib/index.ts +18 -0
  184. package/lib/method-map.js +87 -98
  185. package/lib/stubs.ts +0 -1
  186. package/package.json +27 -20
  187. package/index.js +0 -24
  188. package/lib/android-helpers.js +0 -983
  189. package/lib/commands/coverage.js +0 -18
  190. package/lib/commands/find.js +0 -82
  191. package/lib/unlock-helpers.js +0 -278
  192. package/lib/webview-helpers.js +0 -602
@@ -1,5 +1,19 @@
1
- export default AndroidDriver;
2
- export class AndroidDriver extends BaseDriver<any, import("@appium/types").StringRecord, import("@appium/types").StringRecord, import("@appium/types").DefaultCreateSessionResult<any>, void, import("@appium/types").StringRecord> {
1
+ import type { DriverCaps, DriverData, DriverOpts, ExternalDriver, InitialOpts, RouteMatcher, StringRecord, W3CDriverCaps } from '@appium/types';
2
+ import ADB from 'appium-adb';
3
+ import type { default as AppiumChromedriver } from 'appium-chromedriver';
4
+ import { BaseDriver } from 'appium/driver';
5
+ import AndroidBootstrap from './bootstrap';
6
+ import { AndroidDriverConstraints } from './constraints';
7
+ import { helpers } from './helpers';
8
+ export type AndroidDriverCaps = DriverCaps<AndroidDriverConstraints>;
9
+ export type W3CAndroidDriverCaps = W3CDriverCaps<AndroidDriverConstraints>;
10
+ export type AndroidDriverOpts = DriverOpts<AndroidDriverConstraints>;
11
+ export interface AndroidSettings {
12
+ ignoreUnimportantViews: boolean;
13
+ }
14
+ export type AndroidDriverCreateResult = [string, AndroidDriverCaps];
15
+ type AndroidExternalDriver = ExternalDriver<AndroidDriverConstraints>;
16
+ declare class AndroidDriver<Settings extends AndroidSettings = AndroidSettings, CreateResult = AndroidDriverCreateResult> extends BaseDriver<AndroidDriverConstraints, StringRecord, Settings, CreateResult> implements ExternalDriver<AndroidDriverConstraints, string, StringRecord, Settings, CreateResult> {
3
17
  static newMethodMap: {
4
18
  readonly '/session/:sessionId/timeouts/implicit_wait': {
5
19
  readonly POST: {
@@ -355,14 +369,6 @@ export class AndroidDriver extends BaseDriver<any, import("@appium/types").Strin
355
369
  };
356
370
  };
357
371
  };
358
- readonly '/session/:sessionId/appium/app/end_test_coverage': {
359
- readonly POST: {
360
- readonly command: "endCoverage";
361
- readonly payloadParams: {
362
- readonly required: readonly ["intent", "path"];
363
- };
364
- };
365
- };
366
372
  readonly '/session/:sessionId/appium/app/strings': {
367
373
  readonly POST: {
368
374
  readonly command: "getStrings";
@@ -388,43 +394,68 @@ export class AndroidDriver extends BaseDriver<any, import("@appium/types").Strin
388
394
  };
389
395
  };
390
396
  };
391
- constructor(opts?: {}, shouldValidateCaps?: boolean);
392
- desiredCapConstraints: {};
393
- sessionChromedrivers: {};
397
+ jwpProxyAvoid: RouteMatcher[];
398
+ bootstrap?: AndroidBootstrap;
399
+ adb?: ADB;
400
+ unlocker: typeof helpers.unlocker;
401
+ apkStrings: StringRecord<StringRecord<string>>;
402
+ proxyReqRes?: (...args: any) => any;
403
+ contexts?: string[];
404
+ sessionChromedrivers: StringRecord<AppiumChromedriver>;
405
+ chromedriver?: AppiumChromedriver;
406
+ proxyCommand?: AndroidExternalDriver['proxyCommand'];
394
407
  jwpProxyActive: boolean;
395
- jwpProxyAvoid: (string | RegExp)[][];
396
- settings: DeviceSettings<{
397
- ignoreUnimportantViews: boolean;
398
- }>;
399
- chromedriver: any;
400
- apkStrings: {};
401
- unlocker: typeof import("./unlock-helpers").helpers;
402
- curContext: any;
403
- createSession(...args: any[]): Promise<(string | import("@appium/types").DriverCaps<any>)[]>;
404
- useUnlockHelperApp: boolean | undefined;
405
- adb: any;
408
+ curContext: string;
409
+ useUnlockHelperApp?: boolean;
410
+ defaultIME?: string;
411
+ _wasWindowAnimationDisabled?: boolean;
412
+ opts: AndroidDriverOpts;
413
+ constructor(opts?: InitialOpts, shouldValidateCaps?: boolean);
414
+ createSession(w3cCaps1: W3CAndroidDriverCaps, w3cCaps2?: W3CAndroidDriverCaps, w3cCaps3?: W3CAndroidDriverCaps, driverData?: DriverData[]): Promise<CreateResult>;
406
415
  isEmulator(): boolean;
407
- setAvdFromCapabilities(caps: any): void;
416
+ setAvdFromCapabilities(caps: AndroidDriverCaps): void;
408
417
  get appOnDevice(): boolean;
409
418
  get isChromeSession(): boolean;
410
- onSettingsUpdate(key: any, value: any): Promise<void>;
411
- startAndroidSession(): Promise<void>;
412
- defaultIME: any;
413
- _wasWindowAnimationDisabled: boolean | undefined;
414
- bootstrap: import("./bootstrap").AndroidBootstrap | null | undefined;
419
+ onSettingsUpdate(key: keyof Settings, value: any): Promise<void>;
420
+ startAndroidSession(opts: AndroidDriverOpts): Promise<void>;
415
421
  initAutoWebview(): Promise<void>;
416
422
  initAUT(): Promise<void>;
417
423
  checkAppPresent(): Promise<void>;
418
424
  checkPackagePresent(): Promise<void>;
425
+ /**
426
+ * Set CompressedLayoutHierarchy on the device
427
+ * @privateRemarks FIXME: unknown param type
428
+ */
419
429
  setCompressedLayoutHierarchy(compress: any): Promise<void>;
420
430
  deleteSession(): Promise<void>;
421
- setSharedPreferences(): Promise<boolean>;
431
+ /**
432
+ *
433
+ * @param {AndroidDriverOpts} [opts]
434
+ */
435
+ setSharedPreferences(opts: AndroidDriverOpts): Promise<boolean>;
422
436
  getPrefsBuilder(): any;
423
- validateDesiredCaps(caps: any): boolean;
424
- proxyActive(sessionId: any): boolean;
425
- getProxyAvoidList(sessionId: any): (string | RegExp)[][];
426
- canProxy(sessionId: any): boolean;
437
+ /**
438
+ *
439
+ * @param {any} caps
440
+ * @returns {caps is AndroidDriverCaps}
441
+ */
442
+ validateDesiredCaps(caps: any): caps is AndroidDriverCaps;
443
+ /**
444
+ *
445
+ * @param {string} sessionId
446
+ */
447
+ proxyActive(sessionId: string): boolean;
448
+ /**
449
+ *
450
+ * @param {string} sessionId
451
+ */
452
+ getProxyAvoidList(sessionId: string): RouteMatcher[];
453
+ /**
454
+ *
455
+ * @param {string} sessionId
456
+ */
457
+ canProxy(sessionId: string): boolean;
427
458
  }
428
- import { BaseDriver } from 'appium/driver';
429
- import { DeviceSettings } from 'appium/driver';
459
+ export { commands as androidCommands } from './commands';
460
+ export { AndroidDriver };
430
461
  //# sourceMappingURL=driver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../../lib/driver.js"],"names":[],"mappings":";AAmCA;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;M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SAAS,EAAE,MAAM;CAM3B;AAED,OAAO,EAAC,QAAQ,IAAI,eAAe,EAAC,MAAM,YAAY,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,CAAC"}
@@ -1,24 +1,26 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
5
6
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AndroidDriver = void 0;
7
- const driver_1 = require("appium/driver");
8
- const desired_caps_1 = __importDefault(require("./desired-caps"));
9
- const index_1 = __importDefault(require("./commands/index"));
10
- const method_map_1 = require("./method-map");
11
- const android_helpers_1 = require("./android-helpers");
12
- const lodash_1 = __importDefault(require("lodash"));
13
- const appium_adb_1 = require("appium-adb");
7
+ exports.AndroidDriver = exports.androidCommands = void 0;
14
8
  const support_1 = require("@appium/support");
9
+ const appium_adb_1 = require("appium-adb");
10
+ const driver_1 = require("appium/driver");
15
11
  const asyncbox_1 = require("asyncbox");
16
- const shared_preferences_builder_1 = require("shared-preferences-builder");
17
12
  const bluebird_1 = __importDefault(require("bluebird"));
13
+ const lodash_1 = __importDefault(require("lodash"));
14
+ const shared_preferences_builder_1 = require("shared-preferences-builder");
15
+ const constraints_1 = __importDefault(require("./constraints"));
16
+ const helpers_1 = require("./helpers");
17
+ const method_map_1 = require("./method-map");
18
18
  const APP_EXTENSION = '.apk';
19
19
  const DEVICE_PORT = 4724;
20
- // This is a set of methods and paths that we never want to proxy to
21
- // Chromedriver
20
+ /**
21
+ * This is a set of methods and paths that we never want to proxy to
22
+ * Chromedriver
23
+ **/
22
24
  const NO_PROXY = [
23
25
  ['POST', new RegExp('^/session/[^/]+/context')],
24
26
  ['GET', new RegExp('^/session/[^/]+/context')],
@@ -41,29 +43,25 @@ class AndroidDriver extends driver_1.BaseDriver {
41
43
  'id',
42
44
  'class name',
43
45
  'accessibility id',
44
- '-android uiautomator'
46
+ '-android uiautomator',
45
47
  ];
46
- this.desiredCapConstraints = desired_caps_1.default;
48
+ this.desiredCapConstraints = lodash_1.default.cloneDeep(constraints_1.default);
47
49
  this.sessionChromedrivers = {};
48
50
  this.jwpProxyActive = false;
49
51
  this.jwpProxyAvoid = lodash_1.default.clone(NO_PROXY);
50
52
  this.settings = new driver_1.DeviceSettings({ ignoreUnimportantViews: false }, this.onSettingsUpdate.bind(this));
51
- this.chromedriver = null;
52
53
  this.apkStrings = {};
53
- this.unlocker = android_helpers_1.helpers.unlocker;
54
- for (let [cmd, fn] of lodash_1.default.toPairs(index_1.default)) {
55
- AndroidDriver.prototype[cmd] = fn;
56
- }
57
- // needs to be after the line which assigns commands to AndroidDriver.prototype, so that `this.defaultContextName` is defined.
54
+ this.unlocker = helpers_1.helpers.unlocker;
58
55
  this.curContext = this.defaultContextName();
56
+ this.opts = opts;
59
57
  }
60
- async createSession(...args) {
58
+ async createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData) {
61
59
  // the whole createSession flow is surrounded in a try-catch statement
62
60
  // if creating a session fails at any point, we teardown everything we
63
61
  // set up before throwing the error.
64
62
  try {
65
- let [sessionId, caps] = await super.createSession(...args);
66
- let serverDetails = {
63
+ const [sessionId, caps] = (await super.createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData));
64
+ const serverDetails = {
67
65
  platform: 'LINUX',
68
66
  webStorageEnabled: false,
69
67
  takesScreenshot: true,
@@ -72,11 +70,11 @@ class AndroidDriver extends driver_1.BaseDriver {
72
70
  networkConnectionEnabled: true,
73
71
  locationContextEnabled: false,
74
72
  warnings: {},
75
- desired: this.caps
73
+ desired: this.caps,
76
74
  };
77
75
  this.caps = Object.assign(serverDetails, this.caps);
78
76
  // assigning defaults
79
- let defaultOpts = {
77
+ const defaultOpts = {
80
78
  action: 'android.intent.action.MAIN',
81
79
  category: 'android.intent.category.LAUNCHER',
82
80
  flags: '0x10200000',
@@ -88,33 +86,27 @@ class AndroidDriver extends driver_1.BaseDriver {
88
86
  bootstrapPort: DEVICE_PORT,
89
87
  androidInstallTimeout: 90000,
90
88
  };
91
- lodash_1.default.defaults(this.opts, defaultOpts);
89
+ this.opts = { ...defaultOpts, ...this.opts };
92
90
  this.useUnlockHelperApp = lodash_1.default.isUndefined(this.caps.unlockType);
93
- // not user visible via caps
94
- if (this.opts.noReset === true) {
95
- this.opts.fullReset = false;
96
- }
97
- if (this.opts.fullReset === true) {
98
- this.opts.noReset = false;
99
- }
100
- this.opts.fastReset = !this.opts.fullReset && !this.opts.noReset;
101
- this.opts.skipUninstall = this.opts.fastReset || this.opts.noReset;
102
91
  if (this.isChromeSession) {
103
- android_helpers_1.helpers.adjustBrowserSessionCaps(this.opts);
92
+ helpers_1.helpers.adjustBrowserSessionCaps(this.opts);
104
93
  }
105
94
  if (this.opts.nativeWebScreenshot) {
106
95
  this.jwpProxyAvoid.push(['GET', new RegExp('^/session/[^/]+/screenshot')]);
107
96
  }
97
+ // @ts-expect-error do not put arbitrary properties on opts
108
98
  if (this.opts.reboot) {
109
99
  this.setAvdFromCapabilities(caps);
110
100
  }
111
101
  // get device udid for this session
112
- let { udid, emPort } = await android_helpers_1.helpers.getDeviceInfoFromCaps(this.opts);
102
+ const { udid, emPort } = await helpers_1.helpers.getDeviceInfoFromCaps(this.opts);
113
103
  this.opts.udid = udid;
104
+ // @ts-expect-error do not put arbitrary properties on opts
114
105
  this.opts.emPort = emPort;
115
106
  // set up an instance of ADB
116
- this.adb = await android_helpers_1.helpers.createADB({
107
+ this.adb = await helpers_1.helpers.createADB({
117
108
  udid: this.opts.udid,
109
+ // @ts-expect-error: unknown
118
110
  emPort: this.opts.emPort,
119
111
  adbPort: this.opts.adbPort,
120
112
  suppressKillServer: this.opts.suppressKillServer,
@@ -123,14 +115,16 @@ class AndroidDriver extends driver_1.BaseDriver {
123
115
  adbExecTimeout: this.opts.adbExecTimeout,
124
116
  allowOfflineDevices: this.opts.allowOfflineDevices,
125
117
  });
126
- if (await this.adb.getApiLevel() >= 23) {
118
+ if ((await this.adb.getApiLevel()) >= 23) {
127
119
  this.log.warn("Consider setting 'automationName' capability to " +
128
120
  "'uiautomator2' on Android >= 6, since UIAutomator framework " +
129
121
  'is not maintained anymore by the OS vendor.');
130
122
  }
123
+ // @ts-expect-error no arbitrary props on opts
131
124
  if (this.helpers.isPackageOrBundle(this.opts.app)) {
132
125
  // user provided package instead of app for 'app' capability, massage options
133
126
  this.opts.appPackage = this.opts.app;
127
+ // @ts-expect-error no arbitrary props on opts
134
128
  this.opts.app = null;
135
129
  }
136
130
  if (this.opts.app) {
@@ -152,7 +146,7 @@ class AndroidDriver extends driver_1.BaseDriver {
152
146
  this.log.warn('Sorry, networkSpeed capability is only available for emulators');
153
147
  }
154
148
  else {
155
- const networkSpeed = (0, android_helpers_1.ensureNetworkSpeed)(this.adb, this.opts.networkSpeed);
149
+ const networkSpeed = (0, helpers_1.ensureNetworkSpeed)(this.adb, this.opts.networkSpeed);
156
150
  await this.adb.networkSpeed(networkSpeed);
157
151
  }
158
152
  }
@@ -180,7 +174,7 @@ class AndroidDriver extends driver_1.BaseDriver {
180
174
  }
181
175
  }
182
176
  isEmulator() {
183
- return android_helpers_1.helpers.isEmulator(this.adb, this.opts);
177
+ return helpers_1.helpers.isEmulator(this.adb, this.opts);
184
178
  }
185
179
  setAvdFromCapabilities(caps) {
186
180
  if (this.opts.avd) {
@@ -189,40 +183,51 @@ class AndroidDriver extends driver_1.BaseDriver {
189
183
  else {
190
184
  if (!caps.deviceName) {
191
185
  this.log.errorAndThrow('avd or deviceName should be specified when reboot option is enables');
186
+ throw new Error(); // unreachable
192
187
  }
193
188
  if (!caps.platformVersion) {
194
189
  this.log.errorAndThrow('avd or platformVersion should be specified when reboot option is enabled');
190
+ throw new Error(); // unreachable
195
191
  }
196
- let avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-');
192
+ const avdDevice = caps.deviceName.replace(/[^a-zA-Z0-9_.]/g, '-');
197
193
  this.opts.avd = `${avdDevice}__${caps.platformVersion}`;
198
194
  }
199
195
  }
200
196
  get appOnDevice() {
201
- return this.helpers.isPackageOrBundle(this.opts.app) || (!this.opts.app &&
202
- this.helpers.isPackageOrBundle(this.opts.appPackage));
197
+ return (
198
+ // @ts-expect-error no arbitrary props on opts
199
+ this.helpers.isPackageOrBundle(this.opts.app) ||
200
+ // @ts-expect-error no arbitrary props on opts
201
+ (!this.opts.app && this.helpers.isPackageOrBundle(this.opts.appPackage)));
203
202
  }
204
203
  get isChromeSession() {
205
- return android_helpers_1.helpers.isChromeBrowser(this.opts.browserName);
204
+ return helpers_1.helpers.isChromeBrowser(String(this.opts.browserName));
206
205
  }
207
206
  async onSettingsUpdate(key, value) {
208
207
  if (key === 'ignoreUnimportantViews') {
209
208
  await this.setCompressedLayoutHierarchy(value);
210
209
  }
211
210
  }
212
- async startAndroidSession() {
211
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
212
+ async startAndroidSession(opts) {
213
213
  this.log.info(`Starting Android session`);
214
214
  // set up the device to run on (real or emulator, etc)
215
- this.defaultIME = await android_helpers_1.helpers.initDevice(this.adb, this.opts);
215
+ this.defaultIME = (await helpers_1.helpers.initDevice(this.adb, this.opts));
216
216
  // set actual device name, udid, platform version, screen size, model and manufacturer details.
217
217
  this.caps.deviceName = this.adb.curDeviceId;
218
+ // @ts-expect-error do not put arbitrary properties on caps
218
219
  this.caps.deviceUDID = this.opts.udid;
219
220
  this.caps.platformVersion = await this.adb.getPlatformVersion();
221
+ // @ts-expect-error do not put arbitrary properties on caps
220
222
  this.caps.deviceScreenSize = await this.adb.getScreenSize();
223
+ // @ts-expect-error do not put arbitrary properties on caps
221
224
  this.caps.deviceModel = await this.adb.getModel();
225
+ // @ts-expect-error do not put arbitrary properties on caps
222
226
  this.caps.deviceManufacturer = await this.adb.getManufacturer();
223
227
  if (this.opts.disableWindowAnimation) {
224
228
  if (await this.adb.isAnimationOn()) {
225
- if (await this.adb.getApiLevel() >= 28) { // API level 28 is Android P
229
+ if ((await this.adb.getApiLevel()) >= 28) {
230
+ // API level 28 is Android P
226
231
  // Don't forget to reset the relaxing in delete session
227
232
  this.log.warn('Relaxing hidden api policy to manage animation scale');
228
233
  await this.adb.setHiddenApiPolicy('1', !!this.opts.ignoreHiddenApiPolicyError);
@@ -238,15 +243,17 @@ class AndroidDriver extends driver_1.BaseDriver {
238
243
  // set up app under test
239
244
  await this.initAUT();
240
245
  // start UiAutomator
241
- this.bootstrap = new android_helpers_1.helpers.bootstrap(this.adb, this.opts.bootstrapPort, this.opts.websocket);
242
- await this.bootstrap.start(this.opts.appPackage, this.opts.disableAndroidWatchers, this.opts.acceptSslCerts);
246
+ const bootstrap = (this.bootstrap = new helpers_1.helpers.bootstrap(this.adb, this.opts.bootstrapPort,
247
+ // @ts-expect-error do not put arbitrary properties on opts
248
+ this.opts.websocket));
249
+ await bootstrap.start(this.opts.appPackage, this.opts.disableAndroidWatchers, this.opts.acceptSslCerts);
243
250
  // handling unexpected shutdown
244
251
  (async () => {
245
252
  try {
246
- await this.bootstrap.onUnexpectedShutdown;
253
+ await bootstrap.onUnexpectedShutdown;
247
254
  }
248
255
  catch (err) {
249
- if (!this.bootstrap.ignoreUnexpectedShutdown) {
256
+ if (!bootstrap.ignoreUnexpectedShutdown) {
250
257
  await this.startUnexpectedShutdown(err);
251
258
  }
252
259
  }
@@ -257,12 +264,14 @@ class AndroidDriver extends driver_1.BaseDriver {
257
264
  else {
258
265
  this.log.info('Checking for lockscreen presence. ' +
259
266
  `This could be skipped by setting the 'appium:skipUnlock' capability to true.`);
260
- await android_helpers_1.helpers.unlock(this, this.adb, this.caps);
267
+ await helpers_1.helpers.unlock(this, this.adb, this.caps);
261
268
  }
262
269
  // Set CompressedLayoutHierarchy on the device based on current settings object
263
270
  // this has to happen _after_ bootstrap is initialized
264
271
  if (this.opts.ignoreUnimportantViews) {
265
- await this.settings.update({ ignoreUnimportantViews: this.opts.ignoreUnimportantViews });
272
+ await this.settings.update({
273
+ ignoreUnimportantViews: this.opts.ignoreUnimportantViews,
274
+ });
266
275
  }
267
276
  if (this.isChromeSession) {
268
277
  // start a chromedriver session and proxy to it
@@ -276,14 +285,15 @@ class AndroidDriver extends driver_1.BaseDriver {
276
285
  }
277
286
  if (support_1.util.hasValue(this.opts.orientation)) {
278
287
  this.log.debug(`Setting initial orientation to '${this.opts.orientation}'`);
288
+ // @ts-expect-error no arbitrary props on opts
279
289
  await this.setOrientation(this.opts.orientation);
280
290
  }
281
291
  await this.initAutoWebview();
282
292
  }
283
293
  async initAutoWebview() {
284
294
  if (this.opts.autoWebview) {
285
- let viewName = this.defaultWebviewName();
286
- let timeout = (this.opts.autoWebviewTimeout) || 2000;
295
+ const viewName = this.defaultWebviewName();
296
+ const timeout = this.opts.autoWebviewTimeout || 2000;
287
297
  this.log.info(`Setting auto webview to context '${viewName}' with timeout ${timeout}ms`);
288
298
  // try every 500ms until timeout is over
289
299
  await (0, asyncbox_1.retryInterval)(timeout / 500, 500, async () => {
@@ -295,26 +305,28 @@ class AndroidDriver extends driver_1.BaseDriver {
295
305
  // populate appPackage, appActivity, appWaitPackage, appWaitActivity,
296
306
  // and the device being used
297
307
  // in the opts and caps (so it gets back to the user on session creation)
298
- let launchInfo = await android_helpers_1.helpers.getLaunchInfo(this.adb, this.opts);
308
+ const launchInfo = await helpers_1.helpers.getLaunchInfo(this.adb, this.opts);
299
309
  Object.assign(this.opts, launchInfo);
300
310
  Object.assign(this.caps, launchInfo);
301
311
  // Uninstall any uninstallOtherPackages which were specified in caps
302
312
  if (this.opts.uninstallOtherPackages) {
303
- android_helpers_1.helpers.validateDesiredCaps(this.opts);
313
+ helpers_1.helpers.validateDesiredCaps(this.opts);
304
314
  // Only SETTINGS_HELPER_PKG_ID package is used by UIA1
305
- await android_helpers_1.helpers.uninstallOtherPackages(this.adb, android_helpers_1.helpers.parseArray(this.opts.uninstallOtherPackages), [android_helpers_1.SETTINGS_HELPER_PKG_ID]);
315
+ await helpers_1.helpers.uninstallOtherPackages(this.adb, helpers_1.helpers.parseArray(this.opts.uninstallOtherPackages), [helpers_1.SETTINGS_HELPER_PKG_ID]);
306
316
  }
307
317
  // Install any "otherApps" that were specified in caps
308
318
  if (this.opts.otherApps) {
319
+ /** @type {string[]} */
309
320
  let otherApps;
310
321
  try {
311
- otherApps = android_helpers_1.helpers.parseArray(this.opts.otherApps);
322
+ otherApps = helpers_1.helpers.parseArray(this.opts.otherApps);
312
323
  }
313
324
  catch (e) {
314
325
  this.log.errorAndThrow(`Could not parse "otherApps" capability: ${e.message}`);
326
+ return; // unreachable
315
327
  }
316
328
  otherApps = await bluebird_1.default.all(otherApps.map((app) => this.helpers.configureApp(app, APP_EXTENSION)));
317
- await android_helpers_1.helpers.installOtherApks(otherApps, this.adb, this.opts);
329
+ await helpers_1.helpers.installOtherApks(otherApps, this.adb, this.opts);
318
330
  }
319
331
  // install app
320
332
  if (!this.opts.app) {
@@ -323,15 +335,15 @@ class AndroidDriver extends driver_1.BaseDriver {
323
335
  }
324
336
  this.log.debug('No app capability. Assuming it is already on the device');
325
337
  if (this.opts.fastReset) {
326
- await android_helpers_1.helpers.resetApp(this.adb, this.opts);
338
+ await helpers_1.helpers.resetApp(this.adb, this.opts);
327
339
  }
328
340
  return;
329
341
  }
330
342
  if (!this.opts.skipUninstall) {
331
343
  await this.adb.uninstallApk(this.opts.appPackage);
332
344
  }
333
- await android_helpers_1.helpers.installApk(this.adb, this.opts);
334
- const apkStringsForLanguage = await android_helpers_1.helpers.pushStrings(this.opts.language, this.adb, this.opts);
345
+ await helpers_1.helpers.installApk(this.adb, this.opts);
346
+ const apkStringsForLanguage = await helpers_1.helpers.pushStrings(this.opts.language, this.adb, this.opts);
335
347
  if (this.opts.language) {
336
348
  this.apkStrings[this.opts.language] = apkStringsForLanguage;
337
349
  }
@@ -343,17 +355,21 @@ class AndroidDriver extends driver_1.BaseDriver {
343
355
  }
344
356
  async checkAppPresent() {
345
357
  this.log.debug('Checking whether app is actually present');
358
+ // @ts-expect-error do not put arbitrary properties on opts
346
359
  if (!(await support_1.fs.exists(this.opts.app))) {
347
360
  this.log.errorAndThrow(`Could not find app apk at ${this.opts.app}`);
348
361
  }
349
362
  }
350
363
  async checkPackagePresent() {
351
364
  this.log.debug('Checking whether package is present on the device');
352
- if (!(await this.adb.shell(['pm', 'list', 'packages', this.opts.appPackage]))) {
365
+ if (!(await this.adb.shell(['pm', 'list', 'packages', String(this.opts.appPackage)]))) {
353
366
  this.log.errorAndThrow(`Could not find package ${this.opts.appPackage} on the device`);
354
367
  }
355
368
  }
356
- // Set CompressedLayoutHierarchy on the device
369
+ /**
370
+ * Set CompressedLayoutHierarchy on the device
371
+ * @privateRemarks FIXME: unknown param type
372
+ */
357
373
  async setCompressedLayoutHierarchy(compress) {
358
374
  await this.bootstrap.sendAction('compressedLayoutHierarchy', { compressLayout: compress });
359
375
  }
@@ -365,7 +381,7 @@ class AndroidDriver extends driver_1.BaseDriver {
365
381
  }
366
382
  }
367
383
  catch (ign) { }
368
- await android_helpers_1.helpers.removeAllSessionWebSocketHandlers(this.server, this.sessionId);
384
+ await helpers_1.helpers.removeAllSessionWebSocketHandlers(this.server, this.sessionId);
369
385
  await this.mobileStopScreenStreaming();
370
386
  await super.deleteSession();
371
387
  if (this.bootstrap) {
@@ -383,7 +399,7 @@ class AndroidDriver extends driver_1.BaseDriver {
383
399
  await this.adb?.uninstallApk(this.opts.appPackage);
384
400
  }
385
401
  await this.bootstrap.shutdown();
386
- this.bootstrap = null;
402
+ this.bootstrap = undefined;
387
403
  }
388
404
  else {
389
405
  this.log.debug("Called deleteSession but bootstrap wasn't active");
@@ -398,29 +414,36 @@ class AndroidDriver extends driver_1.BaseDriver {
398
414
  this.log.info('Restoring window animation state');
399
415
  await this.adb?.setAnimationState(true);
400
416
  // This was necessary to change animation scale over Android P. We must reset the policy for the security.
401
- if (await this.adb?.getApiLevel() >= 28) {
417
+ if (this.adb && (await this.adb.getApiLevel()) >= 28) {
402
418
  this.log.info('Restoring hidden api policy to the device default configuration');
403
419
  await this.adb?.setDefaultHiddenApiPolicy(!!this.opts.ignoreHiddenApiPolicyError);
404
420
  }
405
421
  }
422
+ // @ts-expect-error do not put arbitrary properties on opts
406
423
  if (this.opts.reboot) {
407
- let avdName = this.opts.avd.replace('@', '');
424
+ // @ts-expect-error do not put arbitrary properties on opts
425
+ const avdName = this.opts.avd.replace('@', '');
408
426
  this.log.debug(`closing emulator '${avdName}'`);
409
427
  await this.adb?.killEmulator(avdName);
410
428
  }
411
429
  }
412
- async setSharedPreferences() {
413
- let sharedPrefs = this.opts.sharedPreferences;
430
+ /**
431
+ *
432
+ * @param {AndroidDriverOpts} [opts]
433
+ */
434
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
435
+ async setSharedPreferences(opts) {
436
+ const sharedPrefs = this.opts.sharedPreferences;
414
437
  this.log.info('Trying to set shared preferences');
415
- let name = sharedPrefs.name;
438
+ const name = sharedPrefs.name;
416
439
  if (lodash_1.default.isUndefined(name)) {
417
440
  this.log.warn(`Skipping setting Shared preferences, name is undefined: ${JSON.stringify(sharedPrefs)}`);
418
441
  return false;
419
442
  }
420
- let remotePath = `/data/data/${this.opts.appPackage}/shared_prefs`;
421
- let remoteFile = `${remotePath}/${name}.xml`;
422
- let localPath = `/tmp/${name}.xml`;
423
- let builder = this.getPrefsBuilder();
443
+ const remotePath = `/data/data/${this.opts.appPackage}/shared_prefs`;
444
+ const remoteFile = `${remotePath}/${name}.xml`;
445
+ const localPath = `/tmp/${name}.xml`;
446
+ const builder = this.getPrefsBuilder();
424
447
  builder.build(sharedPrefs.prefs);
425
448
  this.log.info(`Creating temporary shared preferences: ${localPath}`);
426
449
  builder.toFile(localPath);
@@ -442,26 +465,45 @@ class AndroidDriver extends driver_1.BaseDriver {
442
465
  getPrefsBuilder() {
443
466
  /* Add this method to create a new SharedPrefsBuilder instead of
444
467
  * directly creating the object on setSharedPreferences for testing purposes
445
- */
468
+ */
446
469
  return new shared_preferences_builder_1.SharedPrefsBuilder();
447
470
  }
471
+ /**
472
+ *
473
+ * @param {any} caps
474
+ * @returns {caps is AndroidDriverCaps}
475
+ */
448
476
  validateDesiredCaps(caps) {
449
477
  if (!super.validateDesiredCaps(caps)) {
450
478
  return false;
451
479
  }
452
- if ((!caps.browserName || !android_helpers_1.helpers.isChromeBrowser(caps.browserName)) && !caps.app && !caps.appPackage) {
480
+ if ((!caps.browserName || !helpers_1.helpers.isChromeBrowser(caps.browserName)) &&
481
+ !caps.app &&
482
+ !caps.appPackage) {
453
483
  this.log.errorAndThrow('The desired capabilities must include either an app, appPackage or browserName');
454
484
  }
455
- return android_helpers_1.helpers.validateDesiredCaps(caps);
485
+ return helpers_1.helpers.validateDesiredCaps(caps);
456
486
  }
487
+ /**
488
+ *
489
+ * @param {string} sessionId
490
+ */
457
491
  proxyActive(sessionId) {
458
492
  super.proxyActive(sessionId);
459
493
  return this.jwpProxyActive;
460
494
  }
495
+ /**
496
+ *
497
+ * @param {string} sessionId
498
+ */
461
499
  getProxyAvoidList(sessionId) {
462
500
  super.getProxyAvoidList(sessionId);
463
501
  return this.jwpProxyAvoid;
464
502
  }
503
+ /**
504
+ *
505
+ * @param {string} sessionId
506
+ */
465
507
  canProxy(sessionId) {
466
508
  super.canProxy(sessionId);
467
509
  // this will change depending on ChromeDriver status
@@ -470,5 +512,6 @@ class AndroidDriver extends driver_1.BaseDriver {
470
512
  }
471
513
  exports.AndroidDriver = AndroidDriver;
472
514
  AndroidDriver.newMethodMap = method_map_1.newMethodMap;
473
- exports.default = AndroidDriver;
515
+ var commands_1 = require("./commands");
516
+ Object.defineProperty(exports, "androidCommands", { enumerable: true, get: function () { return commands_1.commands; } });
474
517
  //# sourceMappingURL=driver.js.map