appium-adb 14.3.1 → 14.3.2

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 (92) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/lib/helpers.d.ts +2 -2
  3. package/build/lib/helpers.d.ts.map +1 -1
  4. package/build/lib/helpers.js +5 -5
  5. package/build/lib/helpers.js.map +1 -1
  6. package/build/lib/index.d.ts +8 -0
  7. package/build/lib/index.d.ts.map +1 -0
  8. package/build/{index.js → lib/index.js} +4 -4
  9. package/build/lib/index.js.map +1 -0
  10. package/build/lib/tools/aab-utils.d.ts +2 -2
  11. package/build/lib/tools/aab-utils.d.ts.map +1 -1
  12. package/build/lib/tools/aab-utils.js +10 -10
  13. package/build/lib/tools/aab-utils.js.map +1 -1
  14. package/build/lib/tools/android-manifest.d.ts +2 -2
  15. package/build/lib/tools/android-manifest.d.ts.map +1 -1
  16. package/build/lib/tools/android-manifest.js +27 -27
  17. package/build/lib/tools/android-manifest.js.map +1 -1
  18. package/build/lib/tools/apk-signing.d.ts +2 -2
  19. package/build/lib/tools/apk-signing.d.ts.map +1 -1
  20. package/build/lib/tools/apk-signing.js +34 -34
  21. package/build/lib/tools/apk-signing.js.map +1 -1
  22. package/build/lib/tools/apk-utils.d.ts +2 -2
  23. package/build/lib/tools/apk-utils.d.ts.map +1 -1
  24. package/build/lib/tools/apk-utils.js +50 -50
  25. package/build/lib/tools/apk-utils.js.map +1 -1
  26. package/build/lib/tools/apks-utils.d.ts +2 -2
  27. package/build/lib/tools/apks-utils.d.ts.map +1 -1
  28. package/build/lib/tools/apks-utils.js +18 -18
  29. package/build/lib/tools/apks-utils.js.map +1 -1
  30. package/build/lib/tools/app-commands.d.ts +2 -2
  31. package/build/lib/tools/app-commands.d.ts.map +1 -1
  32. package/build/lib/tools/app-commands.js +36 -36
  33. package/build/lib/tools/app-commands.js.map +1 -1
  34. package/build/lib/tools/device-settings.d.ts +2 -2
  35. package/build/lib/tools/device-settings.d.ts.map +1 -1
  36. package/build/lib/tools/device-settings.js +15 -15
  37. package/build/lib/tools/device-settings.js.map +1 -1
  38. package/build/lib/tools/emulator-commands.d.ts +2 -2
  39. package/build/lib/tools/emulator-commands.d.ts.map +1 -1
  40. package/build/lib/tools/emulator-commands.js +7 -7
  41. package/build/lib/tools/emulator-commands.js.map +1 -1
  42. package/build/lib/tools/fs-commands.d.ts +1 -1
  43. package/build/lib/tools/fs-commands.d.ts.map +1 -1
  44. package/build/lib/tools/general-commands.d.ts +2 -2
  45. package/build/lib/tools/general-commands.d.ts.map +1 -1
  46. package/build/lib/tools/general-commands.js +7 -7
  47. package/build/lib/tools/general-commands.js.map +1 -1
  48. package/build/lib/tools/keyboard-commands.d.ts +2 -2
  49. package/build/lib/tools/keyboard-commands.d.ts.map +1 -1
  50. package/build/lib/tools/keyboard-commands.js +3 -3
  51. package/build/lib/tools/keyboard-commands.js.map +1 -1
  52. package/build/lib/tools/lockmgmt.d.ts +1 -1
  53. package/build/lib/tools/lockmgmt.d.ts.map +1 -1
  54. package/build/lib/tools/lockmgmt.js +8 -8
  55. package/build/lib/tools/lockmgmt.js.map +1 -1
  56. package/build/lib/tools/logcat-commands.d.ts +2 -2
  57. package/build/lib/tools/logcat-commands.d.ts.map +1 -1
  58. package/build/lib/tools/network-commands.d.ts +2 -2
  59. package/build/lib/tools/network-commands.d.ts.map +1 -1
  60. package/build/lib/tools/network-commands.js +10 -10
  61. package/build/lib/tools/network-commands.js.map +1 -1
  62. package/build/lib/tools/process-commands.d.ts +1 -1
  63. package/build/lib/tools/process-commands.d.ts.map +1 -1
  64. package/build/lib/tools/process-commands.js +10 -10
  65. package/build/lib/tools/process-commands.js.map +1 -1
  66. package/build/lib/tools/system-calls.d.ts +2 -2
  67. package/build/lib/tools/system-calls.d.ts.map +1 -1
  68. package/build/lib/tools/system-calls.js +72 -72
  69. package/build/lib/tools/system-calls.js.map +1 -1
  70. package/lib/helpers.ts +3 -3
  71. package/lib/index.ts +8 -0
  72. package/lib/tools/aab-utils.ts +4 -4
  73. package/lib/tools/android-manifest.ts +4 -4
  74. package/lib/tools/apk-signing.ts +4 -4
  75. package/lib/tools/apk-utils.ts +4 -4
  76. package/lib/tools/apks-utils.ts +4 -4
  77. package/lib/tools/app-commands.ts +3 -3
  78. package/lib/tools/device-settings.ts +3 -3
  79. package/lib/tools/emulator-commands.ts +3 -3
  80. package/lib/tools/fs-commands.ts +1 -1
  81. package/lib/tools/general-commands.ts +3 -3
  82. package/lib/tools/keyboard-commands.ts +3 -3
  83. package/lib/tools/lockmgmt.ts +2 -2
  84. package/lib/tools/logcat-commands.ts +2 -2
  85. package/lib/tools/network-commands.ts +3 -3
  86. package/lib/tools/process-commands.ts +2 -2
  87. package/lib/tools/system-calls.ts +4 -4
  88. package/package.json +4 -6
  89. package/build/index.d.ts +0 -8
  90. package/build/index.d.ts.map +0 -1
  91. package/build/index.js.map +0 -1
  92. package/index.ts +0 -8
@@ -74,10 +74,10 @@ exports.isMitmCertificateInstalled = isMitmCertificateInstalled;
74
74
  exports.shellChunks = shellChunks;
75
75
  exports.toAvdLocaleArgs = toAvdLocaleArgs;
76
76
  const node_path_1 = __importDefault(require("node:path"));
77
- const logger_js_1 = require("../logger.js");
77
+ const logger_1 = require("../logger");
78
78
  const bluebird_1 = __importDefault(require("bluebird"));
79
79
  const support_1 = require("@appium/support");
80
- const helpers_js_1 = require("../helpers.js");
80
+ const helpers_1 = require("../helpers");
81
81
  const teen_process_1 = require("teen_process");
82
82
  const asyncbox_1 = require("asyncbox");
83
83
  const lodash_1 = __importDefault(require("lodash"));
@@ -180,10 +180,10 @@ async function getBinaryFromSdkRoot(binaryName) {
180
180
  if (this.buildToolsVersion) {
181
181
  buildToolsDirs = buildToolsDirs.filter((x) => node_path_1.default.basename(x) === this.buildToolsVersion);
182
182
  if (lodash_1.default.isEmpty(buildToolsDirs)) {
183
- logger_js_1.log.info(`Found no build tools whose version matches to '${this.buildToolsVersion}'`);
183
+ logger_1.log.info(`Found no build tools whose version matches to '${this.buildToolsVersion}'`);
184
184
  }
185
185
  else {
186
- logger_js_1.log.info(`Using build tools at '${buildToolsDirs}'`);
186
+ logger_1.log.info(`Using build tools at '${buildToolsDirs}'`);
187
187
  }
188
188
  }
189
189
  binaryLocs.push(...lodash_1.default.flatten(buildToolsDirs.map((dir) => [
@@ -202,7 +202,7 @@ async function getBinaryFromSdkRoot(binaryName) {
202
202
  `Do you have Android Build Tools ${this.buildToolsVersion ? `v ${this.buildToolsVersion} ` : ''}` +
203
203
  `installed at '${this.sdkRoot}'?`);
204
204
  }
205
- logger_js_1.log.info(`Using '${fullBinaryName}' from '${binaryLoc}'`);
205
+ logger_1.log.info(`Using '${fullBinaryName}' from '${binaryLoc}'`);
206
206
  if (!this.binaries) {
207
207
  this.binaries = {};
208
208
  }
@@ -219,7 +219,7 @@ async function getBinaryFromSdkRoot(binaryName) {
219
219
  */
220
220
  async function getAndroidBinaryPath(binaryName) {
221
221
  const fullBinaryName = (0, exports.getBinaryNameForOS)(binaryName);
222
- const sdkRoot = (0, helpers_js_1.getSdkRootFromEnv)();
222
+ const sdkRoot = (0, helpers_1.getSdkRootFromEnv)();
223
223
  const binaryLocs = getSdkBinaryLocationCandidates(sdkRoot ?? '', fullBinaryName);
224
224
  for (const loc of binaryLocs) {
225
225
  if (await support_1.fs.exists(loc)) {
@@ -243,7 +243,7 @@ async function getBinaryFromPath(binaryName) {
243
243
  const fullBinaryName = this.getBinaryNameForOS(binaryName);
244
244
  try {
245
245
  const binaryLoc = await support_1.fs.which(fullBinaryName);
246
- logger_js_1.log.info(`Using '${fullBinaryName}' from '${binaryLoc}'`);
246
+ logger_1.log.info(`Using '${fullBinaryName}' from '${binaryLoc}'`);
247
247
  if (!this.binaries) {
248
248
  this.binaries = {};
249
249
  }
@@ -263,7 +263,7 @@ async function getBinaryFromPath(binaryName) {
263
263
  * @throws {Error} If adb devices command fails or returns unexpected output
264
264
  */
265
265
  async function getConnectedDevices(opts = {}) {
266
- logger_js_1.log.debug('Getting connected devices');
266
+ logger_1.log.debug('Getting connected devices');
267
267
  const args = [...this.executable.defaultArgs, 'devices'];
268
268
  if (opts.verbose) {
269
269
  args.push('-l');
@@ -310,10 +310,10 @@ async function getConnectedDevices(opts = {}) {
310
310
  return device;
311
311
  });
312
312
  if (lodash_1.default.isEmpty(devices)) {
313
- logger_js_1.log.debug('No connected devices have been detected');
313
+ logger_1.log.debug('No connected devices have been detected');
314
314
  }
315
315
  else {
316
- logger_js_1.log.debug(`Connected devices: ${JSON.stringify(devices)}`);
316
+ logger_1.log.debug(`Connected devices: ${JSON.stringify(devices)}`);
317
317
  }
318
318
  return devices;
319
319
  }
@@ -325,7 +325,7 @@ async function getConnectedDevices(opts = {}) {
325
325
  * @throws {Error} If no devices are found within the timeout period
326
326
  */
327
327
  async function getDevicesWithRetry(timeoutMs = 20000) {
328
- logger_js_1.log.debug('Trying to find connected Android devices');
328
+ logger_1.log.debug('Trying to find connected Android devices');
329
329
  try {
330
330
  let devices = [];
331
331
  await (0, asyncbox_1.waitForCondition)(async () => {
@@ -334,12 +334,12 @@ async function getDevicesWithRetry(timeoutMs = 20000) {
334
334
  if (devices.length) {
335
335
  return true;
336
336
  }
337
- logger_js_1.log.debug('Could not find online devices');
337
+ logger_1.log.debug('Could not find online devices');
338
338
  }
339
339
  catch (err) {
340
340
  const error = err;
341
- logger_js_1.log.debug(error.stack);
342
- logger_js_1.log.warn(`Got an unexpected error while fetching connected devices list: ${error.message}`);
341
+ logger_1.log.debug(error.stack);
342
+ logger_1.log.warn(`Got an unexpected error while fetching connected devices list: ${error.message}`);
343
343
  }
344
344
  try {
345
345
  await this.reconnect();
@@ -371,7 +371,7 @@ async function getDevicesWithRetry(timeoutMs = 20000) {
371
371
  * @throws {Error} If reconnect command fails
372
372
  */
373
373
  async function reconnect(target = 'offline') {
374
- logger_js_1.log.debug(`Reconnecting adb (target ${target})`);
374
+ logger_1.log.debug(`Reconnecting adb (target ${target})`);
375
375
  const args = ['reconnect'];
376
376
  if (target) {
377
377
  args.push(target);
@@ -389,23 +389,23 @@ async function reconnect(target = 'offline') {
389
389
  */
390
390
  async function restartAdb() {
391
391
  if (this.suppressKillServer) {
392
- logger_js_1.log.debug(`Not restarting abd since 'suppressKillServer' is on`);
392
+ logger_1.log.debug(`Not restarting abd since 'suppressKillServer' is on`);
393
393
  return;
394
394
  }
395
- logger_js_1.log.debug('Restarting adb');
395
+ logger_1.log.debug('Restarting adb');
396
396
  try {
397
397
  await this.killServer();
398
398
  await this.adbExec(['start-server']);
399
399
  }
400
400
  catch {
401
- logger_js_1.log.error(`Error killing ADB server, going to see if it's online anyway`);
401
+ logger_1.log.error(`Error killing ADB server, going to see if it's online anyway`);
402
402
  }
403
403
  }
404
404
  /**
405
405
  * Kill adb server.
406
406
  */
407
407
  async function killServer() {
408
- logger_js_1.log.debug(`Killing adb server on port '${this.adbPort}'`);
408
+ logger_1.log.debug(`Killing adb server on port '${this.adbPort}'`);
409
409
  await this.adbExec(['kill-server'], {
410
410
  exclusive: true,
411
411
  });
@@ -421,17 +421,17 @@ exports.resetTelnetAuthToken = lodash_1.default.memoize(async function resetTeln
421
421
  //
422
422
  const homeFolderPath = process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'];
423
423
  if (!homeFolderPath) {
424
- logger_js_1.log.warn(`Cannot find the path to user home folder. Ignoring resetting of emulator's telnet authentication token`);
424
+ logger_1.log.warn(`Cannot find the path to user home folder. Ignoring resetting of emulator's telnet authentication token`);
425
425
  return false;
426
426
  }
427
427
  const dstPath = node_path_1.default.resolve(homeFolderPath, '.emulator_console_auth_token');
428
- logger_js_1.log.debug(`Overriding ${dstPath} with an empty string to avoid telnet authentication for emulator commands`);
428
+ logger_1.log.debug(`Overriding ${dstPath} with an empty string to avoid telnet authentication for emulator commands`);
429
429
  try {
430
430
  await support_1.fs.writeFile(dstPath, '');
431
431
  }
432
432
  catch (e) {
433
433
  const error = e;
434
- logger_js_1.log.warn(`Error ${error.message} while resetting the content of ${dstPath}. Ignoring resetting of emulator's telnet authentication token`);
434
+ logger_1.log.warn(`Error ${error.message} while resetting the content of ${dstPath}. Ignoring resetting of emulator's telnet authentication token`);
435
435
  return false;
436
436
  }
437
437
  return true;
@@ -466,7 +466,7 @@ async function adbExec(cmd, opts) {
466
466
  }
467
467
  const optsCopy = lodash_1.default.cloneDeep(opts ?? {});
468
468
  // setting default timeout for each command to prevent infinite wait.
469
- optsCopy.timeout = optsCopy.timeout || this.adbExecTimeout || helpers_js_1.DEFAULT_ADB_EXEC_TIMEOUT;
469
+ optsCopy.timeout = optsCopy.timeout || this.adbExecTimeout || helpers_1.DEFAULT_ADB_EXEC_TIMEOUT;
470
470
  optsCopy.timeoutCapName = optsCopy.timeoutCapName || 'adbExecTimeout'; // For error message
471
471
  const { outputFormat = this.EXEC_OUTPUT_FORMAT.STDOUT } = optsCopy;
472
472
  cmd = lodash_1.default.isArray(cmd) ? cmd : [cmd];
@@ -474,7 +474,7 @@ async function adbExec(cmd, opts) {
474
474
  const execFunc = async () => {
475
475
  try {
476
476
  const args = [...this.executable.defaultArgs, ...cmd];
477
- logger_js_1.log.debug(`Running '${this.executable.path} ` +
477
+ logger_1.log.debug(`Running '${this.executable.path} ` +
478
478
  (args.find((arg) => /\s+/.test(arg)) ? support_1.util.quote(args) : args.join(' ')) +
479
479
  `'`);
480
480
  const { stdout: rawStdout, stderr } = (await (0, teen_process_1.exec)(this.executable.path, args, optsCopy));
@@ -487,7 +487,7 @@ async function adbExec(cmd, opts) {
487
487
  const error = e;
488
488
  const errText = `${error.message}, ${error.stdout}, ${error.stderr}`;
489
489
  if (ADB_RETRY_ERROR_PATTERNS.some((p) => p.test(errText))) {
490
- logger_js_1.log.info(`Error sending command, reconnecting device and retrying: ${cmd}`);
490
+ logger_1.log.info(`Error sending command, reconnecting device and retrying: ${cmd}`);
491
491
  await this.getDevicesWithRetry();
492
492
  // try again one time
493
493
  if (!adbRetried) {
@@ -513,12 +513,12 @@ async function adbExec(cmd, opts) {
513
513
  }
514
514
  };
515
515
  if (isExecLocked) {
516
- logger_js_1.log.debug('Waiting until the other exclusive ADB command is completed');
516
+ logger_1.log.debug('Waiting until the other exclusive ADB command is completed');
517
517
  await (0, asyncbox_1.waitForCondition)(() => !isExecLocked, {
518
518
  waitMs: Number.MAX_SAFE_INTEGER,
519
519
  intervalMs: 10,
520
520
  });
521
- logger_js_1.log.debug('Continuing with the current ADB command');
521
+ logger_1.log.debug('Continuing with the current ADB command');
522
522
  }
523
523
  if (optsCopy.exclusive) {
524
524
  isExecLocked = true;
@@ -545,9 +545,9 @@ async function shell(cmd, opts) {
545
545
  const cmdArr = lodash_1.default.isArray(cmd) ? cmd : [cmd];
546
546
  const fullCmd = ['shell'];
547
547
  if (privileged) {
548
- logger_js_1.log.info(`'adb shell ${support_1.util.quote(cmdArr)}' requires root access`);
548
+ logger_1.log.info(`'adb shell ${support_1.util.quote(cmdArr)}' requires root access`);
549
549
  if (await this.isRoot()) {
550
- logger_js_1.log.info('The device already had root access');
550
+ logger_1.log.info('The device already had root access');
551
551
  fullCmd.push(...cmdArr);
552
552
  }
553
553
  else {
@@ -568,7 +568,7 @@ async function shell(cmd, opts) {
568
568
  function createSubProcess(args = []) {
569
569
  // add the default arguments
570
570
  const finalArgs = [...this.executable.defaultArgs, ...args];
571
- logger_js_1.log.debug(`Creating ADB subprocess with args: ${JSON.stringify(finalArgs)}`);
571
+ logger_1.log.debug(`Creating ADB subprocess with args: ${JSON.stringify(finalArgs)}`);
572
572
  return new teen_process_1.SubProcess(this.getAdbPath(), finalArgs);
573
573
  }
574
574
  /**
@@ -588,7 +588,7 @@ function getAdbServerPort() {
588
588
  * @throws {Error} If no devices are connected or emulator port cannot be found
589
589
  */
590
590
  async function getEmulatorPort() {
591
- logger_js_1.log.debug('Getting running emulator port');
591
+ logger_1.log.debug('Getting running emulator port');
592
592
  if (!lodash_1.default.isNil(this.emulatorPort)) {
593
593
  return this.emulatorPort;
594
594
  }
@@ -626,7 +626,7 @@ function getPortFromEmulatorString(emStr) {
626
626
  * @throws {Error} If error occurs while getting emulators
627
627
  */
628
628
  async function getConnectedEmulators(opts = {}) {
629
- logger_js_1.log.debug('Getting connected emulators');
629
+ logger_1.log.debug('Getting connected emulators');
630
630
  try {
631
631
  const devices = await this.getConnectedDevices(opts);
632
632
  const emulators = [];
@@ -637,7 +637,7 @@ async function getConnectedEmulators(opts = {}) {
637
637
  emulators.push(device);
638
638
  }
639
639
  }
640
- logger_js_1.log.debug(`${support_1.util.pluralize('emulator', emulators.length, true)} connected`);
640
+ logger_1.log.debug(`${support_1.util.pluralize('emulator', emulators.length, true)} connected`);
641
641
  return emulators;
642
642
  }
643
643
  catch (e) {
@@ -659,7 +659,7 @@ function setEmulatorPort(emPort) {
659
659
  * @param deviceId - The device identifier
660
660
  */
661
661
  function setDeviceId(deviceId) {
662
- logger_js_1.log.debug(`Setting device id to ${deviceId}`);
662
+ logger_1.log.debug(`Setting device id to ${deviceId}`);
663
663
  this.curDeviceId = deviceId;
664
664
  const argsHasDevice = this.executable.defaultArgs.indexOf('-s');
665
665
  if (argsHasDevice !== -1) {
@@ -692,7 +692,7 @@ function setDevice(deviceObj) {
692
692
  * @throws {Error} If error occurs while getting AVD
693
693
  */
694
694
  async function getRunningAVD(avdName) {
695
- logger_js_1.log.debug(`Trying to find '${avdName}' emulator`);
695
+ logger_1.log.debug(`Trying to find '${avdName}' emulator`);
696
696
  try {
697
697
  const emulators = await this.getConnectedEmulators();
698
698
  for (const emulator of emulators) {
@@ -705,12 +705,12 @@ async function getRunningAVD(avdName) {
705
705
  connTimeout: 1000,
706
706
  });
707
707
  if (lodash_1.default.toLower(avdName) === lodash_1.default.toLower(runningAVDName.trim())) {
708
- logger_js_1.log.debug(`Found emulator '${avdName}' on port ${emulator.port}`);
708
+ logger_1.log.debug(`Found emulator '${avdName}' on port ${emulator.port}`);
709
709
  this.setDeviceId(emulator.udid);
710
710
  return emulator;
711
711
  }
712
712
  }
713
- logger_js_1.log.debug(`Emulator '${avdName}' not running`);
713
+ logger_1.log.debug(`Emulator '${avdName}' not running`);
714
714
  return null;
715
715
  }
716
716
  catch (e) {
@@ -734,7 +734,7 @@ async function getRunningAVDWithRetry(avdName, timeoutMs = 20000) {
734
734
  }
735
735
  catch (e) {
736
736
  const error = e;
737
- logger_js_1.log.debug(error.message);
737
+ logger_1.log.debug(error.message);
738
738
  return false;
739
739
  }
740
740
  }, {
@@ -782,23 +782,23 @@ async function killAllEmulators() {
782
782
  */
783
783
  async function killEmulator(avdName = null, timeout = 60000) {
784
784
  if (support_1.util.hasValue(avdName)) {
785
- logger_js_1.log.debug(`Killing avd '${avdName}'`);
785
+ logger_1.log.debug(`Killing avd '${avdName}'`);
786
786
  const device = await this.getRunningAVD(avdName);
787
787
  if (!device) {
788
- logger_js_1.log.info(`No avd with name '${avdName}' running. Skipping kill step.`);
788
+ logger_1.log.info(`No avd with name '${avdName}' running. Skipping kill step.`);
789
789
  return false;
790
790
  }
791
791
  }
792
792
  else {
793
793
  // killing the current avd
794
- logger_js_1.log.debug(`Killing avd with id '${this.curDeviceId}'`);
794
+ logger_1.log.debug(`Killing avd with id '${this.curDeviceId}'`);
795
795
  if (!(await this.isEmulatorConnected())) {
796
- logger_js_1.log.debug(`Emulator with id '${this.curDeviceId}' not connected. Skipping kill step`);
796
+ logger_1.log.debug(`Emulator with id '${this.curDeviceId}' not connected. Skipping kill step`);
797
797
  return false;
798
798
  }
799
799
  }
800
800
  await this.adbExec(['emu', 'kill']);
801
- logger_js_1.log.debug(`Waiting up to ${timeout}ms until the emulator '${avdName ? avdName : this.curDeviceId}' is killed`);
801
+ logger_1.log.debug(`Waiting up to ${timeout}ms until the emulator '${avdName ? avdName : this.curDeviceId}' is killed`);
802
802
  try {
803
803
  await (0, asyncbox_1.waitForCondition)(async () => {
804
804
  try {
@@ -817,7 +817,7 @@ async function killEmulator(avdName = null, timeout = 60000) {
817
817
  catch {
818
818
  throw new Error(`The emulator '${avdName ? avdName : this.curDeviceId}' is still running after being killed ${timeout}ms ago`);
819
819
  }
820
- logger_js_1.log.info(`Successfully killed the '${avdName ? avdName : this.curDeviceId}' emulator`);
820
+ logger_1.log.info(`Successfully killed the '${avdName ? avdName : this.curDeviceId}' emulator`);
821
821
  return true;
822
822
  }
823
823
  /**
@@ -830,7 +830,7 @@ async function killEmulator(avdName = null, timeout = 60000) {
830
830
  */
831
831
  async function launchAVD(avdName, opts = {}) {
832
832
  const { args = [], env = {}, language, country, launchTimeout = 60000, readyTimeout = 60000, retryTimes = 1, } = opts;
833
- logger_js_1.log.debug(`Launching Emulator with AVD ${avdName}, launchTimeout ` +
833
+ logger_1.log.debug(`Launching Emulator with AVD ${avdName}, launchTimeout ` +
834
834
  `${launchTimeout}ms and readyTimeout ${readyTimeout}ms`);
835
835
  const emulatorBinaryPath = await this.getSdkBinaryPath('emulator');
836
836
  let processedAvdName = avdName;
@@ -859,30 +859,30 @@ async function launchAVD(avdName, opts = {}) {
859
859
  }
860
860
  catch (e) {
861
861
  const error = e;
862
- logger_js_1.log.info(`The -delay-adb emulator startup detection feature will not be enabled. ` +
862
+ logger_1.log.info(`The -delay-adb emulator startup detection feature will not be enabled. ` +
863
863
  `Original error: ${error.message}`);
864
864
  }
865
865
  }
866
866
  }
867
867
  else {
868
- logger_js_1.log.info('The -delay-adb emulator startup detection feature has been explicitly disabled');
868
+ logger_1.log.info('The -delay-adb emulator startup detection feature has been explicitly disabled');
869
869
  }
870
870
  if (!lodash_1.default.isEmpty(args)) {
871
871
  launchArgs.push(...(lodash_1.default.isArray(args) ? args : support_1.util.shellParse(`${args}`)));
872
872
  }
873
- logger_js_1.log.debug(`Running '${emulatorBinaryPath}' with args: ${support_1.util.quote(launchArgs)}`);
873
+ logger_1.log.debug(`Running '${emulatorBinaryPath}' with args: ${support_1.util.quote(launchArgs)}`);
874
874
  if (!lodash_1.default.isEmpty(env)) {
875
- logger_js_1.log.debug(`Customized emulator environment: ${JSON.stringify(env)}`);
875
+ logger_1.log.debug(`Customized emulator environment: ${JSON.stringify(env)}`);
876
876
  }
877
877
  const proc = new teen_process_1.SubProcess(emulatorBinaryPath, launchArgs, {
878
878
  env: { ...process.env, ...env },
879
879
  });
880
880
  await proc.start(0);
881
881
  for (const streamName of ['stderr', 'stdout']) {
882
- proc.on(`line-${streamName}`, (line) => logger_js_1.log.debug(`[AVD OUTPUT] ${line}`));
882
+ proc.on(`line-${streamName}`, (line) => logger_1.log.debug(`[AVD OUTPUT] ${line}`));
883
883
  }
884
884
  proc.on('die', (code, signal) => {
885
- logger_js_1.log.warn(`Emulator avd ${processedAvdName} exited with code ${code}${signal ? `, signal ${signal}` : ''}`);
885
+ logger_1.log.warn(`Emulator avd ${processedAvdName} exited with code ${code}${signal ? `, signal ${signal}` : ''}`);
886
886
  });
887
887
  await (0, asyncbox_1.retry)(retryTimes, async () => await this.getRunningAVDWithRetry(processedAvdName, launchTimeout));
888
888
  // At this point we have deviceId already assigned
@@ -937,7 +937,7 @@ exports.getVersion = lodash_1.default.memoize(async function getVersion() {
937
937
  * @throws {Error} If emulator is not ready within the timeout period
938
938
  */
939
939
  async function waitForEmulatorReady(timeoutMs = 20000) {
940
- logger_js_1.log.debug(`Waiting up to ${timeoutMs}ms for the emulator to be ready`);
940
+ logger_1.log.debug(`Waiting up to ${timeoutMs}ms for the emulator to be ready`);
941
941
  const requiredServicesRe = REQUIRED_SERVICES.map((name) => new RegExp(`\\b${name}:`));
942
942
  let services;
943
943
  const timer = new support_1.timing.Timer().start();
@@ -949,7 +949,7 @@ async function waitForEmulatorReady(timeoutMs = 20000) {
949
949
  isFirstCheck = false;
950
950
  }
951
951
  else {
952
- logger_js_1.log.debug(`${timer.getDuration().asMilliSeconds.toFixed(0)}ms elapsed since ` +
952
+ logger_1.log.debug(`${timer.getDuration().asMilliSeconds.toFixed(0)}ms elapsed since ` +
953
953
  `emulator readiness check has started`);
954
954
  }
955
955
  try {
@@ -959,7 +959,7 @@ async function waitForEmulatorReady(timeoutMs = 20000) {
959
959
  this.shell(['getprop', 'init.svc.bootanim']),
960
960
  ]);
961
961
  if (bootCompleted.trim() !== '1' || !['stopped', ''].includes(bootAnimState.trim())) {
962
- logger_js_1.log.debug(`Current status: sys.boot_completed=${bootCompleted.trim()}, ` +
962
+ logger_1.log.debug(`Current status: sys.boot_completed=${bootCompleted.trim()}, ` +
963
963
  `init.svc.bootanim=${bootAnimState.trim()}`);
964
964
  return false;
965
965
  }
@@ -969,14 +969,14 @@ async function waitForEmulatorReady(timeoutMs = 20000) {
969
969
  services = servicesOutput;
970
970
  if (!servicesOutput ||
971
971
  !requiredServicesRe.every((pattern) => pattern.test(servicesOutput))) {
972
- logger_js_1.log.debug(`Running services: ${servicesOutput}`);
972
+ logger_1.log.debug(`Running services: ${servicesOutput}`);
973
973
  return false;
974
974
  }
975
975
  return true;
976
976
  }
977
977
  catch (err) {
978
978
  const error = err;
979
- logger_js_1.log.debug(`Intermediate error: ${error.message}`);
979
+ logger_1.log.debug(`Intermediate error: ${error.message}`);
980
980
  return false;
981
981
  }
982
982
  }, {
@@ -998,7 +998,7 @@ async function waitForEmulatorReady(timeoutMs = 20000) {
998
998
  const elapsedMs = timer.getDuration().asMilliSeconds;
999
999
  // Only log if the wait took a noticeable amount of time
1000
1000
  if (elapsedMs > 100) {
1001
- logger_js_1.log.info(`Emulator is ready after ${elapsedMs}ms`);
1001
+ logger_1.log.info(`Emulator is ready after ${elapsedMs}ms`);
1002
1002
  }
1003
1003
  }
1004
1004
  /**
@@ -1088,7 +1088,7 @@ async function reboot(retries = DEFAULT_ADB_REBOOT_RETRIES) {
1088
1088
  }
1089
1089
  const msg = `Reboot is not completed after ${timer.getDuration().asMilliSeconds.toFixed(0)}ms`;
1090
1090
  // we don't want the stack trace
1091
- logger_js_1.log.debug(msg);
1091
+ logger_1.log.debug(msg);
1092
1092
  throw new Error(msg);
1093
1093
  });
1094
1094
  }
@@ -1109,7 +1109,7 @@ async function changeUserPrivileges(isElevated) {
1109
1109
  // Check the output of the stdErr to see if there's any clues that show that the device went offline
1110
1110
  // and if it did go offline, restart ADB
1111
1111
  if (['closed', 'device offline', 'timeout expired'].some((x) => (error.stderr || '').toLowerCase().includes(x))) {
1112
- logger_js_1.log.warn(`Attempt to ${cmd} caused ADB to think the device went offline`);
1112
+ logger_1.log.warn(`Attempt to ${cmd} caused ADB to think the device went offline`);
1113
1113
  try {
1114
1114
  await this.reconnect();
1115
1115
  }
@@ -1131,7 +1131,7 @@ async function changeUserPrivileges(isElevated) {
1131
1131
  let wasAlreadyRooted = isRoot;
1132
1132
  try {
1133
1133
  const { stdout } = await retryIfOffline(async () => await this.adbExec([cmd]));
1134
- logger_js_1.log.debug(stdout);
1134
+ logger_1.log.debug(stdout);
1135
1135
  // on real devices in some situations we get an error in the stdout
1136
1136
  if (stdout) {
1137
1137
  if (stdout.includes('adbd cannot run as root')) {
@@ -1147,7 +1147,7 @@ async function changeUserPrivileges(isElevated) {
1147
1147
  catch (err) {
1148
1148
  const error = err;
1149
1149
  const { stderr = '', message } = error;
1150
- logger_js_1.log.warn(`Unable to ${cmd} adb daemon. Original error: '${message}'. Stderr: '${stderr}'. Continuing.`);
1150
+ logger_1.log.warn(`Unable to ${cmd} adb daemon. Original error: '${message}'. Stderr: '${stderr}'. Continuing.`);
1151
1151
  return { isSuccessful: false, wasAlreadyRooted };
1152
1152
  }
1153
1153
  }
@@ -1195,19 +1195,19 @@ async function installMitmCertificate(cert) {
1195
1195
  await support_1.fs.writeFile(srcCert, Buffer.isBuffer(cert) ? cert : Buffer.from(cert, 'base64'));
1196
1196
  const { stdout } = await (0, teen_process_1.exec)(openSsl, ['x509', '-noout', '-hash', '-in', srcCert]);
1197
1197
  const certHash = stdout.trim();
1198
- logger_js_1.log.debug(`Got certificate hash: ${certHash}`);
1199
- logger_js_1.log.debug('Preparing certificate content');
1198
+ logger_1.log.debug(`Got certificate hash: ${certHash}`);
1199
+ logger_1.log.debug('Preparing certificate content');
1200
1200
  const { stdout: stdoutBuff1 } = await (0, teen_process_1.exec)(openSsl, ['x509', '-in', srcCert], { isBuffer: true });
1201
1201
  const { stdout: stdoutBuff2 } = await (0, teen_process_1.exec)(openSsl, ['x509', '-in', srcCert, '-text', '-fingerprint', '-noout'], { isBuffer: true });
1202
1202
  const dstCertContent = Buffer.concat([stdoutBuff1, stdoutBuff2]);
1203
1203
  const dstCert = node_path_1.default.resolve(tmpRoot, `${certHash}.0`);
1204
1204
  await support_1.fs.writeFile(dstCert, dstCertContent);
1205
- logger_js_1.log.debug('Remounting /system in rw mode');
1205
+ logger_1.log.debug('Remounting /system in rw mode');
1206
1206
  // Sometimes emulator reboot is still not fully finished on this stage, so retry
1207
1207
  await (0, asyncbox_1.retryInterval)(5, 2000, async () => await this.adbExec(['remount']));
1208
- logger_js_1.log.debug(`Uploading the generated certificate from '${dstCert}' to '${CERTS_ROOT}'`);
1208
+ logger_1.log.debug(`Uploading the generated certificate from '${dstCert}' to '${CERTS_ROOT}'`);
1209
1209
  await this.push(dstCert, CERTS_ROOT);
1210
- logger_js_1.log.debug('Remounting /system to confirm changes');
1210
+ logger_1.log.debug('Remounting /system to confirm changes');
1211
1211
  await this.adbExec(['remount']);
1212
1212
  }
1213
1213
  catch (err) {
@@ -1248,7 +1248,7 @@ async function isMitmCertificateInstalled(cert) {
1248
1248
  await support_1.fs.rimraf(tmpRoot);
1249
1249
  }
1250
1250
  const dstPath = node_path_1.default.posix.resolve(CERTS_ROOT, `${certHash}.0`);
1251
- logger_js_1.log.debug(`Checking if the certificate is already installed at '${dstPath}'`);
1251
+ logger_1.log.debug(`Checking if the certificate is already installed at '${dstPath}'`);
1252
1252
  return await this.fileExists(dstPath);
1253
1253
  }
1254
1254
  /**
@@ -1281,7 +1281,7 @@ async function shellChunks(argTransformer, args) {
1281
1281
  if (!lodash_1.default.isEmpty(cmdChunk)) {
1282
1282
  commands.push(cmdChunk);
1283
1283
  }
1284
- logger_js_1.log.debug(`Got the following command chunks to execute: ${JSON.stringify(commands)}`);
1284
+ logger_1.log.debug(`Got the following command chunks to execute: ${JSON.stringify(commands)}`);
1285
1285
  let lastError = null;
1286
1286
  for (const cmd of commands) {
1287
1287
  try {
@@ -1346,15 +1346,15 @@ exports.getBuildToolsDirs = lodash_1.default.memoize(async function getBuildTool
1346
1346
  }
1347
1347
  catch (err) {
1348
1348
  const error = err;
1349
- logger_js_1.log.warn(`Cannot sort build-tools folders ${JSON.stringify(buildToolsDirs.map((dir) => node_path_1.default.basename(dir)))} ` +
1349
+ logger_1.log.warn(`Cannot sort build-tools folders ${JSON.stringify(buildToolsDirs.map((dir) => node_path_1.default.basename(dir)))} ` +
1350
1350
  `by semantic version names.`);
1351
- logger_js_1.log.warn(`Falling back to sorting by modification date. Original error: ${error.message}`);
1351
+ logger_1.log.warn(`Falling back to sorting by modification date. Original error: ${error.message}`);
1352
1352
  const pairs = await bluebird_1.default.map(buildToolsDirs, async (dir) => [(await support_1.fs.stat(dir)).mtime.valueOf(), dir]);
1353
1353
  buildToolsDirs = pairs.sort((a, b) => (a[0] < b[0] ? 1 : -1)).map((pair) => pair[1]);
1354
1354
  }
1355
- logger_js_1.log.info(`Found ${buildToolsDirs.length} 'build-tools' folders under '${sdkRoot}' (newest first):`);
1355
+ logger_1.log.info(`Found ${buildToolsDirs.length} 'build-tools' folders under '${sdkRoot}' (newest first):`);
1356
1356
  for (const dir of buildToolsDirs) {
1357
- logger_js_1.log.info(` ${dir}`);
1357
+ logger_1.log.info(` ${dir}`);
1358
1358
  }
1359
1359
  return buildToolsDirs;
1360
1360
  });