io.appium.settings 5.3.0 → 5.4.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 (69) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/apks/settings_apk-debug.apk +0 -0
  3. package/build/lib/client.d.ts +83 -0
  4. package/build/lib/client.d.ts.map +1 -0
  5. package/build/lib/client.js +137 -0
  6. package/build/lib/client.js.map +1 -0
  7. package/build/lib/commands/animation.d.ts +16 -0
  8. package/build/lib/commands/animation.d.ts.map +1 -0
  9. package/build/lib/commands/animation.js +29 -0
  10. package/build/lib/commands/animation.js.map +1 -0
  11. package/build/lib/commands/clipboard.d.ts +16 -0
  12. package/build/lib/commands/clipboard.d.ts.map +1 -0
  13. package/build/lib/commands/clipboard.js +51 -0
  14. package/build/lib/commands/clipboard.js.map +1 -0
  15. package/build/lib/commands/geolocation.d.ts +70 -0
  16. package/build/lib/commands/geolocation.d.ts.map +1 -0
  17. package/build/lib/commands/geolocation.js +215 -0
  18. package/build/lib/commands/geolocation.js.map +1 -0
  19. package/build/lib/commands/locale.d.ts +13 -0
  20. package/build/lib/commands/locale.d.ts.map +1 -0
  21. package/build/lib/commands/locale.js +31 -0
  22. package/build/lib/commands/locale.js.map +1 -0
  23. package/build/lib/commands/media.d.ts +11 -0
  24. package/build/lib/commands/media.d.ts.map +1 -0
  25. package/build/lib/commands/media.js +35 -0
  26. package/build/lib/commands/media.js.map +1 -0
  27. package/build/lib/commands/network.d.ts +19 -0
  28. package/build/lib/commands/network.d.ts.map +1 -0
  29. package/build/lib/commands/network.js +68 -0
  30. package/build/lib/commands/network.js.map +1 -0
  31. package/build/lib/commands/notifications.d.ts +50 -0
  32. package/build/lib/commands/notifications.d.ts.map +1 -0
  33. package/build/lib/commands/notifications.js +77 -0
  34. package/build/lib/commands/notifications.js.map +1 -0
  35. package/build/lib/commands/sms.d.ts +90 -0
  36. package/build/lib/commands/sms.d.ts.map +1 -0
  37. package/build/lib/commands/sms.js +95 -0
  38. package/build/lib/commands/sms.js.map +1 -0
  39. package/build/lib/commands/typing.d.ts +23 -0
  40. package/build/lib/commands/typing.d.ts.map +1 -0
  41. package/build/lib/commands/typing.js +51 -0
  42. package/build/lib/commands/typing.js.map +1 -0
  43. package/build/lib/commands/utf7.d.ts +26 -0
  44. package/build/lib/commands/utf7.d.ts.map +1 -0
  45. package/build/lib/commands/utf7.js +144 -0
  46. package/build/lib/commands/utf7.js.map +1 -0
  47. package/build/lib/constants.d.ts +23 -0
  48. package/build/lib/constants.d.ts.map +1 -0
  49. package/build/lib/constants.js +26 -0
  50. package/build/lib/constants.js.map +1 -0
  51. package/build/lib/logger.d.ts +3 -0
  52. package/build/lib/logger.d.ts.map +1 -0
  53. package/build/lib/logger.js +17 -0
  54. package/build/lib/logger.js.map +1 -0
  55. package/index.js +6 -2
  56. package/lib/client.js +155 -0
  57. package/lib/commands/animation.js +24 -0
  58. package/lib/commands/clipboard.js +47 -0
  59. package/lib/commands/geolocation.js +214 -0
  60. package/lib/commands/locale.js +28 -0
  61. package/lib/commands/media.js +27 -0
  62. package/lib/commands/network.js +73 -0
  63. package/lib/commands/notifications.js +71 -0
  64. package/lib/commands/sms.js +92 -0
  65. package/lib/commands/typing.js +46 -0
  66. package/lib/commands/utf7.js +154 -0
  67. package/lib/constants.js +31 -0
  68. package/lib/logger.js +14 -0
  69. package/package.json +44 -8
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## [5.4.0](https://github.com/appium/io.appium.settings/compare/v5.3.1...v5.4.0) (2024-01-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add javascript wrappers over Settings App APIs ([#131](https://github.com/appium/io.appium.settings/issues/131)) ([bd56d5e](https://github.com/appium/io.appium.settings/commit/bd56d5ed958f243bb32c22197cf9526bfc6428f7))
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add missing packages ([#132](https://github.com/appium/io.appium.settings/issues/132)) ([7d3015a](https://github.com/appium/io.appium.settings/commit/7d3015a45c44e9cf7edd0ce2d918561571879ade))
12
+
13
+
14
+ ### Miscellaneous Chores
15
+
16
+ * **deps:** bump org.apache.commons:commons-lang3 from 3.13.0 to 3.14.0 ([#130](https://github.com/appium/io.appium.settings/issues/130)) ([ae96723](https://github.com/appium/io.appium.settings/commit/ae96723d82f5f2436294bb74db0d4184fafe5c85))
17
+
18
+ ## [5.3.1](https://github.com/appium/io.appium.settings/compare/v5.3.0...v5.3.1) (2024-01-06)
19
+
20
+
21
+ ### Miscellaneous Chores
22
+
23
+ * Bump Gradle version ([#129](https://github.com/appium/io.appium.settings/issues/129)) ([865c90f](https://github.com/appium/io.appium.settings/commit/865c90f65c0b5dfb2ff5dc89f0cc2c4b1bc9915d))
24
+
1
25
  ## [5.3.0](https://github.com/appium/io.appium.settings/compare/v5.2.0...v5.3.0) (2024-01-06)
2
26
 
3
27
 
Binary file
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @typedef {Object} SettingsAppOpts
3
+ * @property {import('appium-adb').ADB} adb
4
+ */
5
+ export class SettingsApp {
6
+ /**
7
+ * @param {SettingsAppOpts} opts
8
+ */
9
+ constructor(opts: SettingsAppOpts);
10
+ /** @type {import('appium-adb').ADB} */
11
+ adb: import('appium-adb').ADB;
12
+ /** @type {import('npmlog').Logger} */
13
+ log: import('npmlog').Logger;
14
+ /**
15
+ * @typedef {Object} SettingsAppStartupOptions
16
+ * @property {number} [timeout=5000] The maximum number of milliseconds
17
+ * to wait until the app has started
18
+ * @property {boolean} [shouldRestoreCurrentApp=false] Whether to restore
19
+ * the activity which was the current one before Settings startup
20
+ */
21
+ /**
22
+ * Ensures that Appium Settings helper application is running
23
+ * and starts it if necessary
24
+ *
25
+ * @param {SettingsAppStartupOptions} [opts={}]
26
+ * @throws {Error} If Appium Settings has failed to start
27
+ * @returns {Promise<SettingsApp>} self instance for chaining
28
+ */
29
+ requireRunning(opts?: {
30
+ /**
31
+ * The maximum number of milliseconds
32
+ * to wait until the app has started
33
+ */
34
+ timeout?: number | undefined;
35
+ /**
36
+ * Whether to restore
37
+ * the activity which was the current one before Settings startup
38
+ */
39
+ shouldRestoreCurrentApp?: boolean | undefined;
40
+ } | undefined): Promise<SettingsApp>;
41
+ /**
42
+ * Parses the output in JSON format retrieved from
43
+ * the corresponding Appium Settings broadcast calls
44
+ *
45
+ * @param {string} output The actual command output
46
+ * @param {string} entityName The name of the entity which is
47
+ * going to be parsed
48
+ * @returns {Object} The parsed JSON object
49
+ * @throws {Error} If the output cannot be parsed
50
+ * as a valid JSON
51
+ */
52
+ _parseJsonData(output: string, entityName: string): any;
53
+ setAnimationState: typeof setAnimationState;
54
+ getClipboard: typeof getClipboard;
55
+ setGeoLocation: typeof setGeoLocation;
56
+ getGeoLocation: typeof getGeoLocation;
57
+ refreshGeoLocationCache: typeof refreshGeoLocationCache;
58
+ setDeviceSysLocale: typeof setDeviceSysLocale;
59
+ scanMedia: typeof scanMedia;
60
+ setDataState: typeof setDataState;
61
+ setWifiState: typeof setWifiState;
62
+ getNotifications: typeof getNotifications;
63
+ getSmsList: typeof getSmsList;
64
+ performEditorAction: typeof performEditorAction;
65
+ typeUnicode: typeof typeUnicode;
66
+ }
67
+ export type SettingsAppOpts = {
68
+ adb: import('appium-adb').ADB;
69
+ };
70
+ import { setAnimationState } from './commands/animation';
71
+ import { getClipboard } from './commands/clipboard';
72
+ import { setGeoLocation } from './commands/geolocation';
73
+ import { getGeoLocation } from './commands/geolocation';
74
+ import { refreshGeoLocationCache } from './commands/geolocation';
75
+ import { setDeviceSysLocale } from './commands/locale';
76
+ import { scanMedia } from './commands/media';
77
+ import { setDataState } from './commands/network';
78
+ import { setWifiState } from './commands/network';
79
+ import { getNotifications } from './commands/notifications';
80
+ import { getSmsList } from './commands/sms';
81
+ import { performEditorAction } from './commands/typing';
82
+ import { typeUnicode } from './commands/typing';
83
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.js"],"names":[],"mappings":"AAcA;;;GAGG;AAGH;IAOE;;OAEG;IACH,kBAFW,eAAe,EAKzB;IAZD,uCAAuC;IACvC,KADW,OAAO,YAAY,EAAE,GAAG,CAC/B;IAEJ,sCAAsC;IACtC,KADW,OAAO,QAAQ,EAAE,MAAM,CAC9B;IAUJ;;;;;;OAMG;IAEH;;;;;;;OAOG;IACH;;;;;;;;;;;oBAFa,QAAQ,WAAW,CAAC,CA4ChC;IAED;;;;;;;;;;OAUG;IACH,uBAPW,MAAM,cACN,MAAM,OAgChB;IAED,4CAAsC;IAEtC,kCAA4B;IAE5B,sCAAgC;IAChC,sCAAgC;IAChC,wDAAkD;IAElD,8CAAwC;IAExC,4BAAsB;IAEtB,kCAA4B;IAC5B,kCAA4B;IAE5B,0CAAoC;IACpC,8BAAwB;IAExB,gDAA0C;IAC1C,gCAA0B;CAC3B;;SA1Ia,OAAO,YAAY,EAAE,GAAG;;kCAZJ,sBAAsB;6BAC3B,sBAAsB;+BACqB,wBAAwB;+BAAxB,wBAAwB;wCAAxB,wBAAwB;mCAC7D,mBAAmB;0BAC5B,kBAAkB;6BACD,oBAAoB;6BAApB,oBAAoB;iCAC9B,0BAA0B;2BAChC,gBAAgB;oCACM,mBAAmB;4BAAnB,mBAAmB"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SettingsApp = void 0;
7
+ const logger_1 = require("./logger");
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const asyncbox_1 = require("asyncbox");
10
+ const constants_js_1 = require("./constants.js");
11
+ const animation_1 = require("./commands/animation");
12
+ const clipboard_1 = require("./commands/clipboard");
13
+ const geolocation_1 = require("./commands/geolocation");
14
+ const locale_1 = require("./commands/locale");
15
+ const media_1 = require("./commands/media");
16
+ const network_1 = require("./commands/network");
17
+ const notifications_1 = require("./commands/notifications");
18
+ const sms_1 = require("./commands/sms");
19
+ const typing_1 = require("./commands/typing");
20
+ /**
21
+ * @typedef {Object} SettingsAppOpts
22
+ * @property {import('appium-adb').ADB} adb
23
+ */
24
+ class SettingsApp {
25
+ /**
26
+ * @param {SettingsAppOpts} opts
27
+ */
28
+ constructor(opts) {
29
+ this.setAnimationState = animation_1.setAnimationState;
30
+ this.getClipboard = clipboard_1.getClipboard;
31
+ this.setGeoLocation = geolocation_1.setGeoLocation;
32
+ this.getGeoLocation = geolocation_1.getGeoLocation;
33
+ this.refreshGeoLocationCache = geolocation_1.refreshGeoLocationCache;
34
+ this.setDeviceSysLocale = locale_1.setDeviceSysLocale;
35
+ this.scanMedia = media_1.scanMedia;
36
+ this.setDataState = network_1.setDataState;
37
+ this.setWifiState = network_1.setWifiState;
38
+ this.getNotifications = notifications_1.getNotifications;
39
+ this.getSmsList = sms_1.getSmsList;
40
+ this.performEditorAction = typing_1.performEditorAction;
41
+ this.typeUnicode = typing_1.typeUnicode;
42
+ this.adb = opts.adb;
43
+ this.log = logger_1.log;
44
+ }
45
+ /**
46
+ * @typedef {Object} SettingsAppStartupOptions
47
+ * @property {number} [timeout=5000] The maximum number of milliseconds
48
+ * to wait until the app has started
49
+ * @property {boolean} [shouldRestoreCurrentApp=false] Whether to restore
50
+ * the activity which was the current one before Settings startup
51
+ */
52
+ /**
53
+ * Ensures that Appium Settings helper application is running
54
+ * and starts it if necessary
55
+ *
56
+ * @param {SettingsAppStartupOptions} [opts={}]
57
+ * @throws {Error} If Appium Settings has failed to start
58
+ * @returns {Promise<SettingsApp>} self instance for chaining
59
+ */
60
+ async requireRunning(opts = {}) {
61
+ if (await this.adb.processExists(constants_js_1.SETTINGS_HELPER_ID)) {
62
+ return this;
63
+ }
64
+ this.log.debug(logger_1.LOG_PREFIX, 'Starting Appium Settings app');
65
+ const { timeout = 5000, shouldRestoreCurrentApp = false, } = opts;
66
+ let appPackage;
67
+ if (shouldRestoreCurrentApp) {
68
+ try {
69
+ ({ appPackage } = await this.adb.getFocusedPackageAndActivity());
70
+ }
71
+ catch (e) {
72
+ this.log.warn(logger_1.LOG_PREFIX, `The current application can not be restored: ${e.message}`);
73
+ }
74
+ }
75
+ await this.adb.startApp({
76
+ pkg: constants_js_1.SETTINGS_HELPER_ID,
77
+ activity: constants_js_1.SETTINGS_HELPER_MAIN_ACTIVITY,
78
+ action: 'android.intent.action.MAIN',
79
+ category: 'android.intent.category.LAUNCHER',
80
+ stopApp: false,
81
+ waitForLaunch: false,
82
+ });
83
+ try {
84
+ await (0, asyncbox_1.waitForCondition)(async () => await this.adb.processExists(constants_js_1.SETTINGS_HELPER_ID), {
85
+ waitMs: timeout,
86
+ intervalMs: 300,
87
+ });
88
+ if (shouldRestoreCurrentApp && appPackage) {
89
+ try {
90
+ await this.adb.activateApp(appPackage);
91
+ }
92
+ catch (e) {
93
+ logger_1.log.warn(`The current application can not be restored: ${e.message}`);
94
+ }
95
+ }
96
+ return this;
97
+ }
98
+ catch (err) {
99
+ throw new Error(`Appium Settings app is not running after ${timeout}ms`);
100
+ }
101
+ }
102
+ /**
103
+ * Parses the output in JSON format retrieved from
104
+ * the corresponding Appium Settings broadcast calls
105
+ *
106
+ * @param {string} output The actual command output
107
+ * @param {string} entityName The name of the entity which is
108
+ * going to be parsed
109
+ * @returns {Object} The parsed JSON object
110
+ * @throws {Error} If the output cannot be parsed
111
+ * as a valid JSON
112
+ */
113
+ _parseJsonData(output, entityName) {
114
+ if (!/\bresult=-1\b/.test(output) || !/\bdata="/.test(output)) {
115
+ this.log.debug(logger_1.LOG_PREFIX, output);
116
+ throw new Error(`Cannot retrieve ${entityName} from the device. ` +
117
+ 'Check the server log for more details');
118
+ }
119
+ const match = /\bdata="(.+)",?/.exec(output);
120
+ if (!match) {
121
+ this.log.debug(logger_1.LOG_PREFIX, output);
122
+ throw new Error(`Cannot parse ${entityName} from the command output. ` +
123
+ 'Check the server log for more details');
124
+ }
125
+ const jsonStr = lodash_1.default.trim(match[1]);
126
+ try {
127
+ return JSON.parse(jsonStr);
128
+ }
129
+ catch (e) {
130
+ logger_1.log.debug(jsonStr);
131
+ throw new Error(`Cannot parse ${entityName} from the resulting data string. ` +
132
+ 'Check the server log for more details');
133
+ }
134
+ }
135
+ }
136
+ exports.SettingsApp = SettingsApp;
137
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.js"],"names":[],"mappings":";;;;;;AAAA,qCAA2C;AAC3C,oDAAuB;AACvB,uCAA4C;AAC5C,iDAAmF;AACnF,oDAAyD;AACzD,oDAAoD;AACpD,wDAAiG;AACjG,8CAAuD;AACvD,4CAA6C;AAC7C,gDAAgE;AAChE,4DAA4D;AAC5D,wCAA4C;AAC5C,8CAAqE;AAErE;;;GAGG;AAGH,MAAa,WAAW;IAOtB;;OAEG;IACH,YAAa,IAAI;QAwGjB,sBAAiB,GAAG,6BAAiB,CAAC;QAEtC,iBAAY,GAAG,wBAAY,CAAC;QAE5B,mBAAc,GAAG,4BAAc,CAAC;QAChC,mBAAc,GAAG,4BAAc,CAAC;QAChC,4BAAuB,GAAG,qCAAuB,CAAC;QAElD,uBAAkB,GAAG,2BAAkB,CAAC;QAExC,cAAS,GAAG,iBAAS,CAAC;QAEtB,iBAAY,GAAG,sBAAY,CAAC;QAC5B,iBAAY,GAAG,sBAAY,CAAC;QAE5B,qBAAgB,GAAG,gCAAgB,CAAC;QACpC,eAAU,GAAG,gBAAU,CAAC;QAExB,wBAAmB,GAAG,4BAAmB,CAAC;QAC1C,gBAAW,GAAG,oBAAW,CAAC;QA1HxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,GAAG,GAAG,YAAG,CAAC;IACjB,CAAC;IAED;;;;;;OAMG;IAEH;;;;;;;OAOG;IACH,KAAK,CAAC,cAAc,CAAE,IAAI,GAAG,EAAE;QAC7B,IAAI,MAAM,IAAI,CAAC,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the device is controlled by the following global properties:
4
+ * [ANIMATOR_DURATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#ANIMATOR_DURATION_SCALE},
5
+ * [TRANSITION_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#TRANSITION_ANIMATION_SCALE},
6
+ * [WINDOW_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#WINDOW_ANIMATION_SCALE}.
7
+ * This method sets all this properties to 0.0 to disable (1.0 to enable) animation.
8
+ *
9
+ * Turning off animation might be useful to improve stability
10
+ * and reduce tests execution time.
11
+ *
12
+ * @this {import('../client').SettingsApp}
13
+ * @param {boolean} on - True to enable and false to disable it.
14
+ */
15
+ export function setAnimationState(this: import("../client").SettingsApp, on: boolean): Promise<void>;
16
+ //# sourceMappingURL=animation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../lib/commands/animation.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,6EAFW,OAAO,iBASjB"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setAnimationState = void 0;
4
+ const constants_js_1 = require("../constants.js");
5
+ /**
6
+ * Change the state of animation on the device under test.
7
+ * Animation on the device is controlled by the following global properties:
8
+ * [ANIMATOR_DURATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#ANIMATOR_DURATION_SCALE},
9
+ * [TRANSITION_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#TRANSITION_ANIMATION_SCALE},
10
+ * [WINDOW_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#WINDOW_ANIMATION_SCALE}.
11
+ * This method sets all this properties to 0.0 to disable (1.0 to enable) animation.
12
+ *
13
+ * Turning off animation might be useful to improve stability
14
+ * and reduce tests execution time.
15
+ *
16
+ * @this {import('../client').SettingsApp}
17
+ * @param {boolean} on - True to enable and false to disable it.
18
+ */
19
+ async function setAnimationState(on) {
20
+ await this.adb.shell([
21
+ 'am', 'broadcast',
22
+ '-a', constants_js_1.ANIMATION_SETTING_ACTION,
23
+ '-n', constants_js_1.ANIMATION_SETTING_RECEIVER,
24
+ '--es', 'setstatus', on ? 'enable' : 'disable'
25
+ ]);
26
+ }
27
+ exports.setAnimationState = setAnimationState;
28
+ ;
29
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../../lib/commands/animation.js"],"names":[],"mappings":";;;AAAA,kDAAuF;AAEvF;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,iBAAiB,CAAE,EAAE;IACzC,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QACnB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,uCAAwB;QAC9B,IAAI,EAAE,yCAA0B;QAChC,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KAC/C,CAAC,CAAC;AACL,CAAC;AAPD,8CAOC;AAAA,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Retrieves the text content of the device's clipboard.
3
+ * The method works for Android below and above 29.
4
+ * It temorarily enforces the IME setting in order to workaround
5
+ * security limitations if needed.
6
+ * This method only works if Appium Settings v. 2.15+ is installed
7
+ * on the device under test
8
+ *
9
+ * @this {import('../client').SettingsApp}
10
+ * @returns {Promise<string>} The actual content of the main clipboard as
11
+ * base64-encoded string or an empty string if the clipboard is empty
12
+ * @throws {Error} If there was a problem while getting the
13
+ * clipboard contant
14
+ */
15
+ export function getClipboard(this: import("../client").SettingsApp): Promise<string>;
16
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../lib/commands/clipboard.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,qEALa,QAAQ,MAAM,CAAC,CA6B3B"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getClipboard = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const logger_1 = require("../logger");
9
+ const constants_1 = require("../constants");
10
+ /**
11
+ * Retrieves the text content of the device's clipboard.
12
+ * The method works for Android below and above 29.
13
+ * It temorarily enforces the IME setting in order to workaround
14
+ * security limitations if needed.
15
+ * This method only works if Appium Settings v. 2.15+ is installed
16
+ * on the device under test
17
+ *
18
+ * @this {import('../client').SettingsApp}
19
+ * @returns {Promise<string>} The actual content of the main clipboard as
20
+ * base64-encoded string or an empty string if the clipboard is empty
21
+ * @throws {Error} If there was a problem while getting the
22
+ * clipboard contant
23
+ */
24
+ async function getClipboard() {
25
+ this.log.debug(logger_1.LOG_PREFIX, 'Getting the clipboard content');
26
+ await this.requireRunning({ shouldRestoreCurrentApp: true });
27
+ const retrieveClipboard = async () => await this.adb.shell([
28
+ 'am', 'broadcast',
29
+ '-n', constants_1.CLIPBOARD_RECEIVER,
30
+ '-a', constants_1.CLIPBOARD_RETRIEVAL_ACTION,
31
+ ]);
32
+ let output;
33
+ try {
34
+ output = (await this.adb.getApiLevel() >= 29)
35
+ ? (await this.adb.runInImeContext(constants_1.APPIUM_IME, retrieveClipboard))
36
+ : (await retrieveClipboard());
37
+ }
38
+ catch (err) {
39
+ throw new Error(`Cannot retrieve the current clipboard content from the device. ` +
40
+ `Make sure the Appium Settings application is up to date. ` +
41
+ `Original error: ${err.message}`);
42
+ }
43
+ const match = /data="([^"]*)"/.exec(output);
44
+ if (!match) {
45
+ throw new Error(`Cannot parse the actual cliboard content from the command output: ${output}`);
46
+ }
47
+ return lodash_1.default.trim(match[1]);
48
+ }
49
+ exports.getClipboard = getClipboard;
50
+ ;
51
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../../lib/commands/clipboard.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,sCAAuC;AACvC,4CAIsB;AAEtB;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,YAAY;IAChC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAU,EAAE,+BAA+B,CAAC,CAAC;IAC5D,MAAM,IAAI,CAAC,cAAc,CAAC,EAAC,uBAAuB,EAAE,IAAI,EAAC,CAAC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,KAAK,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QACzD,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,8BAAkB;QACxB,IAAI,EAAE,sCAA0B;KACjC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;YAC3C,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,sBAAU,EAAE,iBAAiB,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC,MAAM,iBAAiB,EAAE,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iEAAiE;YAC/E,2DAA2D;YAC3D,mBAAmB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,qEAAqE,MAAM,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,gBAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC;AAxBD,oCAwBC;AAAA,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @typedef {Object} Location
3
+ * @property {number|string} longitude - Valid longitude value.
4
+ * @property {number|string} latitude - Valid latitude value.
5
+ * @property {?number|string} [altitude] - Valid altitude value.
6
+ * @property {?number|string} [satellites=12] - Number of satellites being tracked (1-12).
7
+ * This value is ignored on real devices.
8
+ * @property {?number|string} [speed] - Valid speed value.
9
+ * Should be greater than 0.0 meters/second for real devices or 0.0 knots
10
+ * for emulators.
11
+ */
12
+ /**
13
+ * Emulate geolocation coordinates on the device under test.
14
+ *
15
+ * @this {import('../client').SettingsApp}
16
+ * @param {Location} location - Location object. The `altitude` value is ignored
17
+ * while mocking the position.
18
+ * @param {boolean} [isEmulator=false] - Set it to true if the device under test
19
+ * is an emulator rather than a real device.
20
+ */
21
+ export function setGeoLocation(this: import("../client").SettingsApp, location: Location, isEmulator?: boolean | undefined): Promise<void>;
22
+ /**
23
+ * Get the current cached GPS location from the device under test.
24
+ *
25
+ * @this {import('../client').SettingsApp}
26
+ * @returns {Promise<Location>} The current location
27
+ * @throws {Error} If the current location cannot be retrieved
28
+ */
29
+ export function getGeoLocation(this: import("../client").SettingsApp): Promise<Location>;
30
+ /**
31
+ * Sends an async request to refresh the GPS cache.
32
+ * This feature only works if the device under test has
33
+ * Google Play Services installed. In case the vanilla
34
+ * LocationManager is used the device API level must be at
35
+ * version 30 (Android R) or higher.
36
+ *
37
+ * @this {import('../client').SettingsApp}
38
+ * @param {number} timeoutMs The maximum number of milliseconds
39
+ * to block until GPS cache is refreshed. Providing zero or a negative
40
+ * value to it skips waiting completely.
41
+ *
42
+ * @throws {Error} If the GPS cache cannot be refreshed.
43
+ */
44
+ export function refreshGeoLocationCache(this: import("../client").SettingsApp, timeoutMs?: number): Promise<void>;
45
+ export type Location = {
46
+ /**
47
+ * - Valid longitude value.
48
+ */
49
+ longitude: number | string;
50
+ /**
51
+ * - Valid latitude value.
52
+ */
53
+ latitude: number | string;
54
+ /**
55
+ * - Valid altitude value.
56
+ */
57
+ altitude?: string | number | null | undefined;
58
+ /**
59
+ * - Number of satellites being tracked (1-12).
60
+ * This value is ignored on real devices.
61
+ */
62
+ satellites?: string | number | null | undefined;
63
+ /**
64
+ * - Valid speed value.
65
+ * Should be greater than 0.0 meters/second for real devices or 0.0 knots
66
+ * for emulators.
67
+ */
68
+ speed?: string | number | null | undefined;
69
+ };
70
+ //# sourceMappingURL=geolocation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geolocation.d.ts","sourceRoot":"","sources":["../../../lib/commands/geolocation.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AACH,gFALW,QAAQ,mDAoElB;AAED;;;;;;GAMG;AACH,uEAHa,QAAQ,QAAQ,CAAC,CA8B7B;AAED;;;;;;;;;;;;;GAaG;AACH,2FANW,MAAM,iBA+DhB;;;;;eA/La,MAAM,GAAC,MAAM;;;;cACb,MAAM,GAAC,MAAM"}