appium-android-driver 4.52.1 → 5.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 (55) hide show
  1. package/build/index.js +6 -4
  2. package/build/lib/android-helpers.js +12 -9
  3. package/build/lib/bootstrap.js +7 -7
  4. package/build/lib/commands/actions.js +13 -13
  5. package/build/lib/commands/alert.js +7 -7
  6. package/build/lib/commands/app-management.js +6 -6
  7. package/build/lib/commands/context.js +10 -8
  8. package/build/lib/commands/element.js +5 -5
  9. package/build/lib/commands/execute.js +7 -6
  10. package/build/lib/commands/file-actions.js +27 -20
  11. package/build/lib/commands/find.js +6 -6
  12. package/build/lib/commands/general.js +8 -8
  13. package/build/lib/commands/ime.js +4 -4
  14. package/build/lib/commands/intent.js +7 -7
  15. package/build/lib/commands/log.js +6 -6
  16. package/build/lib/commands/network.js +11 -4
  17. package/build/lib/commands/performance.js +1 -1
  18. package/build/lib/commands/recordscreen.js +15 -15
  19. package/build/lib/commands/shell.js +3 -3
  20. package/build/lib/commands/streamscreen.js +7 -7
  21. package/build/lib/commands/touch.js +8 -8
  22. package/build/lib/desired-caps.js +1 -1
  23. package/build/lib/driver.js +12 -12
  24. package/build/lib/logger.js +3 -3
  25. package/build/lib/server.js +4 -4
  26. package/build/lib/uiautomator.js +3 -3
  27. package/build/lib/unlock-helpers.js +8 -8
  28. package/build/lib/webview-helpers.js +7 -7
  29. package/lib/android-helpers.js +1 -1
  30. package/lib/bootstrap.js +2 -2
  31. package/lib/commands/actions.js +1 -1
  32. package/lib/commands/alert.js +1 -1
  33. package/lib/commands/app-management.js +4 -2
  34. package/lib/commands/context.js +2 -2
  35. package/lib/commands/element.js +1 -1
  36. package/lib/commands/execute.js +3 -1
  37. package/lib/commands/file-actions.js +28 -8
  38. package/lib/commands/find.js +2 -2
  39. package/lib/commands/general.js +1 -1
  40. package/lib/commands/ime.js +1 -1
  41. package/lib/commands/intent.js +1 -1
  42. package/lib/commands/log.js +1 -1
  43. package/lib/commands/network.js +22 -1
  44. package/lib/commands/recordscreen.js +1 -1
  45. package/lib/commands/shell.js +1 -1
  46. package/lib/commands/streamscreen.js +1 -1
  47. package/lib/commands/touch.js +2 -2
  48. package/lib/driver.js +2 -2
  49. package/lib/logger.js +1 -1
  50. package/lib/server.js +1 -1
  51. package/lib/uiautomator.js +1 -1
  52. package/lib/unlock-helpers.js +1 -1
  53. package/lib/webview-helpers.js +1 -1
  54. package/package.json +21 -15
  55. package/lib/.DS_Store +0 -0
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { fs, util, zip, tempDir} from 'appium-support';
2
+ import { fs, util, zip, tempDir} from '@appium/support';
3
3
  import log from '../logger';
4
4
  import path from 'path';
5
5
 
@@ -30,6 +30,32 @@ function parseContainerPath (remotePath) {
30
30
  return [match[1], path.posix.resolve(`/data/data/${match[1]}`, match[2])];
31
31
  }
32
32
 
33
+ /**
34
+ * Scans the given file/folder on the remote device
35
+ * and adds matching items to the device's media library.
36
+ * Exceptions are ignored and written into the log.
37
+ *
38
+ * @param {ADB} adb ADB instance
39
+ * @param {string} remotePath The file/folder path on the remote device
40
+ */
41
+ async function scanMedia (adb, remotePath) {
42
+ log.debug(`Performing media scan of '${remotePath}'`);
43
+ try {
44
+ // https://github.com/appium/appium/issues/16184
45
+ if (await adb.getApiLevel() >= 29) {
46
+ await adb.scanMedia(remotePath);
47
+ } else {
48
+ await adb.shell([
49
+ 'am', 'broadcast',
50
+ '-a', ANDROID_MEDIA_RESCAN_INTENT,
51
+ '-d', `file://${remotePath}`
52
+ ]);
53
+ }
54
+ } catch (e) {
55
+ log.warn(`Ignoring an unexpected error upon media scanning of '${remotePath}': ${e.stderr || e.message}`);
56
+ }
57
+ }
58
+
33
59
  /**
34
60
  * A small helper, which escapes single quotes in paths,
35
61
  * so they are safe to be passed as arguments of shell commands
@@ -139,13 +165,7 @@ commands.pushFile = async function pushFile (remotePath, base64Data) {
139
165
 
140
166
  // if we have pushed a file, it might be a media file, so ensure that
141
167
  // apps know about it
142
- log.info('After pushing media file, broadcasting media scan intent');
143
- try {
144
- await this.adb.shell(['am', 'broadcast', '-a',
145
- ANDROID_MEDIA_RESCAN_INTENT, '-d', `file://${remotePath}`]);
146
- } catch (e) {
147
- log.warn(`Got error broadcasting media scan intent: ${e.message}; ignoring`);
148
- }
168
+ await scanMedia(this.adb, remotePath);
149
169
  }
150
170
  } finally {
151
171
  if (await fs.exists(localFile)) {
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { errors, isErrorType } from 'appium-base-driver';
2
+ import { errors, isErrorType } from '@appium/base-driver';
3
3
 
4
4
 
5
5
  let helpers = {}, extensions = {};
@@ -44,7 +44,7 @@ helpers.findElOrEls = async function findElOrEls (strategy, selector, mult, cont
44
44
 
45
45
  // now we have to inspect the error to determine if it is a no such
46
46
  // element error, based on the shape of the error object from
47
- // appium-base-driver
47
+ // @appium/base-driver
48
48
  if (isErrorType(err, errors.NoSuchElementError)) {
49
49
  // we are fine with this, just indicate a retry
50
50
  return false;
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import androidHelpers from '../android-helpers';
3
- import { util } from 'appium-support';
3
+ import { util } from '@appium/support';
4
4
  import log from '../logger';
5
5
  import moment from 'moment';
6
6
  import { longSleep } from 'asyncbox';
@@ -1,5 +1,5 @@
1
1
  import log from '../logger';
2
- import { errors } from 'appium-base-driver';
2
+ import { errors } from '@appium/base-driver';
3
3
 
4
4
  let commands = {}, helpers = {}, extensions = {};
5
5
 
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { errors } from 'appium-base-driver';
2
+ import { errors } from '@appium/base-driver';
3
3
 
4
4
  const NO_VALUE_ARG_TYPE = 'sn';
5
5
  const SUPPORTED_EXTRA_TYPES = [
@@ -2,7 +2,7 @@ import log from '../logger';
2
2
  import os from 'os';
3
3
  import _ from 'lodash';
4
4
  import WebSocket from 'ws';
5
- import { DEFAULT_WS_PATHNAME_PREFIX, BaseDriver } from 'appium-base-driver';
5
+ import { DEFAULT_WS_PATHNAME_PREFIX, BaseDriver } from '@appium/base-driver';
6
6
 
7
7
  const GET_SERVER_LOGS_FEATURE = 'get_server_logs';
8
8
 
@@ -1,6 +1,6 @@
1
1
  import log from '../logger';
2
2
  import _ from 'lodash';
3
- import { errors } from 'appium-base-driver';
3
+ import { errors } from '@appium/base-driver';
4
4
  import B from 'bluebird';
5
5
 
6
6
  let commands = {}, helpers = {}, extensions = {};
@@ -144,6 +144,27 @@ commands.setGeoLocation = async function setGeoLocation (location) {
144
144
  }
145
145
  };
146
146
 
147
+ /**
148
+ * @typedef {Object} GpsCacheRefreshOptions
149
+ * @property {number} timeoutMs [20000] The maximum number of milliseconds
150
+ * to block until GPS cache is refreshed. Providing zero or a negative
151
+ * value to it skips waiting completely.
152
+ */
153
+
154
+ /**
155
+ * Sends an async request to refresh the GPS cache.
156
+ * This feature only works if the device under test has
157
+ * Google Play Services installed. In case the vanilla
158
+ * LocationManager is used the device API level must be at
159
+ * version 30 (Android R) or higher.
160
+ *
161
+ * @param {GpsCacheRefreshOptions} opts
162
+ */
163
+ commands.mobileRefreshGpsCache = async function mobileRefreshGpsCache (opts = {}) {
164
+ const { timeoutMs } = opts;
165
+ await this.adb.refreshGeoLocationCache(timeoutMs);
166
+ };
167
+
147
168
  commands.getGeoLocation = async function getGeoLocation () {
148
169
  const {latitude, longitude, altitude} = await this.adb.getGeoLocation();
149
170
  return {
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import { waitForCondition } from 'asyncbox';
3
- import { util, fs, net, tempDir, system, timing } from 'appium-support';
3
+ import { util, fs, net, tempDir, system, timing } from '@appium/support';
4
4
  import log from '../logger';
5
5
  import { exec } from 'teen_process';
6
6
  import path from 'path';
@@ -1,7 +1,7 @@
1
1
  import log from '../logger';
2
2
  import _ from 'lodash';
3
3
  import { exec } from 'teen_process';
4
- import { util } from 'appium-support';
4
+ import { util } from '@appium/support';
5
5
 
6
6
  const ADB_SHELL_FEATURE = 'adb_shell';
7
7
 
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { fs, system, logger, util } from 'appium-support';
2
+ import { fs, system, logger, util } from '@appium/support';
3
3
  import log from '../logger';
4
4
  import { exec, SubProcess } from 'teen_process';
5
5
  import { checkPortStatus } from 'portscanner';
@@ -2,9 +2,9 @@ import log from '../logger';
2
2
  import _ from 'lodash';
3
3
  import androidHelpers from '../android-helpers';
4
4
  import B from 'bluebird';
5
- import { errors, isErrorType } from 'appium-base-driver';
5
+ import { errors, isErrorType } from '@appium/base-driver';
6
6
  import { asyncmap } from 'asyncbox';
7
- import { util } from 'appium-support';
7
+ import { util } from '@appium/support';
8
8
 
9
9
  let commands = {}, helpers = {}, extensions = {};
10
10
 
package/lib/driver.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseDriver, DeviceSettings } from 'appium-base-driver';
1
+ import { BaseDriver, DeviceSettings } from '@appium/base-driver';
2
2
  import desiredConstraints from './desired-caps';
3
3
  import commands from './commands/index';
4
4
  import {
@@ -8,7 +8,7 @@ import {
8
8
  import log from './logger';
9
9
  import _ from 'lodash';
10
10
  import { DEFAULT_ADB_PORT } from 'appium-adb';
11
- import { fs, tempDir, util } from 'appium-support';
11
+ import { fs, tempDir, util } from '@appium/support';
12
12
  import { retryInterval } from 'asyncbox';
13
13
  import { SharedPrefsBuilder } from 'shared-preferences-builder';
14
14
  import B from 'bluebird';
package/lib/logger.js CHANGED
@@ -1,4 +1,4 @@
1
- import { logger } from 'appium-support';
1
+ import { logger } from '@appium/support';
2
2
  const log = logger.getLogger('AndroidDriver');
3
3
 
4
4
  export default log;
package/lib/server.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import log from './logger';
2
- import { server as baseServer, routeConfiguringFunction as makeRouter } from 'appium-base-driver';
2
+ import { server as baseServer, routeConfiguringFunction as makeRouter } from '@appium/base-driver';
3
3
  import AndroidDriver from './driver';
4
4
 
5
5
  async function startServer (port, host) {
@@ -1,5 +1,5 @@
1
1
  import events from 'events';
2
- import { logger } from 'appium-support';
2
+ import { logger } from '@appium/support';
3
3
 
4
4
 
5
5
  const log = logger.getLogger('UiAutomator');
@@ -1,7 +1,7 @@
1
1
  import logger from './logger';
2
2
  import { sleep } from 'asyncbox';
3
3
  import _ from 'lodash';
4
- import { util } from 'appium-support';
4
+ import { util } from '@appium/support';
5
5
 
6
6
  const PIN_UNLOCK = 'pin';
7
7
  const PIN_UNLOCK_KEY_EVENT = 'pinWithKeyEvent';
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import logger from './logger';
3
3
  import axios from 'axios';
4
- import { util } from 'appium-support';
4
+ import { util } from '@appium/support';
5
5
  import { findAPortNotInUse } from 'portscanner';
6
6
  import LRU from 'lru-cache';
7
7
  import B from 'bluebird';
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "mobile",
10
10
  "mobile testing"
11
11
  ],
12
- "version": "4.52.1",
12
+ "version": "5.0.1",
13
13
  "author": "appium",
14
14
  "license": "Apache-2.0",
15
15
  "repository": {
@@ -35,25 +35,25 @@
35
35
  "bootstrap/bin/AppiumBootstrap.jar"
36
36
  ],
37
37
  "dependencies": {
38
+ "@appium/base-driver": "^8.0.0",
39
+ "@appium/support": "^2.55.3",
38
40
  "@babel/runtime": "^7.0.0",
39
- "appium-adb": "^8.16.0",
40
- "appium-base-driver": "^7.0.0",
41
- "appium-chromedriver": "^4.13.0",
42
- "appium-support": "^2.47.1",
41
+ "appium-adb": "^9.0.0",
42
+ "appium-chromedriver": "^5.0.1",
43
43
  "asyncbox": "^2.8.0",
44
44
  "axios": "^0.x",
45
45
  "bluebird": "^3.4.7",
46
- "io.appium.settings": "^3.3.0",
47
- "jimp": "^0.16.1",
46
+ "io.appium.settings": "^4.0.0",
47
+ "jimp": "^0.x",
48
48
  "lodash": "^4.17.4",
49
- "lru-cache": "^6.0.0",
49
+ "lru-cache": "^7.3.0",
50
50
  "moment": "^2.24.0",
51
51
  "moment-timezone": "^0.5.26",
52
52
  "portfinder": "^1.0.6",
53
53
  "portscanner": "2.2.0",
54
- "shared-preferences-builder": "^0.0.4",
54
+ "shared-preferences-builder": "^0.x",
55
55
  "semver": "^7.0.0",
56
- "source-map-support": "^0.5.5",
56
+ "source-map-support": "^0.x",
57
57
  "teen_process": "^1.9.0",
58
58
  "ws": "^8.0.0"
59
59
  },
@@ -77,18 +77,24 @@
77
77
  "precommit-test"
78
78
  ],
79
79
  "devDependencies": {
80
+ "@appium/gulp-plugins": "^6.0.0",
81
+ "@appium/eslint-config-appium": "^5.0.0",
82
+ "@appium/test-support": "^1.0.0",
83
+ "@babel/core": "^7.16.0",
84
+ "@babel/eslint-parser": "^7.16.3",
80
85
  "@xmldom/xmldom": "^0.x",
81
- "android-apidemos": "^3.0.0",
82
- "appium-gulp-plugins": "^5.4.0",
83
- "appium-test-support": "^1.0.0",
86
+ "android-apidemos": "^4.0.0",
84
87
  "chai": "^4.1.2",
85
88
  "chai-as-promised": "^7.1.1",
86
- "eslint-config-appium": "^4.0.1",
89
+ "eslint": "^7.32.0",
90
+ "eslint-plugin-import": "^2.25.3",
91
+ "eslint-plugin-mocha": "^9.0.0",
92
+ "eslint-plugin-promise": "^6.0.0",
87
93
  "gulp": "^4.0.0",
88
94
  "mocha": "^9.0.0",
89
95
  "mock-fs": "^5.0.0",
90
96
  "pre-commit": "^1.1.3",
91
- "sinon": "^12.0.0",
97
+ "sinon": "^13.0.0",
92
98
  "xpath": "^0.x"
93
99
  }
94
100
  }
package/lib/.DS_Store DELETED
Binary file