@bryce3310687963/android-toolkit 1.0.55 → 1.0.56
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/README.md +6 -0
- package/dist/index.cjs +12 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +12 -4
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,6 +82,12 @@ Excluded:
|
|
|
82
82
|
|
|
83
83
|
## Clear App Cache
|
|
84
84
|
|
|
85
|
+
`Device.writeCacheFile(ctx, { dirName, fileName, text })` writes text directly to
|
|
86
|
+
`/data/data/<package>/cache/<dirName>/<fileName>` with root, sets app ownership,
|
|
87
|
+
and returns the device path. Its ADB command arguments and raw command errors
|
|
88
|
+
are redacted, including retries, so file contents do not enter logs or error
|
|
89
|
+
reports. Callers that stage credentials must remove the temporary files after use.
|
|
90
|
+
|
|
85
91
|
`Device.clearAppCache(ctx, packageName = ctx.packageName)` requires root ADB access.
|
|
86
92
|
Stop the app before clearing its cache, then launch it again:
|
|
87
93
|
|
package/dist/index.cjs
CHANGED
|
@@ -912,9 +912,16 @@ async function adbExec(ctx, args, options = {}) {
|
|
|
912
912
|
const startedAt = Date.now();
|
|
913
913
|
try {
|
|
914
914
|
const { stdout } = await execAdbWithRetry(adbPath, args, options);
|
|
915
|
-
Logger.useTemplate().adbExec({ duration: Logger.duration(startedAt), args: compactArgs(args) });
|
|
915
|
+
Logger.useTemplate().adbExec({ duration: Logger.duration(startedAt), args: options.sensitive ? "[REDACTED]" : compactArgs(args) });
|
|
916
916
|
return stdout;
|
|
917
917
|
} catch (error) {
|
|
918
|
+
if (options.sensitive) {
|
|
919
|
+
throw new CrawlerError({
|
|
920
|
+
message: "ADB command failed (sensitive content omitted)",
|
|
921
|
+
code: isAdbUnavailableError(error) ? Code.AdbUnavailable : Code.AutomationFailed,
|
|
922
|
+
context: { adbPath }
|
|
923
|
+
});
|
|
924
|
+
}
|
|
918
925
|
if (isAdbUnavailableError(error)) {
|
|
919
926
|
throw new CrawlerError({
|
|
920
927
|
message: `adb_unavailable: ${error?.message || String(error)}`,
|
|
@@ -943,7 +950,8 @@ async function writeCacheFile(ctx, options = {}) {
|
|
|
943
950
|
].join(" && ");
|
|
944
951
|
await Device.adbShell(ctx, [`su -c ${shellQuoteForRemote(command)}`], {
|
|
945
952
|
timeoutMs: Number(options.timeoutMs || 1e4),
|
|
946
|
-
maxBuffer: Number(options.maxBuffer || 1024)
|
|
953
|
+
maxBuffer: Number(options.maxBuffer || 1024),
|
|
954
|
+
sensitive: true
|
|
947
955
|
});
|
|
948
956
|
return filePath;
|
|
949
957
|
}
|
|
@@ -1267,8 +1275,8 @@ async function execAdbWithRetry(adbPath, args, options = {}) {
|
|
|
1267
1275
|
label: options.label || "adb",
|
|
1268
1276
|
attempt,
|
|
1269
1277
|
attempts,
|
|
1270
|
-
args: compactArgs(args),
|
|
1271
|
-
message: error?.message || String(error)
|
|
1278
|
+
args: options.sensitive ? "[REDACTED]" : compactArgs(args),
|
|
1279
|
+
message: options.sensitive ? "sensitive ADB command failed" : error?.message || String(error)
|
|
1272
1280
|
});
|
|
1273
1281
|
await sleep(delayMs * attempt);
|
|
1274
1282
|
}
|