appium-adb 12.0.0 → 12.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.
- package/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/build/lib/tools/settings-client-commands.d.ts +0 -333
- package/build/lib/tools/settings-client-commands.d.ts.map +0 -1
- package/build/lib/tools/settings-client-commands.js +0 -655
- package/build/lib/tools/settings-client-commands.js.map +0 -1
- package/build/lib/tools/utf7.d.ts +0 -26
- package/build/lib/tools/utf7.d.ts.map +0 -1
- package/build/lib/tools/utf7.js +0 -144
- package/build/lib/tools/utf7.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [12.0.1](https://github.com/appium/appium-adb/compare/v12.0.0...v12.0.1) (2024-01-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Miscellaneous Chores
|
|
5
|
+
|
|
6
|
+
* Bump semantic-release from 22.0.12 to 23.0.0 ([#717](https://github.com/appium/appium-adb/issues/717)) ([cba0e91](https://github.com/appium/appium-adb/commit/cba0e9100e3364b73df28c21e1c2b4145933dd8b))
|
|
7
|
+
* use latest lts for the publishment ([0312fed](https://github.com/appium/appium-adb/commit/0312fedabf4373d59b5f5152f5add8750866a763))
|
|
8
|
+
|
|
1
9
|
## [11.1.0](https://github.com/appium/appium-adb/compare/v11.0.9...v11.1.0) (2024-01-09)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-adb",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "Android Debug Bridge interface",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"mocha": "^10.0.0",
|
|
100
100
|
"prettier": "^3.0.0",
|
|
101
101
|
"rimraf": "^5.0.0",
|
|
102
|
-
"semantic-release": "^
|
|
102
|
+
"semantic-release": "^23.0.0",
|
|
103
103
|
"sinon": "^17.0.0",
|
|
104
104
|
"temp": "^0.x",
|
|
105
105
|
"ts-node": "^10.9.1",
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
export default commands;
|
|
2
|
-
export type SettingsAppStartupOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* The maximum number of milliseconds
|
|
5
|
-
* to wait until the app has started
|
|
6
|
-
*/
|
|
7
|
-
timeout?: number | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Whether to restore
|
|
10
|
-
* the activity which was the current one before Settings startup
|
|
11
|
-
*/
|
|
12
|
-
shouldRestoreCurrentApp?: boolean | undefined;
|
|
13
|
-
};
|
|
14
|
-
export type Location = {
|
|
15
|
-
/**
|
|
16
|
-
* - Valid longitude value.
|
|
17
|
-
*/
|
|
18
|
-
longitude: number | string;
|
|
19
|
-
/**
|
|
20
|
-
* - Valid latitude value.
|
|
21
|
-
*/
|
|
22
|
-
latitude: number | string;
|
|
23
|
-
/**
|
|
24
|
-
* - Valid altitude value.
|
|
25
|
-
*/
|
|
26
|
-
altitude?: string | number | null | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* - Number of satellites being tracked (1-12).
|
|
29
|
-
* This value is ignored on real devices.
|
|
30
|
-
*/
|
|
31
|
-
satellites?: string | number | null | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* - Valid speed value.
|
|
34
|
-
* Should be greater than 0.0 meters/second for real devices or 0.0 knots
|
|
35
|
-
* for emulators.
|
|
36
|
-
*/
|
|
37
|
-
speed?: string | number | null | undefined;
|
|
38
|
-
};
|
|
39
|
-
export type SmsListOptions = {
|
|
40
|
-
/**
|
|
41
|
-
* - The maximum count of recent messages
|
|
42
|
-
* to retrieve
|
|
43
|
-
*/
|
|
44
|
-
max?: number | undefined;
|
|
45
|
-
};
|
|
46
|
-
export type SmsListResult = {
|
|
47
|
-
items: SmsListResultItem[];
|
|
48
|
-
total: number;
|
|
49
|
-
};
|
|
50
|
-
export type SmsListResultItem = {
|
|
51
|
-
id: string;
|
|
52
|
-
address: string;
|
|
53
|
-
person: string | null;
|
|
54
|
-
date: string;
|
|
55
|
-
read: string;
|
|
56
|
-
status: string;
|
|
57
|
-
type: string;
|
|
58
|
-
subject: string | null;
|
|
59
|
-
body: string;
|
|
60
|
-
serviceCenter: string | null;
|
|
61
|
-
};
|
|
62
|
-
export type SettingsClientCommands = typeof commands;
|
|
63
|
-
declare namespace commands {
|
|
64
|
-
/**
|
|
65
|
-
* @typedef {Object} SettingsAppStartupOptions
|
|
66
|
-
* @property {number} [timeout=5000] The maximum number of milliseconds
|
|
67
|
-
* to wait until the app has started
|
|
68
|
-
* @property {boolean} [shouldRestoreCurrentApp=false] Whether to restore
|
|
69
|
-
* the activity which was the current one before Settings startup
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* Ensures that Appium Settings helper application is running
|
|
73
|
-
* and starts it if necessary
|
|
74
|
-
*
|
|
75
|
-
* @this {import('../adb.js').ADB}
|
|
76
|
-
* @param {SettingsAppStartupOptions} [opts={}]
|
|
77
|
-
* @throws {Error} If Appium Settings has failed to start
|
|
78
|
-
* @returns {Promise<import('../adb.js').ADB>} self instance for chaining
|
|
79
|
-
*/
|
|
80
|
-
function requireRunningSettingsApp(this: import("../adb.js").ADB, opts?: SettingsAppStartupOptions | undefined): Promise<import("../adb.js").ADB>;
|
|
81
|
-
/**
|
|
82
|
-
* Change the state of WiFi on the device under test.
|
|
83
|
-
*
|
|
84
|
-
* @this {import('../adb.js').ADB}
|
|
85
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
86
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
87
|
-
* is an emulator rather than a real device.
|
|
88
|
-
*/
|
|
89
|
-
function setWifiState(this: import("../adb.js").ADB, on: boolean, isEmulator?: boolean | undefined): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Change the state of Data transfer on the device under test.
|
|
92
|
-
*
|
|
93
|
-
* @this {import('../adb.js').ADB}
|
|
94
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
95
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
96
|
-
* is an emulator rather than a real device.
|
|
97
|
-
*/
|
|
98
|
-
function setDataState(this: import("../adb.js").ADB, on: boolean, isEmulator?: boolean | undefined): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Change the state of animation on the device under test.
|
|
101
|
-
* Animation on the device is controlled by the following global properties:
|
|
102
|
-
* [ANIMATOR_DURATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#ANIMATOR_DURATION_SCALE},
|
|
103
|
-
* [TRANSITION_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#TRANSITION_ANIMATION_SCALE},
|
|
104
|
-
* [WINDOW_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#WINDOW_ANIMATION_SCALE}.
|
|
105
|
-
* This method sets all this properties to 0.0 to disable (1.0 to enable) animation.
|
|
106
|
-
*
|
|
107
|
-
* Turning off animation might be useful to improve stability
|
|
108
|
-
* and reduce tests execution time.
|
|
109
|
-
*
|
|
110
|
-
* @this {import('../adb.js').ADB}
|
|
111
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
112
|
-
*/
|
|
113
|
-
function setAnimationState(this: import("../adb.js").ADB, on: boolean): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Change the locale on the device under test. Don't need to reboot the device after changing the locale.
|
|
116
|
-
* This method sets an arbitrary locale following:
|
|
117
|
-
* https://developer.android.com/reference/java/util/Locale.html
|
|
118
|
-
* https://developer.android.com/reference/java/util/Locale.html#Locale(java.lang.String,%20java.lang.String)
|
|
119
|
-
*
|
|
120
|
-
* @this {import('../adb.js').ADB}
|
|
121
|
-
* @param {string} language - Language. e.g. en, ja
|
|
122
|
-
* @param {string} country - Country. e.g. US, JP
|
|
123
|
-
* @param {string?} [script=null] - Script. e.g. Hans in `zh-Hans-CN`
|
|
124
|
-
*/
|
|
125
|
-
function setDeviceSysLocaleViaSettingApp(this: import("../adb.js").ADB, language: string, country: string, script?: string | null | undefined): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* @typedef {Object} Location
|
|
128
|
-
* @property {number|string} longitude - Valid longitude value.
|
|
129
|
-
* @property {number|string} latitude - Valid latitude value.
|
|
130
|
-
* @property {?number|string} [altitude] - Valid altitude value.
|
|
131
|
-
* @property {?number|string} [satellites=12] - Number of satellites being tracked (1-12).
|
|
132
|
-
* This value is ignored on real devices.
|
|
133
|
-
* @property {?number|string} [speed] - Valid speed value.
|
|
134
|
-
* Should be greater than 0.0 meters/second for real devices or 0.0 knots
|
|
135
|
-
* for emulators.
|
|
136
|
-
*/
|
|
137
|
-
/**
|
|
138
|
-
* Emulate geolocation coordinates on the device under test.
|
|
139
|
-
*
|
|
140
|
-
* @this {import('../adb.js').ADB}
|
|
141
|
-
* @param {Location} location - Location object. The `altitude` value is ignored
|
|
142
|
-
* while mocking the position.
|
|
143
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
144
|
-
* is an emulator rather than a real device.
|
|
145
|
-
*/
|
|
146
|
-
function setGeoLocation(this: import("../adb.js").ADB, location: Location, isEmulator?: boolean | undefined): Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
* Get the current cached GPS location from the device under test.
|
|
149
|
-
*
|
|
150
|
-
* @this {import('../adb.js').ADB}
|
|
151
|
-
* @returns {Promise<Location>} The current location
|
|
152
|
-
* @throws {Error} If the current location cannot be retrieved
|
|
153
|
-
*/
|
|
154
|
-
function getGeoLocation(this: import("../adb.js").ADB): Promise<Location>;
|
|
155
|
-
/**
|
|
156
|
-
* Sends an async request to refresh the GPS cache.
|
|
157
|
-
* This feature only works if the device under test has
|
|
158
|
-
* Google Play Services installed. In case the vanilla
|
|
159
|
-
* LocationManager is used the device API level must be at
|
|
160
|
-
* version 30 (Android R) or higher.
|
|
161
|
-
*
|
|
162
|
-
* @this {import('../adb.js').ADB}
|
|
163
|
-
* @param {number} timeoutMs The maximum number of milliseconds
|
|
164
|
-
* to block until GPS cache is refreshed. Providing zero or a negative
|
|
165
|
-
* value to it skips waiting completely.
|
|
166
|
-
*
|
|
167
|
-
* @throws {Error} If the GPS cache cannot be refreshed.
|
|
168
|
-
*/
|
|
169
|
-
function refreshGeoLocationCache(this: import("../adb.js").ADB, timeoutMs?: number): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Performs the given editor action on the focused input field.
|
|
172
|
-
* This method requires Appium Settings helper to be installed on the device.
|
|
173
|
-
* No exception is thrown if there was a failure while performing the action.
|
|
174
|
-
* You must investigate the logcat output if something did not work as expected.
|
|
175
|
-
*
|
|
176
|
-
* @this {import('../adb.js').ADB}
|
|
177
|
-
* @param {string|number} action - Either action code or name. The following action
|
|
178
|
-
* names are supported: `normal, unspecified, none,
|
|
179
|
-
* go, search, send, next, done, previous`
|
|
180
|
-
*/
|
|
181
|
-
function performEditorAction(this: import("../adb.js").ADB, action: string | number): Promise<void>;
|
|
182
|
-
/**
|
|
183
|
-
* Retrieves the text content of the device's clipboard.
|
|
184
|
-
* The method works for Android below and above 29.
|
|
185
|
-
* It temorarily enforces the IME setting in order to workaround
|
|
186
|
-
* security limitations if needed.
|
|
187
|
-
* This method only works if Appium Settings v. 2.15+ is installed
|
|
188
|
-
* on the device under test
|
|
189
|
-
*
|
|
190
|
-
* @this {import('../adb.js').ADB}
|
|
191
|
-
* @returns {Promise<string>} The actual content of the main clipboard as
|
|
192
|
-
* base64-encoded string or an empty string if the clipboard is empty
|
|
193
|
-
* @throws {Error} If there was a problem while getting the
|
|
194
|
-
* clipboard contant
|
|
195
|
-
*/
|
|
196
|
-
function getClipboard(this: import("../adb.js").ADB): Promise<string>;
|
|
197
|
-
/**
|
|
198
|
-
* Retrieves Android notifications via Appium Settings helper.
|
|
199
|
-
* Appium Settings app itself must be *manually* granted to access notifications
|
|
200
|
-
* under device Settings in order to make this feature working.
|
|
201
|
-
* Appium Settings helper keeps all the active notifications plus
|
|
202
|
-
* notifications that appeared while it was running in the internal buffer,
|
|
203
|
-
* but no more than 100 items altogether. Newly appeared notifications
|
|
204
|
-
* are always added to the head of the notifications array.
|
|
205
|
-
* The `isRemoved` flag is set to `true` for notifications that have been removed.
|
|
206
|
-
*
|
|
207
|
-
* See https://developer.android.com/reference/android/service/notification/StatusBarNotification
|
|
208
|
-
* and https://developer.android.com/reference/android/app/Notification.html
|
|
209
|
-
* for more information on available notification properties and their values.
|
|
210
|
-
*
|
|
211
|
-
* @this {import('../adb.js').ADB}
|
|
212
|
-
* @returns {Promise<import('@appium/types').StringRecord>} The example output is:
|
|
213
|
-
* ```json
|
|
214
|
-
* {
|
|
215
|
-
* "statusBarNotifications":[
|
|
216
|
-
* {
|
|
217
|
-
* "isGroup":false,
|
|
218
|
-
* "packageName":"io.appium.settings",
|
|
219
|
-
* "isClearable":false,
|
|
220
|
-
* "isOngoing":true,
|
|
221
|
-
* "id":1,
|
|
222
|
-
* "tag":null,
|
|
223
|
-
* "notification":{
|
|
224
|
-
* "title":null,
|
|
225
|
-
* "bigTitle":"Appium Settings",
|
|
226
|
-
* "text":null,
|
|
227
|
-
* "bigText":"Keep this service running, so Appium for Android can properly interact with several system APIs",
|
|
228
|
-
* "tickerText":null,
|
|
229
|
-
* "subText":null,
|
|
230
|
-
* "infoText":null,
|
|
231
|
-
* "template":"android.app.Notification$BigTextStyle"
|
|
232
|
-
* },
|
|
233
|
-
* "userHandle":0,
|
|
234
|
-
* "groupKey":"0|io.appium.settings|1|null|10133",
|
|
235
|
-
* "overrideGroupKey":null,
|
|
236
|
-
* "postTime":1576853518850,
|
|
237
|
-
* "key":"0|io.appium.settings|1|null|10133",
|
|
238
|
-
* "isRemoved":false
|
|
239
|
-
* }
|
|
240
|
-
* ]
|
|
241
|
-
* }
|
|
242
|
-
* ```
|
|
243
|
-
* @throws {Error} If there was an error while getting the notifications list
|
|
244
|
-
*/
|
|
245
|
-
function getNotifications(this: import("../adb.js").ADB): Promise<import("@appium/types").StringRecord<any>>;
|
|
246
|
-
/**
|
|
247
|
-
* @typedef {Object} SmsListOptions
|
|
248
|
-
* @property {number} [max=100] - The maximum count of recent messages
|
|
249
|
-
* to retrieve
|
|
250
|
-
*/
|
|
251
|
-
/**
|
|
252
|
-
* @typedef SmsListResult
|
|
253
|
-
* @property {SmsListResultItem[]} items
|
|
254
|
-
* @property {number} total
|
|
255
|
-
*/
|
|
256
|
-
/**
|
|
257
|
-
* @privateRemarks XXX: WAG
|
|
258
|
-
* @typedef SmsListResultItem
|
|
259
|
-
* @property {string} id
|
|
260
|
-
* @property {string} address
|
|
261
|
-
* @property {string|null} person
|
|
262
|
-
* @property {string} date
|
|
263
|
-
* @property {string} read
|
|
264
|
-
* @property {string} status
|
|
265
|
-
* @property {string} type
|
|
266
|
-
* @property {string|null} subject
|
|
267
|
-
* @property {string} body
|
|
268
|
-
* @property {string|null} serviceCenter
|
|
269
|
-
*/
|
|
270
|
-
/**
|
|
271
|
-
* Retrieves the list of the most recent SMS
|
|
272
|
-
* properties list via Appium Settings helper.
|
|
273
|
-
* Messages are sorted by date in descending order.
|
|
274
|
-
*
|
|
275
|
-
* @this {import('../adb.js').ADB}
|
|
276
|
-
* @param {SmsListOptions} opts
|
|
277
|
-
* @returns {Promise<SmsListResult>} The example output is:
|
|
278
|
-
* ```json
|
|
279
|
-
* {
|
|
280
|
-
* "items":[
|
|
281
|
-
* {
|
|
282
|
-
* "id":"2",
|
|
283
|
-
* "address":"+123456789",
|
|
284
|
-
* "person":null,
|
|
285
|
-
* "date":"1581936422203",
|
|
286
|
-
* "read":"0",
|
|
287
|
-
* "status":"-1",
|
|
288
|
-
* "type":"1",
|
|
289
|
-
* "subject":null,
|
|
290
|
-
* "body":"\"text message2\"",
|
|
291
|
-
* "serviceCenter":null
|
|
292
|
-
* },
|
|
293
|
-
* {
|
|
294
|
-
* "id":"1",
|
|
295
|
-
* "address":"+123456789",
|
|
296
|
-
* "person":null,
|
|
297
|
-
* "date":"1581936382740",
|
|
298
|
-
* "read":"0",
|
|
299
|
-
* "status":"-1",
|
|
300
|
-
* "type":"1",
|
|
301
|
-
* "subject":null,
|
|
302
|
-
* "body":"\"text message\"",
|
|
303
|
-
* "serviceCenter":null
|
|
304
|
-
* }
|
|
305
|
-
* ],
|
|
306
|
-
* "total":2
|
|
307
|
-
* }
|
|
308
|
-
* ```
|
|
309
|
-
* @throws {Error} If there was an error while getting the SMS list
|
|
310
|
-
*/
|
|
311
|
-
function getSmsList(this: import("../adb.js").ADB, opts?: SmsListOptions): Promise<SmsListResult>;
|
|
312
|
-
/**
|
|
313
|
-
* Types the given Unicode string.
|
|
314
|
-
* It is expected that the focus is already put
|
|
315
|
-
* to the destination input field before this method is called.
|
|
316
|
-
*
|
|
317
|
-
* @this {import('../adb.js').ADB}
|
|
318
|
-
* @param {string} text The string to type
|
|
319
|
-
* @returns {Promise<boolean>} `true` if the input text has been successfully sent to adb
|
|
320
|
-
*/
|
|
321
|
-
function typeUnicode(this: import("../adb.js").ADB, text: string): Promise<boolean>;
|
|
322
|
-
/**
|
|
323
|
-
* Performs recursive media scan at the given destination.
|
|
324
|
-
* All successfully scanned items are being added to the device's
|
|
325
|
-
* media library.
|
|
326
|
-
*
|
|
327
|
-
* @this {import('../adb.js').ADB}
|
|
328
|
-
* @param {string} destination File/folder path on the remote device.
|
|
329
|
-
* @throws {Error} If there was an unexpected error by scanning.
|
|
330
|
-
*/
|
|
331
|
-
function scanMedia(this: import("../adb.js").ADB, destination: string): Promise<void>;
|
|
332
|
-
}
|
|
333
|
-
//# sourceMappingURL=settings-client-commands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-client-commands.d.ts","sourceRoot":"","sources":["../../../lib/tools/settings-client-commands.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;eAgOc,MAAM,GAAC,MAAM;;;;cACb,MAAM,GAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;WAsUb,iBAAiB,EAAE;WACnB,MAAM;;;QAMN,MAAM;aACN,MAAM;YACN,MAAM,GAAC,IAAI;UACX,MAAM;UACN,MAAM;YACN,MAAM;UACN,MAAM;aACN,MAAM,GAAC,IAAI;UACX,MAAM;mBACN,MAAM,GAAC,IAAI;;qCAsHZ,eAAe;;IAloB5B;;;;;;OAMG;IAEH;;;;;;;;OAQG;IACH,kJA0CC;IAED;;;;;;;OAOG;IACH,mHAyBC;IAED;;;;;;;OAOG;IACH,mHAsBC;IAED;;;;;;;;;;;;;OAaG;IACH,sFAOC;IAED;;;;;;;;;;OAUG;IACH,8JAcC;IAGD;;;;;;;;;;OAUG;IAEH;;;;;;;;OAQG;IACH,4HA+DC;IAED;;;;;;OAMG;IACH,0EA2BC;IAED;;;;;;;;;;;;;OAaG;IACH,mGAyDC;IAED;;;;;;;;;;OAUG;IACH,oGAIC;IAED;;;;;;;;;;;;;OAaG;IACH,sEAwBC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,6GAmBC;IAED;;;;OAIG;IAEH;;;;OAIG;IAEH;;;;;;;;;;;;;OAaG;IAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,kGAoBC;IAED;;;;;;;;OAQG;IACH,oFAcC;IAED;;;;;;;;OAQG;IACH,sFAaC"}
|
|
@@ -1,655 +0,0 @@
|
|
|
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
|
-
const logger_js_1 = __importDefault(require("../logger.js"));
|
|
7
|
-
const helpers_js_1 = require("../helpers.js");
|
|
8
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
-
const support_1 = require("@appium/support");
|
|
10
|
-
const asyncbox_1 = require("asyncbox");
|
|
11
|
-
const utf7_1 = require("./utf7");
|
|
12
|
-
const teen_process_1 = require("teen_process");
|
|
13
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
14
|
-
const SETTINGS_HELPER_ID = 'io.appium.settings';
|
|
15
|
-
const SETTINGS_HELPER_MAIN_ACTIVITY = '.Settings';
|
|
16
|
-
const WIFI_CONNECTION_SETTING_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.WiFiConnectionSettingReceiver`;
|
|
17
|
-
const WIFI_CONNECTION_SETTING_ACTION = `${SETTINGS_HELPER_ID}.wifi`;
|
|
18
|
-
const DATA_CONNECTION_SETTING_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.DataConnectionSettingReceiver`;
|
|
19
|
-
const DATA_CONNECTION_SETTING_ACTION = `${SETTINGS_HELPER_ID}.data_connection`;
|
|
20
|
-
const ANIMATION_SETTING_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.AnimationSettingReceiver`;
|
|
21
|
-
const ANIMATION_SETTING_ACTION = `${SETTINGS_HELPER_ID}.animation`;
|
|
22
|
-
const LOCALE_SETTING_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.LocaleSettingReceiver`;
|
|
23
|
-
const LOCALE_SETTING_ACTION = `${SETTINGS_HELPER_ID}.locale`;
|
|
24
|
-
const LOCATION_SERVICE = `${SETTINGS_HELPER_ID}/.LocationService`;
|
|
25
|
-
const LOCATION_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.LocationInfoReceiver`;
|
|
26
|
-
const LOCATION_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.location`;
|
|
27
|
-
const CLIPBOARD_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.ClipboardReceiver`;
|
|
28
|
-
const CLIPBOARD_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.clipboard.get`;
|
|
29
|
-
const NOTIFICATIONS_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.notifications`;
|
|
30
|
-
const SMS_LIST_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.SmsReader`;
|
|
31
|
-
const SMS_LIST_RETRIEVAL_ACTION = `${SETTINGS_HELPER_ID}.sms.read`;
|
|
32
|
-
const MEDIA_SCAN_RECEIVER = `${SETTINGS_HELPER_ID}/.receivers.MediaScannerReceiver`;
|
|
33
|
-
const MEDIA_SCAN_ACTION = `${SETTINGS_HELPER_ID}.scan_media`;
|
|
34
|
-
const APPIUM_IME = `${SETTINGS_HELPER_ID}/.AppiumIME`;
|
|
35
|
-
const UNICODE_IME = `${SETTINGS_HELPER_ID}/.UnicodeIME`;
|
|
36
|
-
const DEFAULT_SATELLITES_COUNT = 12;
|
|
37
|
-
const DEFAULT_ALTITUDE = 0.0;
|
|
38
|
-
const LOCATION_TRACKER_TAG = 'LocationTracker';
|
|
39
|
-
const GPS_CACHE_REFRESHED_LOGS = [
|
|
40
|
-
'The current location has been successfully retrieved from Play Services',
|
|
41
|
-
'The current location has been successfully retrieved from Location Manager'
|
|
42
|
-
];
|
|
43
|
-
const GPS_COORDINATES_PATTERN = /data="(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)"/;
|
|
44
|
-
const commands = {};
|
|
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
|
-
* @this {import('../adb.js').ADB}
|
|
57
|
-
* @param {SettingsAppStartupOptions} [opts={}]
|
|
58
|
-
* @throws {Error} If Appium Settings has failed to start
|
|
59
|
-
* @returns {Promise<import('../adb.js').ADB>} self instance for chaining
|
|
60
|
-
*/
|
|
61
|
-
commands.requireRunningSettingsApp = async function requireRunningSettingsApp(opts = {}) {
|
|
62
|
-
if (await this.processExists(SETTINGS_HELPER_ID)) {
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
logger_js_1.default.debug('Starting Appium Settings app');
|
|
66
|
-
const { timeout = 5000, shouldRestoreCurrentApp = false, } = opts;
|
|
67
|
-
let appPackage;
|
|
68
|
-
if (shouldRestoreCurrentApp) {
|
|
69
|
-
try {
|
|
70
|
-
({ appPackage } = await this.getFocusedPackageAndActivity());
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
logger_js_1.default.warn(`The current application can not be restored: ${e.message}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
await this.startApp({
|
|
77
|
-
pkg: SETTINGS_HELPER_ID,
|
|
78
|
-
activity: SETTINGS_HELPER_MAIN_ACTIVITY,
|
|
79
|
-
action: 'android.intent.action.MAIN',
|
|
80
|
-
category: 'android.intent.category.LAUNCHER',
|
|
81
|
-
stopApp: false,
|
|
82
|
-
waitForLaunch: false,
|
|
83
|
-
});
|
|
84
|
-
try {
|
|
85
|
-
await (0, asyncbox_1.waitForCondition)(async () => await this.processExists(SETTINGS_HELPER_ID), {
|
|
86
|
-
waitMs: timeout,
|
|
87
|
-
intervalMs: 300,
|
|
88
|
-
});
|
|
89
|
-
if (shouldRestoreCurrentApp && appPackage) {
|
|
90
|
-
try {
|
|
91
|
-
await this.activateApp(appPackage);
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
logger_js_1.default.warn(`The current application can not be restored: ${e.message}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
catch (err) {
|
|
100
|
-
throw new Error(`Appium Settings app is not running after ${timeout}ms`);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Change the state of WiFi on the device under test.
|
|
105
|
-
*
|
|
106
|
-
* @this {import('../adb.js').ADB}
|
|
107
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
108
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
109
|
-
* is an emulator rather than a real device.
|
|
110
|
-
*/
|
|
111
|
-
commands.setWifiState = async function setWifiState(on, isEmulator = false) {
|
|
112
|
-
if (isEmulator) {
|
|
113
|
-
// The svc command does not require to be root since API 26
|
|
114
|
-
await this.shell(['svc', 'wifi', on ? 'enable' : 'disable'], {
|
|
115
|
-
privileged: await this.getApiLevel() < 26,
|
|
116
|
-
});
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (await this.getApiLevel() < 30) {
|
|
120
|
-
// Android below API 30 does not have a dedicated adb command
|
|
121
|
-
// to manipulate wifi connection state, so try to do it via Settings app
|
|
122
|
-
// as a workaround
|
|
123
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
124
|
-
await this.shell([
|
|
125
|
-
'am', 'broadcast',
|
|
126
|
-
'-a', WIFI_CONNECTION_SETTING_ACTION,
|
|
127
|
-
'-n', WIFI_CONNECTION_SETTING_RECEIVER,
|
|
128
|
-
'--es', 'setstatus', on ? 'enable' : 'disable'
|
|
129
|
-
]);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
await this.shell(['cmd', '-w', 'wifi', 'set-wifi-enabled', on ? 'enabled' : 'disabled']);
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Change the state of Data transfer on the device under test.
|
|
136
|
-
*
|
|
137
|
-
* @this {import('../adb.js').ADB}
|
|
138
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
139
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
140
|
-
* is an emulator rather than a real device.
|
|
141
|
-
*/
|
|
142
|
-
commands.setDataState = async function setDataState(on, isEmulator = false) {
|
|
143
|
-
if (isEmulator) {
|
|
144
|
-
// The svc command does not require to be root since API 26
|
|
145
|
-
await this.shell(['svc', 'data', on ? 'enable' : 'disable'], {
|
|
146
|
-
privileged: await this.getApiLevel() < 26,
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (await this.getApiLevel() < 30) {
|
|
151
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
152
|
-
await this.shell([
|
|
153
|
-
'am', 'broadcast',
|
|
154
|
-
'-a', DATA_CONNECTION_SETTING_ACTION,
|
|
155
|
-
'-n', DATA_CONNECTION_SETTING_RECEIVER,
|
|
156
|
-
'--es', 'setstatus', on ? 'enable' : 'disable'
|
|
157
|
-
]);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
await this.shell(['cmd', 'phone', 'data', on ? 'enable' : 'disable']);
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Change the state of animation on the device under test.
|
|
164
|
-
* Animation on the device is controlled by the following global properties:
|
|
165
|
-
* [ANIMATOR_DURATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#ANIMATOR_DURATION_SCALE},
|
|
166
|
-
* [TRANSITION_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#TRANSITION_ANIMATION_SCALE},
|
|
167
|
-
* [WINDOW_ANIMATION_SCALE]{@link https://developer.android.com/reference/android/provider/Settings.Global.html#WINDOW_ANIMATION_SCALE}.
|
|
168
|
-
* This method sets all this properties to 0.0 to disable (1.0 to enable) animation.
|
|
169
|
-
*
|
|
170
|
-
* Turning off animation might be useful to improve stability
|
|
171
|
-
* and reduce tests execution time.
|
|
172
|
-
*
|
|
173
|
-
* @this {import('../adb.js').ADB}
|
|
174
|
-
* @param {boolean} on - True to enable and false to disable it.
|
|
175
|
-
*/
|
|
176
|
-
commands.setAnimationState = async function setAnimationState(on) {
|
|
177
|
-
await this.shell([
|
|
178
|
-
'am', 'broadcast',
|
|
179
|
-
'-a', ANIMATION_SETTING_ACTION,
|
|
180
|
-
'-n', ANIMATION_SETTING_RECEIVER,
|
|
181
|
-
'--es', 'setstatus', on ? 'enable' : 'disable'
|
|
182
|
-
]);
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Change the locale on the device under test. Don't need to reboot the device after changing the locale.
|
|
186
|
-
* This method sets an arbitrary locale following:
|
|
187
|
-
* https://developer.android.com/reference/java/util/Locale.html
|
|
188
|
-
* https://developer.android.com/reference/java/util/Locale.html#Locale(java.lang.String,%20java.lang.String)
|
|
189
|
-
*
|
|
190
|
-
* @this {import('../adb.js').ADB}
|
|
191
|
-
* @param {string} language - Language. e.g. en, ja
|
|
192
|
-
* @param {string} country - Country. e.g. US, JP
|
|
193
|
-
* @param {string?} [script=null] - Script. e.g. Hans in `zh-Hans-CN`
|
|
194
|
-
*/
|
|
195
|
-
commands.setDeviceSysLocaleViaSettingApp = async function setDeviceSysLocaleViaSettingApp(language, country, script = null) {
|
|
196
|
-
const params = [
|
|
197
|
-
'am', 'broadcast',
|
|
198
|
-
'-a', LOCALE_SETTING_ACTION,
|
|
199
|
-
'-n', LOCALE_SETTING_RECEIVER,
|
|
200
|
-
'--es', 'lang', language.toLowerCase(),
|
|
201
|
-
'--es', 'country', country.toUpperCase()
|
|
202
|
-
];
|
|
203
|
-
if (script) {
|
|
204
|
-
params.push('--es', 'script', script);
|
|
205
|
-
}
|
|
206
|
-
await this.shell(params);
|
|
207
|
-
};
|
|
208
|
-
/**
|
|
209
|
-
* @typedef {Object} Location
|
|
210
|
-
* @property {number|string} longitude - Valid longitude value.
|
|
211
|
-
* @property {number|string} latitude - Valid latitude value.
|
|
212
|
-
* @property {?number|string} [altitude] - Valid altitude value.
|
|
213
|
-
* @property {?number|string} [satellites=12] - Number of satellites being tracked (1-12).
|
|
214
|
-
* This value is ignored on real devices.
|
|
215
|
-
* @property {?number|string} [speed] - Valid speed value.
|
|
216
|
-
* Should be greater than 0.0 meters/second for real devices or 0.0 knots
|
|
217
|
-
* for emulators.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* Emulate geolocation coordinates on the device under test.
|
|
221
|
-
*
|
|
222
|
-
* @this {import('../adb.js').ADB}
|
|
223
|
-
* @param {Location} location - Location object. The `altitude` value is ignored
|
|
224
|
-
* while mocking the position.
|
|
225
|
-
* @param {boolean} [isEmulator=false] - Set it to true if the device under test
|
|
226
|
-
* is an emulator rather than a real device.
|
|
227
|
-
*/
|
|
228
|
-
commands.setGeoLocation = async function setGeoLocation(location, isEmulator = false) {
|
|
229
|
-
const formatLocationValue = (valueName, isRequired = true) => {
|
|
230
|
-
if (!support_1.util.hasValue(location[valueName])) {
|
|
231
|
-
if (isRequired) {
|
|
232
|
-
throw new Error(`${valueName} must be provided`);
|
|
233
|
-
}
|
|
234
|
-
return null;
|
|
235
|
-
}
|
|
236
|
-
const floatValue = parseFloat(location[valueName]);
|
|
237
|
-
if (!isNaN(floatValue)) {
|
|
238
|
-
return `${lodash_1.default.ceil(floatValue, 5)}`;
|
|
239
|
-
}
|
|
240
|
-
if (isRequired) {
|
|
241
|
-
throw new Error(`${valueName} is expected to be a valid float number. ` +
|
|
242
|
-
`'${location[valueName]}' is given instead`);
|
|
243
|
-
}
|
|
244
|
-
return null;
|
|
245
|
-
};
|
|
246
|
-
const longitude = /** @type {string} */ (formatLocationValue('longitude'));
|
|
247
|
-
const latitude = /** @type {string} */ (formatLocationValue('latitude'));
|
|
248
|
-
const altitude = formatLocationValue('altitude', false);
|
|
249
|
-
const speed = formatLocationValue('speed', false);
|
|
250
|
-
if (isEmulator) {
|
|
251
|
-
/** @type {string[]} */
|
|
252
|
-
const args = [longitude, latitude];
|
|
253
|
-
if (!lodash_1.default.isNil(altitude)) {
|
|
254
|
-
args.push(altitude);
|
|
255
|
-
}
|
|
256
|
-
const satellites = parseInt(`${location.satellites}`, 10);
|
|
257
|
-
if (!Number.isNaN(satellites) && satellites > 0 && satellites <= 12) {
|
|
258
|
-
if (args.length < 3) {
|
|
259
|
-
args.push(`${DEFAULT_ALTITUDE}`);
|
|
260
|
-
}
|
|
261
|
-
args.push(`${satellites}`);
|
|
262
|
-
}
|
|
263
|
-
if (!lodash_1.default.isNil(speed)) {
|
|
264
|
-
if (args.length < 3) {
|
|
265
|
-
args.push(`${DEFAULT_ALTITUDE}`);
|
|
266
|
-
}
|
|
267
|
-
if (args.length < 4) {
|
|
268
|
-
args.push(`${DEFAULT_SATELLITES_COUNT}`);
|
|
269
|
-
}
|
|
270
|
-
args.push(speed);
|
|
271
|
-
}
|
|
272
|
-
await this.resetTelnetAuthToken();
|
|
273
|
-
await this.adbExec(['emu', 'geo', 'fix', ...args]);
|
|
274
|
-
// A workaround for https://code.google.com/p/android/issues/detail?id=206180
|
|
275
|
-
await this.adbExec(['emu', 'geo', 'fix', ...(args.map((arg) => arg.replace('.', ',')))]);
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
const args = [
|
|
279
|
-
'am', (await this.getApiLevel() >= 26) ? 'start-foreground-service' : 'startservice',
|
|
280
|
-
'-e', 'longitude', longitude,
|
|
281
|
-
'-e', 'latitude', latitude,
|
|
282
|
-
];
|
|
283
|
-
if (support_1.util.hasValue(altitude)) {
|
|
284
|
-
args.push('-e', 'altitude', altitude);
|
|
285
|
-
}
|
|
286
|
-
if (support_1.util.hasValue(speed)) {
|
|
287
|
-
args.push('-e', 'speed', speed);
|
|
288
|
-
}
|
|
289
|
-
args.push(LOCATION_SERVICE);
|
|
290
|
-
await this.shell(args);
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* Get the current cached GPS location from the device under test.
|
|
295
|
-
*
|
|
296
|
-
* @this {import('../adb.js').ADB}
|
|
297
|
-
* @returns {Promise<Location>} The current location
|
|
298
|
-
* @throws {Error} If the current location cannot be retrieved
|
|
299
|
-
*/
|
|
300
|
-
commands.getGeoLocation = async function getGeoLocation() {
|
|
301
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
302
|
-
let output;
|
|
303
|
-
try {
|
|
304
|
-
output = await this.shell([
|
|
305
|
-
'am', 'broadcast',
|
|
306
|
-
'-n', LOCATION_RECEIVER,
|
|
307
|
-
'-a', LOCATION_RETRIEVAL_ACTION,
|
|
308
|
-
]);
|
|
309
|
-
}
|
|
310
|
-
catch (err) {
|
|
311
|
-
throw new Error(`Cannot retrieve the current geo coordinates from the device. ` +
|
|
312
|
-
`Make sure the Appium Settings application is up to date and has location permissions. Also the location ` +
|
|
313
|
-
`services must be enabled on the device. Original error: ${err.stderr || err.stdout || err.message}`);
|
|
314
|
-
}
|
|
315
|
-
const match = GPS_COORDINATES_PATTERN.exec(output);
|
|
316
|
-
if (!match) {
|
|
317
|
-
throw new Error(`Cannot parse the actual location values from the command output: ${output}`);
|
|
318
|
-
}
|
|
319
|
-
const location = {
|
|
320
|
-
latitude: match[1],
|
|
321
|
-
longitude: match[2],
|
|
322
|
-
altitude: match[3],
|
|
323
|
-
};
|
|
324
|
-
logger_js_1.default.debug(`Got geo coordinates: ${JSON.stringify(location)}`);
|
|
325
|
-
return location;
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Sends an async request to refresh the GPS cache.
|
|
329
|
-
* This feature only works if the device under test has
|
|
330
|
-
* Google Play Services installed. In case the vanilla
|
|
331
|
-
* LocationManager is used the device API level must be at
|
|
332
|
-
* version 30 (Android R) or higher.
|
|
333
|
-
*
|
|
334
|
-
* @this {import('../adb.js').ADB}
|
|
335
|
-
* @param {number} timeoutMs The maximum number of milliseconds
|
|
336
|
-
* to block until GPS cache is refreshed. Providing zero or a negative
|
|
337
|
-
* value to it skips waiting completely.
|
|
338
|
-
*
|
|
339
|
-
* @throws {Error} If the GPS cache cannot be refreshed.
|
|
340
|
-
*/
|
|
341
|
-
commands.refreshGeoLocationCache = async function refreshGeoLocationCache(timeoutMs = 20000) {
|
|
342
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
343
|
-
let logcatMonitor;
|
|
344
|
-
let monitoringPromise;
|
|
345
|
-
if (timeoutMs > 0) {
|
|
346
|
-
const cmd = [
|
|
347
|
-
...this.executable.defaultArgs,
|
|
348
|
-
'logcat', '-s', LOCATION_TRACKER_TAG,
|
|
349
|
-
];
|
|
350
|
-
logcatMonitor = new teen_process_1.SubProcess(this.executable.path, cmd);
|
|
351
|
-
const timeoutErrorMsg = `The GPS cache has not been refreshed within ${timeoutMs}ms timeout. ` +
|
|
352
|
-
`Please make sure the device under test has Appium Settings app installed and running. ` +
|
|
353
|
-
`Also, it is required that the device has Google Play Services installed or is running ` +
|
|
354
|
-
`Android 10+ otherwise.`;
|
|
355
|
-
monitoringPromise = new bluebird_1.default((resolve, reject) => {
|
|
356
|
-
setTimeout(() => reject(new Error(timeoutErrorMsg)), timeoutMs);
|
|
357
|
-
logcatMonitor.on('exit', () => reject(new Error(timeoutErrorMsg)));
|
|
358
|
-
['lines-stderr', 'lines-stdout'].map((evt) => logcatMonitor.on(evt, (lines) => {
|
|
359
|
-
if (lines.some((line) => GPS_CACHE_REFRESHED_LOGS.some((x) => line.includes(x)))) {
|
|
360
|
-
resolve();
|
|
361
|
-
}
|
|
362
|
-
}));
|
|
363
|
-
});
|
|
364
|
-
await logcatMonitor.start(0);
|
|
365
|
-
}
|
|
366
|
-
try {
|
|
367
|
-
await this.shell([
|
|
368
|
-
'am', 'broadcast',
|
|
369
|
-
'-n', LOCATION_RECEIVER,
|
|
370
|
-
'-a', LOCATION_RETRIEVAL_ACTION,
|
|
371
|
-
'--ez', 'forceUpdate', 'true',
|
|
372
|
-
]);
|
|
373
|
-
}
|
|
374
|
-
catch (err) {
|
|
375
|
-
throw new Error(`Cannot refresh the GPS cache on the device. ` +
|
|
376
|
-
`Make sure the Appium Settings application is up to date and has location permissions. Also the location ` +
|
|
377
|
-
`services must be enabled on the device. Original error: ${err.stderr || err.stdout || err.message}`);
|
|
378
|
-
}
|
|
379
|
-
if (logcatMonitor && monitoringPromise) {
|
|
380
|
-
const timer = new support_1.timing.Timer().start();
|
|
381
|
-
logger_js_1.default.debug(`Waiting up to ${timeoutMs}ms for the GPS cache to be refreshed`);
|
|
382
|
-
try {
|
|
383
|
-
await monitoringPromise;
|
|
384
|
-
logger_js_1.default.info(`The GPS cache has been successfully refreshed after ` +
|
|
385
|
-
`${timer.getDuration().asMilliSeconds.toFixed(0)}ms`);
|
|
386
|
-
}
|
|
387
|
-
finally {
|
|
388
|
-
if (logcatMonitor.isRunning) {
|
|
389
|
-
await logcatMonitor.stop();
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
logger_js_1.default.info('The request to refresh the GPS cache has been sent. Skipping waiting for its result.');
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
/**
|
|
398
|
-
* Performs the given editor action on the focused input field.
|
|
399
|
-
* This method requires Appium Settings helper to be installed on the device.
|
|
400
|
-
* No exception is thrown if there was a failure while performing the action.
|
|
401
|
-
* You must investigate the logcat output if something did not work as expected.
|
|
402
|
-
*
|
|
403
|
-
* @this {import('../adb.js').ADB}
|
|
404
|
-
* @param {string|number} action - Either action code or name. The following action
|
|
405
|
-
* names are supported: `normal, unspecified, none,
|
|
406
|
-
* go, search, send, next, done, previous`
|
|
407
|
-
*/
|
|
408
|
-
commands.performEditorAction = async function performEditorAction(action) {
|
|
409
|
-
logger_js_1.default.debug(`Performing editor action: ${action}`);
|
|
410
|
-
await this.runInImeContext(APPIUM_IME, async () => await this.shell(['input', 'text', `/${action}/`]));
|
|
411
|
-
};
|
|
412
|
-
/**
|
|
413
|
-
* Retrieves the text content of the device's clipboard.
|
|
414
|
-
* The method works for Android below and above 29.
|
|
415
|
-
* It temorarily enforces the IME setting in order to workaround
|
|
416
|
-
* security limitations if needed.
|
|
417
|
-
* This method only works if Appium Settings v. 2.15+ is installed
|
|
418
|
-
* on the device under test
|
|
419
|
-
*
|
|
420
|
-
* @this {import('../adb.js').ADB}
|
|
421
|
-
* @returns {Promise<string>} The actual content of the main clipboard as
|
|
422
|
-
* base64-encoded string or an empty string if the clipboard is empty
|
|
423
|
-
* @throws {Error} If there was a problem while getting the
|
|
424
|
-
* clipboard contant
|
|
425
|
-
*/
|
|
426
|
-
commands.getClipboard = async function getClipboard() {
|
|
427
|
-
logger_js_1.default.debug('Getting the clipboard content');
|
|
428
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
429
|
-
const retrieveClipboard = async () => await this.shell([
|
|
430
|
-
'am', 'broadcast',
|
|
431
|
-
'-n', CLIPBOARD_RECEIVER,
|
|
432
|
-
'-a', CLIPBOARD_RETRIEVAL_ACTION,
|
|
433
|
-
]);
|
|
434
|
-
let output;
|
|
435
|
-
try {
|
|
436
|
-
output = (await this.getApiLevel() >= 29)
|
|
437
|
-
? (await this.runInImeContext(APPIUM_IME, retrieveClipboard))
|
|
438
|
-
: (await retrieveClipboard());
|
|
439
|
-
}
|
|
440
|
-
catch (err) {
|
|
441
|
-
throw new Error(`Cannot retrieve the current clipboard content from the device. ` +
|
|
442
|
-
`Make sure the Appium Settings application is up to date. ` +
|
|
443
|
-
`Original error: ${err.message}`);
|
|
444
|
-
}
|
|
445
|
-
const match = /data="([^"]*)"/.exec(output);
|
|
446
|
-
if (!match) {
|
|
447
|
-
throw new Error(`Cannot parse the actual cliboard content from the command output: ${output}`);
|
|
448
|
-
}
|
|
449
|
-
return lodash_1.default.trim(match[1]);
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Retrieves Android notifications via Appium Settings helper.
|
|
453
|
-
* Appium Settings app itself must be *manually* granted to access notifications
|
|
454
|
-
* under device Settings in order to make this feature working.
|
|
455
|
-
* Appium Settings helper keeps all the active notifications plus
|
|
456
|
-
* notifications that appeared while it was running in the internal buffer,
|
|
457
|
-
* but no more than 100 items altogether. Newly appeared notifications
|
|
458
|
-
* are always added to the head of the notifications array.
|
|
459
|
-
* The `isRemoved` flag is set to `true` for notifications that have been removed.
|
|
460
|
-
*
|
|
461
|
-
* See https://developer.android.com/reference/android/service/notification/StatusBarNotification
|
|
462
|
-
* and https://developer.android.com/reference/android/app/Notification.html
|
|
463
|
-
* for more information on available notification properties and their values.
|
|
464
|
-
*
|
|
465
|
-
* @this {import('../adb.js').ADB}
|
|
466
|
-
* @returns {Promise<import('@appium/types').StringRecord>} The example output is:
|
|
467
|
-
* ```json
|
|
468
|
-
* {
|
|
469
|
-
* "statusBarNotifications":[
|
|
470
|
-
* {
|
|
471
|
-
* "isGroup":false,
|
|
472
|
-
* "packageName":"io.appium.settings",
|
|
473
|
-
* "isClearable":false,
|
|
474
|
-
* "isOngoing":true,
|
|
475
|
-
* "id":1,
|
|
476
|
-
* "tag":null,
|
|
477
|
-
* "notification":{
|
|
478
|
-
* "title":null,
|
|
479
|
-
* "bigTitle":"Appium Settings",
|
|
480
|
-
* "text":null,
|
|
481
|
-
* "bigText":"Keep this service running, so Appium for Android can properly interact with several system APIs",
|
|
482
|
-
* "tickerText":null,
|
|
483
|
-
* "subText":null,
|
|
484
|
-
* "infoText":null,
|
|
485
|
-
* "template":"android.app.Notification$BigTextStyle"
|
|
486
|
-
* },
|
|
487
|
-
* "userHandle":0,
|
|
488
|
-
* "groupKey":"0|io.appium.settings|1|null|10133",
|
|
489
|
-
* "overrideGroupKey":null,
|
|
490
|
-
* "postTime":1576853518850,
|
|
491
|
-
* "key":"0|io.appium.settings|1|null|10133",
|
|
492
|
-
* "isRemoved":false
|
|
493
|
-
* }
|
|
494
|
-
* ]
|
|
495
|
-
* }
|
|
496
|
-
* ```
|
|
497
|
-
* @throws {Error} If there was an error while getting the notifications list
|
|
498
|
-
*/
|
|
499
|
-
commands.getNotifications = async function getNotifications() {
|
|
500
|
-
logger_js_1.default.debug('Retrieving notifications');
|
|
501
|
-
// Somehow providing the `-n` arg to the `am` underneath
|
|
502
|
-
// renders the broadcast to fail instead of starting the
|
|
503
|
-
// Appium Settings app. This only happens to the notifications
|
|
504
|
-
// receiver
|
|
505
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
506
|
-
let output;
|
|
507
|
-
try {
|
|
508
|
-
output = await this.shell([
|
|
509
|
-
'am', 'broadcast',
|
|
510
|
-
'-a', NOTIFICATIONS_RETRIEVAL_ACTION,
|
|
511
|
-
]);
|
|
512
|
-
}
|
|
513
|
-
catch (err) {
|
|
514
|
-
throw new Error(`Cannot retrieve notifications from the device. ` +
|
|
515
|
-
`Make sure the Appium Settings application is installed and is up to date. ` +
|
|
516
|
-
`Original error: ${err.message}`);
|
|
517
|
-
}
|
|
518
|
-
return (0, helpers_js_1.parseJsonData)(output, 'notifications');
|
|
519
|
-
};
|
|
520
|
-
/**
|
|
521
|
-
* @typedef {Object} SmsListOptions
|
|
522
|
-
* @property {number} [max=100] - The maximum count of recent messages
|
|
523
|
-
* to retrieve
|
|
524
|
-
*/
|
|
525
|
-
/**
|
|
526
|
-
* @typedef SmsListResult
|
|
527
|
-
* @property {SmsListResultItem[]} items
|
|
528
|
-
* @property {number} total
|
|
529
|
-
*/
|
|
530
|
-
/**
|
|
531
|
-
* @privateRemarks XXX: WAG
|
|
532
|
-
* @typedef SmsListResultItem
|
|
533
|
-
* @property {string} id
|
|
534
|
-
* @property {string} address
|
|
535
|
-
* @property {string|null} person
|
|
536
|
-
* @property {string} date
|
|
537
|
-
* @property {string} read
|
|
538
|
-
* @property {string} status
|
|
539
|
-
* @property {string} type
|
|
540
|
-
* @property {string|null} subject
|
|
541
|
-
* @property {string} body
|
|
542
|
-
* @property {string|null} serviceCenter
|
|
543
|
-
*/
|
|
544
|
-
/**
|
|
545
|
-
* Retrieves the list of the most recent SMS
|
|
546
|
-
* properties list via Appium Settings helper.
|
|
547
|
-
* Messages are sorted by date in descending order.
|
|
548
|
-
*
|
|
549
|
-
* @this {import('../adb.js').ADB}
|
|
550
|
-
* @param {SmsListOptions} opts
|
|
551
|
-
* @returns {Promise<SmsListResult>} The example output is:
|
|
552
|
-
* ```json
|
|
553
|
-
* {
|
|
554
|
-
* "items":[
|
|
555
|
-
* {
|
|
556
|
-
* "id":"2",
|
|
557
|
-
* "address":"+123456789",
|
|
558
|
-
* "person":null,
|
|
559
|
-
* "date":"1581936422203",
|
|
560
|
-
* "read":"0",
|
|
561
|
-
* "status":"-1",
|
|
562
|
-
* "type":"1",
|
|
563
|
-
* "subject":null,
|
|
564
|
-
* "body":"\"text message2\"",
|
|
565
|
-
* "serviceCenter":null
|
|
566
|
-
* },
|
|
567
|
-
* {
|
|
568
|
-
* "id":"1",
|
|
569
|
-
* "address":"+123456789",
|
|
570
|
-
* "person":null,
|
|
571
|
-
* "date":"1581936382740",
|
|
572
|
-
* "read":"0",
|
|
573
|
-
* "status":"-1",
|
|
574
|
-
* "type":"1",
|
|
575
|
-
* "subject":null,
|
|
576
|
-
* "body":"\"text message\"",
|
|
577
|
-
* "serviceCenter":null
|
|
578
|
-
* }
|
|
579
|
-
* ],
|
|
580
|
-
* "total":2
|
|
581
|
-
* }
|
|
582
|
-
* ```
|
|
583
|
-
* @throws {Error} If there was an error while getting the SMS list
|
|
584
|
-
*/
|
|
585
|
-
commands.getSmsList = async function getSmsList(opts = {}) {
|
|
586
|
-
logger_js_1.default.debug('Retrieving the recent SMS messages');
|
|
587
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
588
|
-
const args = [
|
|
589
|
-
'am', 'broadcast',
|
|
590
|
-
'-n', SMS_LIST_RECEIVER,
|
|
591
|
-
'-a', SMS_LIST_RETRIEVAL_ACTION,
|
|
592
|
-
];
|
|
593
|
-
if (opts.max) {
|
|
594
|
-
args.push('--es', 'max', `${opts.max}`);
|
|
595
|
-
}
|
|
596
|
-
let output;
|
|
597
|
-
try {
|
|
598
|
-
output = await this.shell(args);
|
|
599
|
-
}
|
|
600
|
-
catch (err) {
|
|
601
|
-
throw new Error(`Cannot retrieve SMS list from the device. ` +
|
|
602
|
-
`Make sure the Appium Settings application is installed and is up to date. ` +
|
|
603
|
-
`Original error: ${err.message}`);
|
|
604
|
-
}
|
|
605
|
-
return (0, helpers_js_1.parseJsonData)(output, 'SMS list');
|
|
606
|
-
};
|
|
607
|
-
/**
|
|
608
|
-
* Types the given Unicode string.
|
|
609
|
-
* It is expected that the focus is already put
|
|
610
|
-
* to the destination input field before this method is called.
|
|
611
|
-
*
|
|
612
|
-
* @this {import('../adb.js').ADB}
|
|
613
|
-
* @param {string} text The string to type
|
|
614
|
-
* @returns {Promise<boolean>} `true` if the input text has been successfully sent to adb
|
|
615
|
-
*/
|
|
616
|
-
commands.typeUnicode = async function typeUnicode(text) {
|
|
617
|
-
if (lodash_1.default.isNil(text)) {
|
|
618
|
-
return false;
|
|
619
|
-
}
|
|
620
|
-
text = `${text}`;
|
|
621
|
-
logger_js_1.default.debug(`Typing ${support_1.util.pluralize('character', text.length, true)}`);
|
|
622
|
-
if (!text) {
|
|
623
|
-
return false;
|
|
624
|
-
}
|
|
625
|
-
await this.runInImeContext(UNICODE_IME, async () => await this.inputText(utf7_1.imap.encode(text)));
|
|
626
|
-
return true;
|
|
627
|
-
};
|
|
628
|
-
/**
|
|
629
|
-
* Performs recursive media scan at the given destination.
|
|
630
|
-
* All successfully scanned items are being added to the device's
|
|
631
|
-
* media library.
|
|
632
|
-
*
|
|
633
|
-
* @this {import('../adb.js').ADB}
|
|
634
|
-
* @param {string} destination File/folder path on the remote device.
|
|
635
|
-
* @throws {Error} If there was an unexpected error by scanning.
|
|
636
|
-
*/
|
|
637
|
-
commands.scanMedia = async function scanMedia(destination) {
|
|
638
|
-
logger_js_1.default.debug(`Scanning '${destination}' for media files`);
|
|
639
|
-
await this.requireRunningSettingsApp({ shouldRestoreCurrentApp: true });
|
|
640
|
-
const output = await this.shell([
|
|
641
|
-
'am', 'broadcast',
|
|
642
|
-
'-n', MEDIA_SCAN_RECEIVER,
|
|
643
|
-
'-a', MEDIA_SCAN_ACTION,
|
|
644
|
-
'--es', 'path', destination
|
|
645
|
-
]);
|
|
646
|
-
if (!lodash_1.default.includes(output, 'result=-1')) {
|
|
647
|
-
throw new Error(`No media could be scanned at '${destination}'. ` +
|
|
648
|
-
`Check the device logcat output for more details.`);
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
exports.default = commands;
|
|
652
|
-
/**
|
|
653
|
-
* @typedef {typeof commands} SettingsClientCommands
|
|
654
|
-
*/
|
|
655
|
-
//# sourceMappingURL=settings-client-commands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-client-commands.js","sourceRoot":"","sources":["../../../lib/tools/settings-client-commands.js"],"names":[],"mappings":";;;;;AAAA,6DAA+B;AAC/B,8CAA8C;AAC9C,oDAAuB;AACvB,6CAA+C;AAC/C,uCAA4C;AAC5C,iCAA8B;AAC9B,+CAA0C;AAC1C,wDAAyB;AAEzB,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAChD,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAClD,MAAM,gCAAgC,GAAG,GAAG,kBAAkB,2CAA2C,CAAC;AAC1G,MAAM,8BAA8B,GAAG,GAAG,kBAAkB,OAAO,CAAC;AACpE,MAAM,gCAAgC,GAAG,GAAG,kBAAkB,2CAA2C,CAAC;AAC1G,MAAM,8BAA8B,GAAG,GAAG,kBAAkB,kBAAkB,CAAC;AAC/E,MAAM,0BAA0B,GAAG,GAAG,kBAAkB,sCAAsC,CAAC;AAC/F,MAAM,wBAAwB,GAAG,GAAG,kBAAkB,YAAY,CAAC;AACnE,MAAM,uBAAuB,GAAG,GAAG,kBAAkB,mCAAmC,CAAC;AACzF,MAAM,qBAAqB,GAAG,GAAG,kBAAkB,SAAS,CAAC;AAC7D,MAAM,gBAAgB,GAAG,GAAG,kBAAkB,mBAAmB,CAAC;AAClE,MAAM,iBAAiB,GAAG,GAAG,kBAAkB,kCAAkC,CAAC;AAClF,MAAM,yBAAyB,GAAG,GAAG,kBAAkB,WAAW,CAAC;AACnE,MAAM,kBAAkB,GAAG,GAAG,kBAAkB,+BAA+B,CAAC;AAChF,MAAM,0BAA0B,GAAG,GAAG,kBAAkB,gBAAgB,CAAC;AACzE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yB,CAAC,EAAC,uBAAuB,EAAE,IAAI,EAAC,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,MAAM,EAAE,WAAW;KAC5B,CAAC,CAAC;IACH,IAAI,CAAC,gBAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,iCAAiC,WAAW,KAAK;YAC/D,kDAAkD,CAAC,CAAC;KACvD;AACH,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC;AAExB;;EAEE"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RFC 2152 UTF-7 encoding with all optionals.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} str
|
|
5
|
-
* @returns {string}
|
|
6
|
-
*/
|
|
7
|
-
export function encodeAll(str: string): string;
|
|
8
|
-
export namespace imap {
|
|
9
|
-
/**
|
|
10
|
-
* RFC 3501, section 5.1.3 UTF-7 encoding.
|
|
11
|
-
*
|
|
12
|
-
* @param {string} str
|
|
13
|
-
* @returns {string}
|
|
14
|
-
*/
|
|
15
|
-
function encode(str: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* RFC 3501, section 5.1.3 UTF-7 decoding.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} str
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
|
-
function decode(str: string): string;
|
|
23
|
-
}
|
|
24
|
-
export function encode(str: string, mask?: string | null): string;
|
|
25
|
-
export function decode(str: string): string;
|
|
26
|
-
//# sourceMappingURL=utf7.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utf7.d.ts","sourceRoot":"","sources":["../../../lib/tools/utf7.js"],"names":[],"mappings":"AAmGA;;;;;GAKG;AACH,+BAHW,MAAM,GACJ,MAAM,CAQlB;;IAED;;;;;OAKG;IACH,qCAQC;IAeD;;;;;OAKG;IACH,qCAKC;;AAtEM,4BAJI,MAAM,SACN,MAAM,UACJ,MAAM,CAgBlB;AAsCM,4BAHI,MAAM,GACJ,MAAM,CAOlB"}
|
package/build/lib/tools/utf7.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* The code below has been adopted from https://www.npmjs.com/package/utf7
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decode = exports.encodeAll = exports.encode = exports.imap = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @param {number} length
|
|
9
|
-
* @returns {Buffer}
|
|
10
|
-
*/
|
|
11
|
-
function allocateAsciiBuffer(length) {
|
|
12
|
-
return Buffer.alloc(length, 'ascii');
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @param {string} str
|
|
16
|
-
* @returns {string}
|
|
17
|
-
*/
|
|
18
|
-
function _encode(str) {
|
|
19
|
-
const b = allocateAsciiBuffer(str.length * 2);
|
|
20
|
-
for (let i = 0, bi = 0; i < str.length; i++) {
|
|
21
|
-
// Note that we can't simply convert a UTF-8 string to Base64 because
|
|
22
|
-
// UTF-8 uses a different encoding. In modified UTF-7, all characters
|
|
23
|
-
// are represented by their two byte Unicode ID.
|
|
24
|
-
const c = str.charCodeAt(i);
|
|
25
|
-
// Upper 8 bits shifted into lower 8 bits so that they fit into 1 byte.
|
|
26
|
-
b[bi++] = c >> 8;
|
|
27
|
-
// Lower 8 bits. Cut off the upper 8 bits so that they fit into 1 byte.
|
|
28
|
-
b[bi++] = c & 0xFF;
|
|
29
|
-
}
|
|
30
|
-
// Modified Base64 uses , instead of / and omits trailing =.
|
|
31
|
-
return b.toString('base64').replace(/=+$/, '');
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @param {string} str
|
|
35
|
-
* @returns {Buffer}
|
|
36
|
-
*/
|
|
37
|
-
function allocateBase64Buffer(str) {
|
|
38
|
-
return Buffer.from(str, 'base64');
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} str
|
|
42
|
-
* @returns {string}
|
|
43
|
-
*/
|
|
44
|
-
function _decode(str) {
|
|
45
|
-
const b = allocateBase64Buffer(str);
|
|
46
|
-
const r = [];
|
|
47
|
-
for (let i = 0; i < b.length;) {
|
|
48
|
-
// Calculate charcode from two adjacent bytes.
|
|
49
|
-
r.push(String.fromCharCode(b[i++] << 8 | b[i++]));
|
|
50
|
-
}
|
|
51
|
-
return r.join('');
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Escape RegEx from http://simonwillison.net/2006/Jan/20/escape/
|
|
55
|
-
*
|
|
56
|
-
* @param {string} chars
|
|
57
|
-
* @returns {string}
|
|
58
|
-
*/
|
|
59
|
-
function escape(chars) {
|
|
60
|
-
return chars.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
61
|
-
}
|
|
62
|
-
// Character classes defined by RFC 2152.
|
|
63
|
-
const setD = 'A-Za-z0-9' + escape(`'(),-./:?`);
|
|
64
|
-
const setO = escape(`!"#$%&*;<=>@[]^_'{|}`);
|
|
65
|
-
const setW = escape(` \r\n\t`);
|
|
66
|
-
// Stores compiled regexes for various replacement pattern.
|
|
67
|
-
/** @type {Record<string, RegExp>} */
|
|
68
|
-
const regexes = {};
|
|
69
|
-
const regexAll = new RegExp(`[^${setW}${setD}${setO}]+`, 'g');
|
|
70
|
-
exports.imap = {};
|
|
71
|
-
/**
|
|
72
|
-
* RFC 2152 UTF-7 encoding.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} str
|
|
75
|
-
* @param {string?} mask
|
|
76
|
-
* @returns {string}
|
|
77
|
-
*/
|
|
78
|
-
const encode = function encode(str, mask = null) {
|
|
79
|
-
// Generate a RegExp object from the string of mask characters.
|
|
80
|
-
if (!mask) {
|
|
81
|
-
mask = '';
|
|
82
|
-
}
|
|
83
|
-
if (!regexes[mask]) {
|
|
84
|
-
regexes[mask] = new RegExp(`[^${setD}${escape(mask)}]+`, 'g');
|
|
85
|
-
}
|
|
86
|
-
// We replace subsequent disallowed chars with their escape sequence.
|
|
87
|
-
return str.replace(regexes[mask], (chunk) =>
|
|
88
|
-
// + is represented by an empty sequence +-, otherwise call encode().
|
|
89
|
-
`+${chunk === '+' ? '' : _encode(chunk)}-`);
|
|
90
|
-
};
|
|
91
|
-
exports.encode = encode;
|
|
92
|
-
/**
|
|
93
|
-
* RFC 2152 UTF-7 encoding with all optionals.
|
|
94
|
-
*
|
|
95
|
-
* @param {string} str
|
|
96
|
-
* @returns {string}
|
|
97
|
-
*/
|
|
98
|
-
function encodeAll(str) {
|
|
99
|
-
// We replace subsequent disallowed chars with their escape sequence.
|
|
100
|
-
return str.replace(regexAll, (chunk) =>
|
|
101
|
-
// + is represented by an empty sequence +-, otherwise call encode().
|
|
102
|
-
`+${chunk === '+' ? '' : _encode(chunk)}-`);
|
|
103
|
-
}
|
|
104
|
-
exports.encodeAll = encodeAll;
|
|
105
|
-
;
|
|
106
|
-
/**
|
|
107
|
-
* RFC 3501, section 5.1.3 UTF-7 encoding.
|
|
108
|
-
*
|
|
109
|
-
* @param {string} str
|
|
110
|
-
* @returns {string}
|
|
111
|
-
*/
|
|
112
|
-
exports.imap.encode = function encode(str) {
|
|
113
|
-
// All printable ASCII chars except for & must be represented by themselves.
|
|
114
|
-
// We replace subsequent non-representable chars with their escape sequence.
|
|
115
|
-
return str.replace(/&/g, '&-').replace(/[^\x20-\x7e]+/g, (chunk) => {
|
|
116
|
-
// & is represented by an empty sequence &-, otherwise call encode().
|
|
117
|
-
chunk = (chunk === '&' ? '' : _encode(chunk)).replace(/\//g, ',');
|
|
118
|
-
return `&${chunk}-`;
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* RFC 2152 UTF-7 decoding.
|
|
123
|
-
*
|
|
124
|
-
* @param {string} str
|
|
125
|
-
* @returns {string}
|
|
126
|
-
*/
|
|
127
|
-
const decode = function decode(str) {
|
|
128
|
-
return str.replace(/\+([A-Za-z0-9/]*)-?/gi, (_, chunk) =>
|
|
129
|
-
// &- represents &.
|
|
130
|
-
chunk === '' ? '+' : _decode(chunk));
|
|
131
|
-
};
|
|
132
|
-
exports.decode = decode;
|
|
133
|
-
/**
|
|
134
|
-
* RFC 3501, section 5.1.3 UTF-7 decoding.
|
|
135
|
-
*
|
|
136
|
-
* @param {string} str
|
|
137
|
-
* @returns {string}
|
|
138
|
-
*/
|
|
139
|
-
exports.imap.decode = function decode(str) {
|
|
140
|
-
return str.replace(/&([^-]*)-/g, (_, chunk) =>
|
|
141
|
-
// &- represents &.
|
|
142
|
-
chunk === '' ? '&' : _decode(chunk.replace(/,/g, '/')));
|
|
143
|
-
};
|
|
144
|
-
//# sourceMappingURL=utf7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utf7.js","sourceRoot":"","sources":["../../../lib/tools/utf7.js"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH;;;GAGG;AACH,SAAS,mBAAmB,CAAC,MAAM;IACjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,SAAS,OAAO,CAAC,GAAG;IAClB,MAAM,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,qEAAqE;QACrE,qEAAqE;QACrE,gDAAgD;QAChD,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,uEAAuE;QACvE,CAAC,CAAC,EAAE,EAAE,CAAC,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