appium-adb 14.3.1 → 14.3.3
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 +13 -0
- package/build/lib/adb.d.ts +9 -9
- package/build/lib/adb.d.ts.map +1 -1
- package/build/lib/adb.js +61 -61
- package/build/lib/adb.js.map +1 -1
- package/build/lib/helpers.d.ts +2 -2
- package/build/lib/helpers.d.ts.map +1 -1
- package/build/lib/helpers.js +5 -5
- package/build/lib/helpers.js.map +1 -1
- package/build/lib/index.d.ts +8 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/{index.js → lib/index.js} +4 -4
- package/build/lib/index.js.map +1 -0
- package/build/lib/logcat.d.ts.map +1 -1
- package/build/lib/logcat.js +1 -1
- package/build/lib/logcat.js.map +1 -1
- package/build/lib/tools/aab-utils.d.ts +2 -2
- package/build/lib/tools/aab-utils.d.ts.map +1 -1
- package/build/lib/tools/aab-utils.js +10 -10
- package/build/lib/tools/aab-utils.js.map +1 -1
- package/build/lib/tools/android-manifest.d.ts +2 -2
- package/build/lib/tools/android-manifest.d.ts.map +1 -1
- package/build/lib/tools/android-manifest.js +27 -27
- package/build/lib/tools/android-manifest.js.map +1 -1
- package/build/lib/tools/apk-signing.d.ts +2 -2
- package/build/lib/tools/apk-signing.d.ts.map +1 -1
- package/build/lib/tools/apk-signing.js +34 -34
- package/build/lib/tools/apk-signing.js.map +1 -1
- package/build/lib/tools/apk-utils.d.ts +2 -2
- package/build/lib/tools/apk-utils.d.ts.map +1 -1
- package/build/lib/tools/apk-utils.js +76 -76
- package/build/lib/tools/apk-utils.js.map +1 -1
- package/build/lib/tools/apks-utils.d.ts +2 -2
- package/build/lib/tools/apks-utils.d.ts.map +1 -1
- package/build/lib/tools/apks-utils.js +58 -58
- package/build/lib/tools/apks-utils.js.map +1 -1
- package/build/lib/tools/app-commands.d.ts +13 -13
- package/build/lib/tools/app-commands.d.ts.map +1 -1
- package/build/lib/tools/app-commands.js +36 -38
- package/build/lib/tools/app-commands.js.map +1 -1
- package/build/lib/tools/device-settings.d.ts +2 -2
- package/build/lib/tools/device-settings.d.ts.map +1 -1
- package/build/lib/tools/device-settings.js +27 -27
- package/build/lib/tools/device-settings.js.map +1 -1
- package/build/lib/tools/emulator-commands.d.ts +2 -2
- package/build/lib/tools/emulator-commands.d.ts.map +1 -1
- package/build/lib/tools/emulator-commands.js +47 -47
- package/build/lib/tools/emulator-commands.js.map +1 -1
- package/build/lib/tools/fs-commands.d.ts +1 -1
- package/build/lib/tools/fs-commands.d.ts.map +1 -1
- package/build/lib/tools/fs-commands.js +3 -3
- package/build/lib/tools/fs-commands.js.map +1 -1
- package/build/lib/tools/general-commands.d.ts +2 -2
- package/build/lib/tools/general-commands.d.ts.map +1 -1
- package/build/lib/tools/general-commands.js +7 -7
- package/build/lib/tools/general-commands.js.map +1 -1
- package/build/lib/tools/keyboard-commands.d.ts +2 -2
- package/build/lib/tools/keyboard-commands.d.ts.map +1 -1
- package/build/lib/tools/keyboard-commands.js +3 -3
- package/build/lib/tools/keyboard-commands.js.map +1 -1
- package/build/lib/tools/lockmgmt.d.ts +1 -1
- package/build/lib/tools/lockmgmt.d.ts.map +1 -1
- package/build/lib/tools/lockmgmt.js +78 -78
- package/build/lib/tools/lockmgmt.js.map +1 -1
- package/build/lib/tools/logcat-commands.d.ts +2 -2
- package/build/lib/tools/logcat-commands.d.ts.map +1 -1
- package/build/lib/tools/network-commands.d.ts +2 -2
- package/build/lib/tools/network-commands.d.ts.map +1 -1
- package/build/lib/tools/network-commands.js +10 -10
- package/build/lib/tools/network-commands.js.map +1 -1
- package/build/lib/tools/process-commands.d.ts +1 -1
- package/build/lib/tools/process-commands.d.ts.map +1 -1
- package/build/lib/tools/process-commands.js +10 -10
- package/build/lib/tools/process-commands.js.map +1 -1
- package/build/lib/tools/system-calls.d.ts +8 -8
- package/build/lib/tools/system-calls.d.ts.map +1 -1
- package/build/lib/tools/system-calls.js +81 -83
- package/build/lib/tools/system-calls.js.map +1 -1
- package/lib/adb.ts +69 -69
- package/lib/helpers.ts +3 -3
- package/lib/index.ts +8 -0
- package/lib/logcat.ts +4 -6
- package/lib/tools/aab-utils.ts +4 -4
- package/lib/tools/android-manifest.ts +4 -4
- package/lib/tools/apk-signing.ts +4 -4
- package/lib/tools/apk-utils.ts +41 -41
- package/lib/tools/apks-utils.ts +53 -53
- package/lib/tools/app-commands.ts +15 -19
- package/lib/tools/device-settings.ts +16 -16
- package/lib/tools/emulator-commands.ts +53 -53
- package/lib/tools/fs-commands.ts +5 -5
- package/lib/tools/general-commands.ts +3 -3
- package/lib/tools/keyboard-commands.ts +3 -3
- package/lib/tools/lockmgmt.ts +84 -84
- package/lib/tools/logcat-commands.ts +2 -2
- package/lib/tools/network-commands.ts +3 -3
- package/lib/tools/process-commands.ts +2 -2
- package/lib/tools/system-calls.ts +13 -17
- package/package.json +4 -6
- package/build/index.d.ts +0 -8
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/index.ts +0 -8
|
@@ -11,12 +11,12 @@ exports.extractBaseApk = extractBaseApk;
|
|
|
11
11
|
exports.extractLanguageApk = extractLanguageApk;
|
|
12
12
|
exports.isTestPackageOnlyError = isTestPackageOnlyError;
|
|
13
13
|
const teen_process_1 = require("teen_process");
|
|
14
|
-
const
|
|
14
|
+
const logger_1 = require("../logger");
|
|
15
15
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
16
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
17
|
const support_1 = require("@appium/support");
|
|
18
18
|
const lru_cache_1 = require("lru-cache");
|
|
19
|
-
const
|
|
19
|
+
const helpers_1 = require("../helpers");
|
|
20
20
|
const async_lock_1 = __importDefault(require("async-lock"));
|
|
21
21
|
const bluebird_1 = __importDefault(require("bluebird"));
|
|
22
22
|
const BASE_APK = 'base-master.apk';
|
|
@@ -27,66 +27,23 @@ const APKS_CACHE = new lru_cache_1.LRUCache({
|
|
|
27
27
|
});
|
|
28
28
|
const APKS_CACHE_GUARD = new async_lock_1.default();
|
|
29
29
|
const BUNDLETOOL_TIMEOUT_MS = 4 * 60 * 1000;
|
|
30
|
-
const APKS_INSTALL_TIMEOUT =
|
|
30
|
+
const APKS_INSTALL_TIMEOUT = helpers_1.APK_INSTALL_TIMEOUT * 2;
|
|
31
31
|
process.on('exit', () => {
|
|
32
32
|
if (!APKS_CACHE.size) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const paths = [...APKS_CACHE.values()];
|
|
36
|
-
|
|
36
|
+
logger_1.log.debug(`Performing cleanup of ${paths.length} cached .apks ` + support_1.util.pluralize('package', paths.length));
|
|
37
37
|
for (const appPath of paths) {
|
|
38
38
|
try {
|
|
39
39
|
// Asynchronous calls are not supported in onExit handler
|
|
40
40
|
support_1.fs.rimrafSync(appPath);
|
|
41
41
|
}
|
|
42
42
|
catch (e) {
|
|
43
|
-
|
|
43
|
+
logger_1.log.warn(e.message);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
/**
|
|
48
|
-
* Extracts the particular apks package into a temporary folder,
|
|
49
|
-
* finds and returns the full path to the file contained in this apk.
|
|
50
|
-
* The resulting temporary path, where the .apks file has been extracted,
|
|
51
|
-
* will be stored into the internal LRU cache for better performance.
|
|
52
|
-
*
|
|
53
|
-
* @param apks - The full path to the .apks file
|
|
54
|
-
* @param dstPath - The relative path to the destination file,
|
|
55
|
-
* which is going to be extracted, where each path component is an array item
|
|
56
|
-
* @returns Full path to the extracted file
|
|
57
|
-
* @throws {Error} If the requested item does not exist in the extracted archive or the provides
|
|
58
|
-
* apks file is not a valid bundle
|
|
59
|
-
*/
|
|
60
|
-
async function extractFromApks(apks, dstPath) {
|
|
61
|
-
const normalizedDstPath = lodash_1.default.isArray(dstPath) ? dstPath : [dstPath];
|
|
62
|
-
return await APKS_CACHE_GUARD.acquire(apks, async () => {
|
|
63
|
-
// It might be that the original file has been replaced,
|
|
64
|
-
// so we need to keep the hash sums instead of the actual file paths
|
|
65
|
-
// as caching keys
|
|
66
|
-
const apksHash = await support_1.fs.hash(apks);
|
|
67
|
-
logger_js_1.log.debug(`Calculated '${apks}' hash: ${apksHash}`);
|
|
68
|
-
if (APKS_CACHE.has(apksHash)) {
|
|
69
|
-
const cachedRoot = APKS_CACHE.get(apksHash);
|
|
70
|
-
if (cachedRoot) {
|
|
71
|
-
const resultPath = node_path_1.default.resolve(cachedRoot, ...normalizedDstPath);
|
|
72
|
-
if (await support_1.fs.exists(resultPath)) {
|
|
73
|
-
return resultPath;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
APKS_CACHE.delete(apksHash);
|
|
77
|
-
}
|
|
78
|
-
const tmpRoot = await support_1.tempDir.openDir();
|
|
79
|
-
logger_js_1.log.debug(`Unpacking application bundle at '${apks}' to '${tmpRoot}'`);
|
|
80
|
-
await (0, helpers_js_1.unzipFile)(apks, tmpRoot);
|
|
81
|
-
const resultPath = node_path_1.default.resolve(tmpRoot, ...normalizedDstPath);
|
|
82
|
-
if (!(await support_1.fs.exists(resultPath))) {
|
|
83
|
-
throw new Error(`${normalizedDstPath.join(node_path_1.default.sep)} cannot be found in '${apks}' bundle. ` +
|
|
84
|
-
`Does the archive contain a valid application bundle?`);
|
|
85
|
-
}
|
|
86
|
-
APKS_CACHE.set(apksHash, tmpRoot);
|
|
87
|
-
return resultPath;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
47
|
/**
|
|
91
48
|
* Executes bundletool utility with given arguments and returns the actual stdout
|
|
92
49
|
*
|
|
@@ -107,23 +64,23 @@ async function execBundletool(args, errorMsg) {
|
|
|
107
64
|
if (this.adbHost) {
|
|
108
65
|
env.ANDROID_ADB_SERVER_HOST = this.adbHost;
|
|
109
66
|
}
|
|
110
|
-
|
|
67
|
+
logger_1.log.debug(`Executing bundletool with arguments: ${JSON.stringify(args)}`);
|
|
111
68
|
let stdout;
|
|
112
69
|
try {
|
|
113
|
-
({ stdout } = await (0, teen_process_1.exec)(await (0,
|
|
70
|
+
({ stdout } = await (0, teen_process_1.exec)(await (0, helpers_1.getJavaForOs)(), args, {
|
|
114
71
|
env,
|
|
115
72
|
timeout: BUNDLETOOL_TIMEOUT_MS,
|
|
116
73
|
}));
|
|
117
|
-
|
|
74
|
+
logger_1.log.debug(`Command stdout: ${lodash_1.default.truncate(stdout, { length: 300 })}`);
|
|
118
75
|
return stdout;
|
|
119
76
|
}
|
|
120
77
|
catch (e) {
|
|
121
78
|
const err = e;
|
|
122
79
|
if (err.stdout) {
|
|
123
|
-
|
|
80
|
+
logger_1.log.debug(`Command stdout: ${err.stdout}`);
|
|
124
81
|
}
|
|
125
82
|
if (err.stderr) {
|
|
126
|
-
|
|
83
|
+
logger_1.log.debug(`Command stderr: ${err.stderr}`);
|
|
127
84
|
}
|
|
128
85
|
throw new Error(`${errorMsg}. Original error: ${err.message}`);
|
|
129
86
|
}
|
|
@@ -144,7 +101,7 @@ async function getDeviceSpec(specLocation) {
|
|
|
144
101
|
'--output',
|
|
145
102
|
specLocation,
|
|
146
103
|
];
|
|
147
|
-
|
|
104
|
+
logger_1.log.debug(`Getting the spec for the device '${this.curDeviceId}'`);
|
|
148
105
|
await this.execBundletool(args, 'Cannot retrieve the device spec');
|
|
149
106
|
return specLocation;
|
|
150
107
|
}
|
|
@@ -155,7 +112,7 @@ async function getDeviceSpec(specLocation) {
|
|
|
155
112
|
* @param options - Installation options
|
|
156
113
|
*/
|
|
157
114
|
async function installMultipleApks(apkPathsToInstall, options = {}) {
|
|
158
|
-
const installArgs = (0,
|
|
115
|
+
const installArgs = (0, helpers_1.buildInstallArgs)(await this.getApiLevel(), options);
|
|
159
116
|
return await this.adbExec(['install-multiple', ...installArgs, ...apkPathsToInstall], {
|
|
160
117
|
// @ts-ignore This validation works
|
|
161
118
|
timeout: isNaN(Number(options.timeout)) ? undefined : options.timeout,
|
|
@@ -224,8 +181,8 @@ async function extractLanguageApk(apks, language = null) {
|
|
|
224
181
|
return await extractFromApks(apks, ['splits', LANGUAGE_APK(language)]);
|
|
225
182
|
}
|
|
226
183
|
catch (e) {
|
|
227
|
-
|
|
228
|
-
|
|
184
|
+
logger_1.log.debug(e.message);
|
|
185
|
+
logger_1.log.info(`Assuming that splitting by language is not enabled for the '${apks}' bundle ` +
|
|
229
186
|
`and returning the main apk instead`);
|
|
230
187
|
return await this.extractBaseApk(apks);
|
|
231
188
|
}
|
|
@@ -237,7 +194,7 @@ async function extractLanguageApk(apks, language = null) {
|
|
|
237
194
|
}
|
|
238
195
|
catch { }
|
|
239
196
|
}
|
|
240
|
-
|
|
197
|
+
logger_1.log.info(`Cannot find any split apk for the default languages ${JSON.stringify(defaultLanguages)}. ` +
|
|
241
198
|
`Returning the main apk instead.`);
|
|
242
199
|
return await this.extractBaseApk(apks);
|
|
243
200
|
}
|
|
@@ -249,4 +206,47 @@ async function extractLanguageApk(apks, language = null) {
|
|
|
249
206
|
function isTestPackageOnlyError(output) {
|
|
250
207
|
return /\[INSTALL_FAILED_TEST_ONLY\]/.test(output);
|
|
251
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Extracts the particular apks package into a temporary folder,
|
|
211
|
+
* finds and returns the full path to the file contained in this apk.
|
|
212
|
+
* The resulting temporary path, where the .apks file has been extracted,
|
|
213
|
+
* will be stored into the internal LRU cache for better performance.
|
|
214
|
+
*
|
|
215
|
+
* @param apks - The full path to the .apks file
|
|
216
|
+
* @param dstPath - The relative path to the destination file,
|
|
217
|
+
* which is going to be extracted, where each path component is an array item
|
|
218
|
+
* @returns Full path to the extracted file
|
|
219
|
+
* @throws {Error} If the requested item does not exist in the extracted archive or the provides
|
|
220
|
+
* apks file is not a valid bundle
|
|
221
|
+
*/
|
|
222
|
+
async function extractFromApks(apks, dstPath) {
|
|
223
|
+
const normalizedDstPath = lodash_1.default.isArray(dstPath) ? dstPath : [dstPath];
|
|
224
|
+
return await APKS_CACHE_GUARD.acquire(apks, async () => {
|
|
225
|
+
// It might be that the original file has been replaced,
|
|
226
|
+
// so we need to keep the hash sums instead of the actual file paths
|
|
227
|
+
// as caching keys
|
|
228
|
+
const apksHash = await support_1.fs.hash(apks);
|
|
229
|
+
logger_1.log.debug(`Calculated '${apks}' hash: ${apksHash}`);
|
|
230
|
+
if (APKS_CACHE.has(apksHash)) {
|
|
231
|
+
const cachedRoot = APKS_CACHE.get(apksHash);
|
|
232
|
+
if (cachedRoot) {
|
|
233
|
+
const resultPath = node_path_1.default.resolve(cachedRoot, ...normalizedDstPath);
|
|
234
|
+
if (await support_1.fs.exists(resultPath)) {
|
|
235
|
+
return resultPath;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
APKS_CACHE.delete(apksHash);
|
|
239
|
+
}
|
|
240
|
+
const tmpRoot = await support_1.tempDir.openDir();
|
|
241
|
+
logger_1.log.debug(`Unpacking application bundle at '${apks}' to '${tmpRoot}'`);
|
|
242
|
+
await (0, helpers_1.unzipFile)(apks, tmpRoot);
|
|
243
|
+
const resultPath = node_path_1.default.resolve(tmpRoot, ...normalizedDstPath);
|
|
244
|
+
if (!(await support_1.fs.exists(resultPath))) {
|
|
245
|
+
throw new Error(`${normalizedDstPath.join(node_path_1.default.sep)} cannot be found in '${apks}' bundle. ` +
|
|
246
|
+
`Does the archive contain a valid application bundle?`);
|
|
247
|
+
}
|
|
248
|
+
APKS_CACHE.set(apksHash, tmpRoot);
|
|
249
|
+
return resultPath;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
252
|
//# sourceMappingURL=apks-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apks-utils.js","sourceRoot":"","sources":["../../../lib/tools/apks-utils.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"apks-utils.js","sourceRoot":"","sources":["../../../lib/tools/apks-utils.ts"],"names":[],"mappings":";;;;;AAkDA,wCA8BC;AAQD,sCAaC;AAQD,kDAWC;AASD,kCAmCC;AASD,wCAEC;AAaD,gDA8BC;AAOD,wDAEC;AAnOD,+CAAkC;A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W,QAAQ,EAAE,CAAC,CAAC;QAEpD,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5C,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,iBAAiB,CAAC,CAAC;gBAClE,IAAI,MAAM,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;oBAChC,OAAO,UAAU,CAAC;gBACpB,CAAC;YACH,CAAC;YACD,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,iBAAO,CAAC,OAAO,EAAE,CAAC;QACxC,YAAG,CAAC,KAAK,CAAC,oCAAoC,IAAI,SAAS,OAAO,GAAG,CAAC,CAAC;QACvE,MAAM,IAAA,mBAAS,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/B,MAAM,UAAU,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,CAAC;QAC/D,IAAI,CAAC,CAAC,MAAM,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,GAAG,iBAAiB,CAAC,IAAI,CAAC,mBAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,YAAY;gBACzE,sDAAsD,CACzD,CAAC;QACJ,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type { ADB } from '../adb
|
|
2
|
-
import type { StringRecord, InstallState, ResolveActivityOptions, IsAppInstalledOptions, StartUriOptions, StartAppOptions, AppInfo, PackageActivityInfo, ListInstalledPackagesOptions, ListInstalledPackagesResult } from './types
|
|
1
|
+
import type { ADB } from '../adb';
|
|
2
|
+
import type { StringRecord, InstallState, ResolveActivityOptions, IsAppInstalledOptions, StartUriOptions, StartAppOptions, AppInfo, PackageActivityInfo, ListInstalledPackagesOptions, ListInstalledPackagesResult } from './types';
|
|
3
3
|
export declare const APP_INSTALL_STATE: StringRecord<InstallState>;
|
|
4
|
+
export interface StartCmdOptions {
|
|
5
|
+
user?: number | string;
|
|
6
|
+
waitForLaunch?: boolean;
|
|
7
|
+
pkg?: string;
|
|
8
|
+
activity?: string;
|
|
9
|
+
action?: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
stopApp?: boolean;
|
|
12
|
+
flags?: string;
|
|
13
|
+
optionalIntentArguments?: string;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Verify whether the given argument is a
|
|
6
17
|
* valid class name.
|
|
@@ -291,15 +302,4 @@ export declare function listAppProcessIds(this: ADB, pkg: string): Promise<numbe
|
|
|
291
302
|
* @returns True if the given package is running.
|
|
292
303
|
*/
|
|
293
304
|
export declare function isAppRunning(this: ADB, pkg: string): Promise<boolean>;
|
|
294
|
-
export interface StartCmdOptions {
|
|
295
|
-
user?: number | string;
|
|
296
|
-
waitForLaunch?: boolean;
|
|
297
|
-
pkg?: string;
|
|
298
|
-
activity?: string;
|
|
299
|
-
action?: string;
|
|
300
|
-
category?: string;
|
|
301
|
-
stopApp?: boolean;
|
|
302
|
-
flags?: string;
|
|
303
|
-
optionalIntentArguments?: string;
|
|
304
|
-
}
|
|
305
305
|
//# sourceMappingURL=app-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-commands.d.ts","sourceRoot":"","sources":["../../../lib/tools/app-commands.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"app-commands.d.ts","sourceRoot":"","sources":["../../../lib/t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G,OAAO,CAAC,MAAM,EAAE,CAAC,CAUjF;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3E"}
|
|
@@ -38,7 +38,7 @@ exports.listAppProcessIds = listAppProcessIds;
|
|
|
38
38
|
exports.isAppRunning = isAppRunning;
|
|
39
39
|
const lodash_1 = __importDefault(require("lodash"));
|
|
40
40
|
const support_1 = require("@appium/support");
|
|
41
|
-
const
|
|
41
|
+
const logger_1 = require("../logger");
|
|
42
42
|
const asyncbox_1 = require("asyncbox");
|
|
43
43
|
const node_path_1 = __importDefault(require("node:path"));
|
|
44
44
|
// Constants
|
|
@@ -55,7 +55,6 @@ const MIN_API_LEVEL_WITH_PERMS_SUPPORT = 23;
|
|
|
55
55
|
const RESOLVER_ACTIVITY_NAME = 'android/com.android.internal.app.ResolverActivity';
|
|
56
56
|
const MAIN_ACTION = 'android.intent.action.MAIN';
|
|
57
57
|
const LAUNCHER_CATEGORY = 'android.intent.category.LAUNCHER';
|
|
58
|
-
// Public methods
|
|
59
58
|
/**
|
|
60
59
|
* Verify whether the given argument is a
|
|
61
60
|
* valid class name.
|
|
@@ -84,7 +83,7 @@ async function resolveLaunchableActivity(pkg, opts = {}) {
|
|
|
84
83
|
const stdout = await this.shell(['dumpsys', 'package', pkg]);
|
|
85
84
|
const names = parseLaunchableActivityNames(stdout);
|
|
86
85
|
if (lodash_1.default.isEmpty(names)) {
|
|
87
|
-
|
|
86
|
+
logger_1.log.debug(stdout);
|
|
88
87
|
throw new Error(`Unable to resolve the launchable activity of '${pkg}'. Is it installed on the device?`);
|
|
89
88
|
}
|
|
90
89
|
if (names.length === 1) {
|
|
@@ -98,8 +97,8 @@ async function resolveLaunchableActivity(pkg, opts = {}) {
|
|
|
98
97
|
}
|
|
99
98
|
catch (e) {
|
|
100
99
|
const err = e;
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
logger_1.log.debug(err.stack);
|
|
101
|
+
logger_1.log.warn(`Unable to resolve the launchable activity of '${pkg}'. ` +
|
|
103
102
|
`The very first match of the dumpsys output is going to be used. ` +
|
|
104
103
|
`Original error: ${err.message}`);
|
|
105
104
|
return names[0];
|
|
@@ -184,7 +183,7 @@ async function grantAllPermissions(pkg, apk) {
|
|
|
184
183
|
}
|
|
185
184
|
catch {
|
|
186
185
|
//avoiding logging error stack, as calling library function would have logged
|
|
187
|
-
|
|
186
|
+
logger_1.log.warn(`Ran into problem getting target SDK version; ignoring...`);
|
|
188
187
|
}
|
|
189
188
|
if (apiLevel >= MIN_API_LEVEL_WITH_PERMS_SUPPORT &&
|
|
190
189
|
targetSdk >= MIN_API_LEVEL_WITH_PERMS_SUPPORT) {
|
|
@@ -198,19 +197,19 @@ async function grantAllPermissions(pkg, apk) {
|
|
|
198
197
|
const grantedPermissions = await this.getGrantedPermissions(pkg, dumpsysOutput);
|
|
199
198
|
const permissionsToGrant = lodash_1.default.difference(requestedPermissions, grantedPermissions);
|
|
200
199
|
if (lodash_1.default.isEmpty(permissionsToGrant)) {
|
|
201
|
-
|
|
200
|
+
logger_1.log.info(`${pkg} contains no permissions available for granting`);
|
|
202
201
|
}
|
|
203
202
|
else {
|
|
204
203
|
await this.grantPermissions(pkg, permissionsToGrant);
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
206
|
else if (targetSdk < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {
|
|
208
|
-
|
|
207
|
+
logger_1.log.info(`It is only possible to grant permissions in runtime for ` +
|
|
209
208
|
`apps whose targetSdkVersion in the manifest is set to ${MIN_API_LEVEL_WITH_PERMS_SUPPORT} or above. ` +
|
|
210
209
|
`The current ${pkg} targetSdkVersion is ${targetSdk || 'unset'}.`);
|
|
211
210
|
}
|
|
212
211
|
else if (apiLevel < MIN_API_LEVEL_WITH_PERMS_SUPPORT) {
|
|
213
|
-
|
|
212
|
+
logger_1.log.info(`The device's OS API level is ${apiLevel}. ` +
|
|
214
213
|
`It is only possible to grant permissions on devices running Android 6 or above.`);
|
|
215
214
|
}
|
|
216
215
|
}
|
|
@@ -228,7 +227,7 @@ async function grantPermissions(pkg, permissions) {
|
|
|
228
227
|
// trying to grant all permission by forming equivalent command.
|
|
229
228
|
// Also, it is necessary to split long commands into chunks, since the maximum length of
|
|
230
229
|
// adb shell buffer is limited
|
|
231
|
-
|
|
230
|
+
logger_1.log.debug(`Granting permissions ${JSON.stringify(permissions)} to '${pkg}'`);
|
|
232
231
|
try {
|
|
233
232
|
await this.shellChunks((perm) => ['pm', 'grant', pkg, perm], permissions);
|
|
234
233
|
}
|
|
@@ -285,7 +284,7 @@ async function revokePermission(pkg, permission) {
|
|
|
285
284
|
* @throws {Error} If there was an error while changing permissions.
|
|
286
285
|
*/
|
|
287
286
|
async function getGrantedPermissions(pkg, cmdOutput = null) {
|
|
288
|
-
|
|
287
|
+
logger_1.log.debug('Retrieving granted permissions');
|
|
289
288
|
const stdout = cmdOutput || (await this.shell(['dumpsys', 'package', pkg]));
|
|
290
289
|
return extractMatchingPermissions(stdout, ['install', 'runtime'], true);
|
|
291
290
|
}
|
|
@@ -298,7 +297,7 @@ async function getGrantedPermissions(pkg, cmdOutput = null) {
|
|
|
298
297
|
* @returns The list of denied permissions or an empty list.
|
|
299
298
|
*/
|
|
300
299
|
async function getDeniedPermissions(pkg, cmdOutput = null) {
|
|
301
|
-
|
|
300
|
+
logger_1.log.debug('Retrieving denied permissions');
|
|
302
301
|
const stdout = cmdOutput || (await this.shell(['dumpsys', 'package', pkg]));
|
|
303
302
|
return extractMatchingPermissions(stdout, ['install', 'runtime'], false);
|
|
304
303
|
}
|
|
@@ -311,7 +310,7 @@ async function getDeniedPermissions(pkg, cmdOutput = null) {
|
|
|
311
310
|
* @returns The list of requested permissions or an empty list.
|
|
312
311
|
*/
|
|
313
312
|
async function getReqPermissions(pkg, cmdOutput = null) {
|
|
314
|
-
|
|
313
|
+
logger_1.log.debug('Retrieving requested permissions');
|
|
315
314
|
const stdout = cmdOutput || (await this.shell(['dumpsys', 'package', pkg]));
|
|
316
315
|
return extractMatchingPermissions(stdout, ['requested']);
|
|
317
316
|
}
|
|
@@ -337,7 +336,7 @@ async function stopAndClear(pkg) {
|
|
|
337
336
|
* @returns The parsed application information.
|
|
338
337
|
*/
|
|
339
338
|
async function getPackageInfo(pkg) {
|
|
340
|
-
|
|
339
|
+
logger_1.log.debug(`Getting package info for '${pkg}'`);
|
|
341
340
|
const result = { name: pkg };
|
|
342
341
|
let stdout;
|
|
343
342
|
try {
|
|
@@ -345,8 +344,8 @@ async function getPackageInfo(pkg) {
|
|
|
345
344
|
}
|
|
346
345
|
catch (err) {
|
|
347
346
|
const error = err;
|
|
348
|
-
|
|
349
|
-
|
|
347
|
+
logger_1.log.debug(error.stack);
|
|
348
|
+
logger_1.log.warn(`Got an unexpected error while dumping package info: ${error.message}`);
|
|
350
349
|
return result;
|
|
351
350
|
}
|
|
352
351
|
const installedPattern = new RegExp(`^\\s*Package\\s+\\[${lodash_1.default.escapeRegExp(pkg)}\\][^:]+:$`, 'm');
|
|
@@ -381,7 +380,7 @@ async function pullApk(pkg, tmpDir) {
|
|
|
381
380
|
const remotePath = stdout.replace(packageMarker, '');
|
|
382
381
|
const tmpApp = node_path_1.default.resolve(tmpDir, `${pkg}.apk`);
|
|
383
382
|
await this.pull(remotePath, tmpApp);
|
|
384
|
-
|
|
383
|
+
logger_1.log.debug(`Pulled app for package '${pkg}' to '${tmpApp}'`);
|
|
385
384
|
return tmpApp;
|
|
386
385
|
}
|
|
387
386
|
/**
|
|
@@ -393,7 +392,7 @@ async function pullApk(pkg, tmpDir) {
|
|
|
393
392
|
* @throws {Error} If the app cannot be activated
|
|
394
393
|
*/
|
|
395
394
|
async function activateApp(appId) {
|
|
396
|
-
|
|
395
|
+
logger_1.log.debug(`Activating '${appId}'`);
|
|
397
396
|
const apiLevel = await this.getApiLevel();
|
|
398
397
|
// Fallback to Monkey in older APIs
|
|
399
398
|
if (apiLevel < 24) {
|
|
@@ -403,21 +402,21 @@ async function activateApp(appId) {
|
|
|
403
402
|
let output = '';
|
|
404
403
|
try {
|
|
405
404
|
output = await this.shell(cmd);
|
|
406
|
-
|
|
405
|
+
logger_1.log.debug(`Command stdout: ${output}`);
|
|
407
406
|
}
|
|
408
407
|
catch (e) {
|
|
409
408
|
const error = e;
|
|
410
|
-
throw
|
|
409
|
+
throw logger_1.log.errorWithException(`Cannot activate '${appId}'. Original error: ${error.message}`);
|
|
411
410
|
}
|
|
412
411
|
if (output.includes('monkey aborted')) {
|
|
413
|
-
throw
|
|
412
|
+
throw logger_1.log.errorWithException(`Cannot activate '${appId}'. Are you sure it is installed?`);
|
|
414
413
|
}
|
|
415
414
|
return;
|
|
416
415
|
}
|
|
417
416
|
let activityName = await this.resolveLaunchableActivity(appId);
|
|
418
417
|
if (activityName === RESOLVER_ACTIVITY_NAME) {
|
|
419
418
|
// https://github.com/appium/appium/issues/17128
|
|
420
|
-
|
|
419
|
+
logger_1.log.debug(`The launchable activity name of '${appId}' was resolved to '${activityName}'. ` +
|
|
421
420
|
`Switching the resolver to not use cmd`);
|
|
422
421
|
activityName = await this.resolveLaunchableActivity(appId, { preferCmd: false });
|
|
423
422
|
}
|
|
@@ -436,7 +435,7 @@ async function activateApp(appId) {
|
|
|
436
435
|
'-n',
|
|
437
436
|
activityName,
|
|
438
437
|
]);
|
|
439
|
-
|
|
438
|
+
logger_1.log.debug(stdout);
|
|
440
439
|
if (/^error:/im.test(stdout)) {
|
|
441
440
|
throw new Error(`Cannot activate '${appId}'. Original error: ${stdout}`);
|
|
442
441
|
}
|
|
@@ -450,7 +449,7 @@ async function activateApp(appId) {
|
|
|
450
449
|
*/
|
|
451
450
|
async function isAppInstalled(pkg, opts = {}) {
|
|
452
451
|
const { user } = opts;
|
|
453
|
-
|
|
452
|
+
logger_1.log.debug(`Getting install status for ${pkg}`);
|
|
454
453
|
let isInstalled;
|
|
455
454
|
if ((await this.getApiLevel()) < 26) {
|
|
456
455
|
try {
|
|
@@ -470,7 +469,7 @@ async function isAppInstalled(pkg, opts = {}) {
|
|
|
470
469
|
const installedPAckages = await this.listInstalledPackages(opts);
|
|
471
470
|
isInstalled = installedPAckages.some((p) => p.appPackage === pkg);
|
|
472
471
|
}
|
|
473
|
-
|
|
472
|
+
logger_1.log.debug(`'${pkg}' is${!isInstalled ? ' not' : ''} installed`);
|
|
474
473
|
return isInstalled;
|
|
475
474
|
}
|
|
476
475
|
/**
|
|
@@ -582,7 +581,7 @@ async function startApp(startAppOptions) {
|
|
|
582
581
|
const stdout = await this.shell(cmd, shellOpts);
|
|
583
582
|
if (stdout.includes('Error: Activity class') && stdout.includes('does not exist')) {
|
|
584
583
|
if (options.retry && options.activity && !options.activity.startsWith('.')) {
|
|
585
|
-
|
|
584
|
+
logger_1.log.debug(`We tried to start an activity that doesn't exist, ` +
|
|
586
585
|
`retrying with '.${options.activity}' activity name`);
|
|
587
586
|
options.activity = `.${options.activity}`;
|
|
588
587
|
options.retry = false;
|
|
@@ -633,7 +632,7 @@ async function dumpWindows() {
|
|
|
633
632
|
* @throws {Error} If there is an error while parsing the data.
|
|
634
633
|
*/
|
|
635
634
|
async function getFocusedPackageAndActivity() {
|
|
636
|
-
|
|
635
|
+
logger_1.log.debug('Getting focused package and activity');
|
|
637
636
|
let stdout;
|
|
638
637
|
try {
|
|
639
638
|
stdout = await this.dumpWindows();
|
|
@@ -684,7 +683,7 @@ async function getFocusedPackageAndActivity() {
|
|
|
684
683
|
};
|
|
685
684
|
}
|
|
686
685
|
}
|
|
687
|
-
|
|
686
|
+
logger_1.log.debug(stdout);
|
|
688
687
|
throw new Error('Could not retrieve the currently focused package and activity');
|
|
689
688
|
}
|
|
690
689
|
/**
|
|
@@ -728,11 +727,11 @@ async function waitForActivityOrNot(pkg, activity, waitForStop, waitMs = 20000)
|
|
|
728
727
|
}
|
|
729
728
|
}
|
|
730
729
|
}
|
|
731
|
-
|
|
730
|
+
logger_1.log.debug(`Expected package names to ${waitForStop ? 'not ' : ''}be focused within ${waitMs}ms: ` +
|
|
732
731
|
allPackages.map((name) => `'${name}'`).join(', '));
|
|
733
732
|
const possibleActivityNames = [...possibleActivityNamesSet];
|
|
734
733
|
const possibleActivityPatterns = possibleActivityNames.map((actName) => new RegExp(`^${actName.replace(/\./g, '\\.').replace(/\*/g, '.*?').replace(/\$/g, '\\$')}$`));
|
|
735
|
-
|
|
734
|
+
logger_1.log.debug(`Expected activity name patterns to ${waitForStop ? 'not ' : ''}be focused within ${waitMs}ms: ` +
|
|
736
735
|
possibleActivityPatterns.map((name) => `'${name}'`).join(', '));
|
|
737
736
|
const conditionFunc = async () => {
|
|
738
737
|
let appPackage;
|
|
@@ -742,20 +741,20 @@ async function waitForActivityOrNot(pkg, activity, waitForStop, waitMs = 20000)
|
|
|
742
741
|
}
|
|
743
742
|
catch (e) {
|
|
744
743
|
const error = e;
|
|
745
|
-
|
|
744
|
+
logger_1.log.debug(error.message);
|
|
746
745
|
return false;
|
|
747
746
|
}
|
|
748
747
|
if (appActivity && appPackage) {
|
|
749
|
-
|
|
748
|
+
logger_1.log.debug(`Focused package: ${appPackage}`);
|
|
750
749
|
const fullyQualifiedActivity = toFullyQualifiedActivityName(appActivity.startsWith('.') ? appPackage : '', appActivity);
|
|
751
|
-
|
|
750
|
+
logger_1.log.debug(`Focused fully qualified activity name: ${fullyQualifiedActivity}`);
|
|
752
751
|
const isFound = lodash_1.default.includes(allPackages, appPackage) &&
|
|
753
752
|
possibleActivityPatterns.some((p) => p.test(fullyQualifiedActivity));
|
|
754
753
|
if ((!waitForStop && isFound) || (waitForStop && !isFound)) {
|
|
755
754
|
return true;
|
|
756
755
|
}
|
|
757
756
|
}
|
|
758
|
-
|
|
757
|
+
logger_1.log.debug('None of the expected package/activity combinations matched to the currently focused one. Retrying');
|
|
759
758
|
return false;
|
|
760
759
|
};
|
|
761
760
|
try {
|
|
@@ -967,7 +966,7 @@ function extractMatchingPermissions(dumpsysOutput, groupNames, grantedState = nu
|
|
|
967
966
|
const filteredResult = result
|
|
968
967
|
.filter((item) => !lodash_1.default.isBoolean(grantedState) || item.granted === grantedState)
|
|
969
968
|
.map((item) => item.permission);
|
|
970
|
-
|
|
969
|
+
logger_1.log.debug(`Retrieved ${support_1.util.pluralize('permission', filteredResult.length, true)} ` +
|
|
971
970
|
`from ${groupNames} ${support_1.util.pluralize('group', groupNames.length, false)}`);
|
|
972
971
|
return filteredResult;
|
|
973
972
|
}
|
|
@@ -981,7 +980,7 @@ async function broadcast(intent) {
|
|
|
981
980
|
if (!this.isValidClass(intent)) {
|
|
982
981
|
throw new Error(`Invalid intent ${intent}`);
|
|
983
982
|
}
|
|
984
|
-
|
|
983
|
+
logger_1.log.debug(`Broadcasting: ${intent}`);
|
|
985
984
|
await this.shell(['am', 'broadcast', '-a', intent]);
|
|
986
985
|
}
|
|
987
986
|
/**
|
|
@@ -991,7 +990,7 @@ async function broadcast(intent) {
|
|
|
991
990
|
* @returns The list of matched process IDs or an empty list.
|
|
992
991
|
*/
|
|
993
992
|
async function listAppProcessIds(pkg) {
|
|
994
|
-
|
|
993
|
+
logger_1.log.debug(`Getting IDs of all '${pkg}' package`);
|
|
995
994
|
const pidRegex = new RegExp(`ProcessRecord\\{[\\w]+\\s+(\\d+):${lodash_1.default.escapeRegExp(pkg)}\\/`);
|
|
996
995
|
const processesInfo = await this.shell(['dumpsys', 'activity', 'processes']);
|
|
997
996
|
const pids = processesInfo
|
|
@@ -1011,7 +1010,6 @@ async function listAppProcessIds(pkg) {
|
|
|
1011
1010
|
async function isAppRunning(pkg) {
|
|
1012
1011
|
return !lodash_1.default.isEmpty(await this.listAppProcessIds(pkg));
|
|
1013
1012
|
}
|
|
1014
|
-
// Private methods
|
|
1015
1013
|
/**
|
|
1016
1014
|
* Parses optional intent arguments from a string.
|
|
1017
1015
|
*
|