@yume-chan/android-bin 0.0.0-20240714132542
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 +129 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/esm/am.d.ts +17 -0
- package/esm/am.d.ts.map +1 -0
- package/esm/am.js +42 -0
- package/esm/am.js.map +1 -0
- package/esm/bu.d.ts +28 -0
- package/esm/bu.d.ts.map +1 -0
- package/esm/bu.js +53 -0
- package/esm/bu.js.map +1 -0
- package/esm/bug-report.d.ts +99 -0
- package/esm/bug-report.d.ts.map +1 -0
- package/esm/bug-report.js +271 -0
- package/esm/bug-report.js.map +1 -0
- package/esm/cmd.d.ts +25 -0
- package/esm/cmd.d.ts.map +1 -0
- package/esm/cmd.js +81 -0
- package/esm/cmd.js.map +1 -0
- package/esm/demo-mode.d.ts +44 -0
- package/esm/demo-mode.d.ts.map +1 -0
- package/esm/demo-mode.js +179 -0
- package/esm/demo-mode.js.map +1 -0
- package/esm/dumpsys.d.ts +51 -0
- package/esm/dumpsys.d.ts.map +1 -0
- package/esm/dumpsys.js +114 -0
- package/esm/dumpsys.js.map +1 -0
- package/esm/index.d.ts +13 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +14 -0
- package/esm/index.js.map +1 -0
- package/esm/intent.d.ts +11 -0
- package/esm/intent.d.ts.map +1 -0
- package/esm/intent.js +59 -0
- package/esm/intent.js.map +1 -0
- package/esm/logcat.d.ts +93 -0
- package/esm/logcat.d.ts.map +1 -0
- package/esm/logcat.js +300 -0
- package/esm/logcat.js.map +1 -0
- package/esm/overlay-display.d.ts +38 -0
- package/esm/overlay-display.d.ts.map +1 -0
- package/esm/overlay-display.js +51 -0
- package/esm/overlay-display.js.map +1 -0
- package/esm/pm.d.ts +211 -0
- package/esm/pm.d.ts.map +1 -0
- package/esm/pm.js +382 -0
- package/esm/pm.js.map +1 -0
- package/esm/settings.d.ts +27 -0
- package/esm/settings.d.ts.map +1 -0
- package/esm/settings.js +66 -0
- package/esm/settings.js.map +1 -0
- package/esm/string-format.d.ts +43 -0
- package/esm/string-format.d.ts.map +1 -0
- package/esm/string-format.js +152 -0
- package/esm/string-format.js.map +1 -0
- package/esm/utils.d.ts +4 -0
- package/esm/utils.d.ts.map +1 -0
- package/esm/utils.js +23 -0
- package/esm/utils.js.map +1 -0
- package/package.json +49 -0
- package/src/am.ts +71 -0
- package/src/bu.ts +80 -0
- package/src/bug-report.ts +348 -0
- package/src/cmd.ts +113 -0
- package/src/demo-mode.ts +232 -0
- package/src/dumpsys.ts +153 -0
- package/src/index.ts +14 -0
- package/src/intent.ts +73 -0
- package/src/logcat.ts +509 -0
- package/src/overlay-display.ts +112 -0
- package/src/pm.ts +674 -0
- package/src/settings.ts +128 -0
- package/src/string-format.ts +197 -0
- package/src/utils.ts +29 -0
- package/tsconfig.build.json +14 -0
- package/tsconfig.build.tsbuildinfo +1 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export class ParseError extends Error {
|
|
2
|
+
#expected;
|
|
3
|
+
get expected() {
|
|
4
|
+
return this.#expected;
|
|
5
|
+
}
|
|
6
|
+
constructor(expected) {
|
|
7
|
+
super(`Expected ${expected.join(", ")}`);
|
|
8
|
+
this.#expected = expected;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const p = {
|
|
12
|
+
literal: (value) => ({
|
|
13
|
+
parse(reader) {
|
|
14
|
+
if (!reader.value.startsWith(value, reader.position)) {
|
|
15
|
+
throw new ParseError([value.charAt(0)]);
|
|
16
|
+
}
|
|
17
|
+
reader.position += value.length;
|
|
18
|
+
return value;
|
|
19
|
+
},
|
|
20
|
+
stringify() {
|
|
21
|
+
return value;
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
digits: () => ({
|
|
25
|
+
parse(reader) {
|
|
26
|
+
const match = reader.value.substring(reader.position).match(/^\d+/);
|
|
27
|
+
if (!match) {
|
|
28
|
+
throw new ParseError("0123456789".split(""));
|
|
29
|
+
}
|
|
30
|
+
reader.position += match[0].length;
|
|
31
|
+
return Number.parseInt(match[0], 10);
|
|
32
|
+
},
|
|
33
|
+
stringify(value) {
|
|
34
|
+
return value.toString();
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
union: (...args) => ({
|
|
38
|
+
parse(reader) {
|
|
39
|
+
const expected = [];
|
|
40
|
+
for (const format of args) {
|
|
41
|
+
try {
|
|
42
|
+
return format.parse(reader);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
if (e instanceof ParseError) {
|
|
46
|
+
expected.push(...e.expected);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new ParseError(expected);
|
|
54
|
+
},
|
|
55
|
+
stringify(value) {
|
|
56
|
+
for (const format of args) {
|
|
57
|
+
try {
|
|
58
|
+
const result = format.stringify(value);
|
|
59
|
+
// Parse the result to make sure it is valid
|
|
60
|
+
format.parse({ value: result, position: 0 });
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
// ignore
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
throw new Error("No format matches");
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
separated: (separator, format, { min = 0, max = Infinity } = {}) => ({
|
|
70
|
+
parse(reader) {
|
|
71
|
+
const result = [];
|
|
72
|
+
while (true) {
|
|
73
|
+
try {
|
|
74
|
+
result.push(format.parse(reader));
|
|
75
|
+
if (result.length === max) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
if (result.length < min) {
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (reader.value.startsWith(separator, reader.position)) {
|
|
88
|
+
reader.position += separator.length;
|
|
89
|
+
}
|
|
90
|
+
else if (result.length < min) {
|
|
91
|
+
throw new ParseError([separator.charAt(0)]);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
},
|
|
99
|
+
stringify(value) {
|
|
100
|
+
return value.map((item) => format.stringify(item)).join(separator);
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
repeated: (format) => ({
|
|
104
|
+
parse(reader) {
|
|
105
|
+
const result = [];
|
|
106
|
+
while (true) {
|
|
107
|
+
try {
|
|
108
|
+
result.push(format.parse(reader));
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
stringify(value) {
|
|
117
|
+
return value.map((item) => format.stringify(item)).join("");
|
|
118
|
+
},
|
|
119
|
+
}),
|
|
120
|
+
sequence: (...args) => ({
|
|
121
|
+
parse(reader) {
|
|
122
|
+
const result = {};
|
|
123
|
+
for (const part of args) {
|
|
124
|
+
if ("name" in part) {
|
|
125
|
+
result[part.name] = part.format.parse(reader);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
void part.parse(reader);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
},
|
|
133
|
+
stringify: (value) => {
|
|
134
|
+
let result = "";
|
|
135
|
+
for (const part of args) {
|
|
136
|
+
if ("name" in part) {
|
|
137
|
+
result += part.format.stringify(value[part.name]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
map: (format, map, reverse) => ({
|
|
144
|
+
parse(reader) {
|
|
145
|
+
return map(format.parse(reader));
|
|
146
|
+
},
|
|
147
|
+
stringify(value) {
|
|
148
|
+
return format.stringify(reverse(value));
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=string-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-format.js","sourceRoot":"","sources":["../src/string-format.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IACjC,SAAS,CAAW;IAEpB,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,YAAY,QAAkB;QAC1B,KAAK,CAAC,YAAY,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;CACJ;AAkCD,MAAM,CAAC,MAAM,CAAC,GAAG;IACb,OAAO,EAAE,CAAmB,KAAQ,EAAa,EAAE,CAAC,CAAC;QACjD,KAAK,CAAC,MAAM;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACnD,MAAM,IAAI,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC;YACD,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC;YAChC,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,SAAS;YACL,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;IACF,MAAM,EAAE,GAAmB,EAAE,CAAC,CAAC;QAC3B,KAAK,CAAC,MAAM;YACR,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACpE,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,MAAM,IAAI,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;YACjD,CAAC;YACD,MAAM,CA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BACN,CAAC;YACL,CAAC;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;IACF,GAAG,EAAE,CACD,MAAiB,EACjB,GAAoB,EACpB,OAAwB,EACf,EAAE,CAAC,CAAC;QACb,KAAK,CAAC,MAAc;YAChB,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,SAAS,CAAC,KAAQ;YACd,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;KACJ,CAAC;CACyD,CAAC"}
|
package/esm/utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function buildArguments<T>(commands: string[], options: Partial<T> | undefined, map: Partial<Record<keyof T, string>>): string[];
|
|
2
|
+
export type SingleUser = number | "current";
|
|
3
|
+
export type SingleUserOrAll = SingleUser | "all";
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,CAAC,EAC5B,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,EAC/B,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACtC,MAAM,EAAE,CAqBV;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5C,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,KAAK,CAAC"}
|
package/esm/utils.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function buildArguments(commands, options, map) {
|
|
2
|
+
const args = commands;
|
|
3
|
+
if (options) {
|
|
4
|
+
for (const [key, value] of Object.entries(options)) {
|
|
5
|
+
if (value) {
|
|
6
|
+
const option = map[key];
|
|
7
|
+
if (option) {
|
|
8
|
+
args.push(option);
|
|
9
|
+
switch (typeof value) {
|
|
10
|
+
case "number":
|
|
11
|
+
args.push(value.toString());
|
|
12
|
+
break;
|
|
13
|
+
case "string":
|
|
14
|
+
args.push(value);
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return args;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
package/esm/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAC1B,QAAkB,EAClB,OAA+B,EAC/B,GAAqC;IAErC,MAAM,IAAI,GAAG,QAAQ,CAAC;IACtB,IAAI,OAAO,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACjD,IAAI,KAAK,EAAE,CAAC;gBACR,MAAM,MAAM,GAAG,GAAG,CAAC,GAAc,CAAC,CAAC;gBACnC,IAAI,MAAM,EAAE,CAAC;oBACT,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAClB,QAAQ,OAAO,KAAK,EAAE,CAAC;wBACnB,KAAK,QAAQ;4BACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;4BAC5B,MAAM;wBACV,KAAK,QAAQ;4BACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;4BACjB,MAAM;oBACd,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yume-chan/android-bin",
|
|
3
|
+
"version": "0.0.0-20240714132542",
|
|
4
|
+
"description": "Wrappers for Android built-in executables.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"adb",
|
|
7
|
+
"Android"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Simon Chan",
|
|
12
|
+
"email": "cnsimonchan@live.com",
|
|
13
|
+
"url": "https://chensi.moe/blog"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/yume-chan/ya-webadb/tree/main/libraries/android-bin#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/yume-chan/ya-webadb.git",
|
|
19
|
+
"directory": "libraries/android-bin"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "esm/index.js",
|
|
26
|
+
"types": "esm/index.d.ts",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@yume-chan/adb": "0.0.0-20240714132542",
|
|
30
|
+
"@yume-chan/stream-extra": "0.0.0-20240714132542",
|
|
31
|
+
"@yume-chan/struct": "0.0.0-20240714132542"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@jest/globals": "^30.0.0-alpha.4",
|
|
35
|
+
"@yume-chan/eslint-config": "^1.0.0",
|
|
36
|
+
"@yume-chan/tsconfig": "^1.0.0",
|
|
37
|
+
"cross-env": "^7.0.3",
|
|
38
|
+
"jest": "^30.0.0-alpha.4",
|
|
39
|
+
"prettier": "^3.3.3",
|
|
40
|
+
"ts-jest": "^29.2.2",
|
|
41
|
+
"typescript": "^5.5.3"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -b tsconfig.build.json",
|
|
45
|
+
"build:watch": "tsc -b tsconfig.build.json",
|
|
46
|
+
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" TS_JEST_DISABLE_VER_CHECKER=true jest --coverage",
|
|
47
|
+
"lint": "run-eslint && prettier src/**/*.ts --write --tab-width 4"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/am.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Adb } from "@yume-chan/adb";
|
|
2
|
+
import { AdbCommandBase } from "@yume-chan/adb";
|
|
3
|
+
import { ConcatStringStream, TextDecoderStream } from "@yume-chan/stream-extra";
|
|
4
|
+
|
|
5
|
+
import { Cmd } from "./cmd.js";
|
|
6
|
+
import type { IntentBuilder } from "./intent.js";
|
|
7
|
+
import type { SingleUser } from "./utils.js";
|
|
8
|
+
import { buildArguments } from "./utils.js";
|
|
9
|
+
|
|
10
|
+
export interface ActivityManagerStartActivityOptions {
|
|
11
|
+
displayId?: number;
|
|
12
|
+
windowingMode?: number;
|
|
13
|
+
forceStop?: boolean;
|
|
14
|
+
user?: SingleUser;
|
|
15
|
+
intent: IntentBuilder;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const START_ACTIVITY_OPTIONS_MAP: Partial<
|
|
19
|
+
Record<keyof ActivityManagerStartActivityOptions, string>
|
|
20
|
+
> = {
|
|
21
|
+
displayId: "--display",
|
|
22
|
+
windowingMode: "--windowingMode",
|
|
23
|
+
forceStop: "-S",
|
|
24
|
+
user: "--user",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export class ActivityManager extends AdbCommandBase {
|
|
28
|
+
#cmd: Cmd;
|
|
29
|
+
|
|
30
|
+
constructor(adb: Adb) {
|
|
31
|
+
super(adb);
|
|
32
|
+
this.#cmd = new Cmd(adb);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async #cmdOrSubprocess(args: string[]) {
|
|
36
|
+
if (this.#cmd.supportsCmd) {
|
|
37
|
+
args.shift();
|
|
38
|
+
return await this.#cmd.spawn(false, "activity", ...args);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return this.adb.subprocess.spawn(args);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async startActivity(
|
|
45
|
+
options: ActivityManagerStartActivityOptions,
|
|
46
|
+
): Promise<void> {
|
|
47
|
+
let args = buildArguments(
|
|
48
|
+
["am", "start-activity", "-W"],
|
|
49
|
+
options,
|
|
50
|
+
START_ACTIVITY_OPTIONS_MAP,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
args = args.concat(options.intent.build());
|
|
54
|
+
|
|
55
|
+
const process = await this.#cmdOrSubprocess(args);
|
|
56
|
+
|
|
57
|
+
const output = await process.stdout
|
|
58
|
+
.pipeThrough(new TextDecoderStream())
|
|
59
|
+
.pipeThrough(new ConcatStringStream())
|
|
60
|
+
.then((output) => output.trim());
|
|
61
|
+
|
|
62
|
+
for (const line of output) {
|
|
63
|
+
if (line.startsWith("Error:")) {
|
|
64
|
+
throw new Error(line.substring("Error:".length).trim());
|
|
65
|
+
}
|
|
66
|
+
if (line === "Complete") {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/bu.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AdbCommandBase } from "@yume-chan/adb";
|
|
2
|
+
import type { MaybeConsumable, ReadableStream } from "@yume-chan/stream-extra";
|
|
3
|
+
import { ConcatStringStream, TextDecoderStream } from "@yume-chan/stream-extra";
|
|
4
|
+
|
|
5
|
+
export interface AdbBackupOptions {
|
|
6
|
+
user: number;
|
|
7
|
+
saveSharedStorage?: boolean;
|
|
8
|
+
saveWidgets?: boolean;
|
|
9
|
+
packages: string[] | "user" | "all";
|
|
10
|
+
savePackageApk: boolean;
|
|
11
|
+
savePackageObb: boolean;
|
|
12
|
+
savePackageKeyValue: boolean;
|
|
13
|
+
compress: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AdbRestoreOptions {
|
|
17
|
+
user: number;
|
|
18
|
+
file: ReadableStream<MaybeConsumable<Uint8Array>>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class AdbBackup extends AdbCommandBase {
|
|
22
|
+
/**
|
|
23
|
+
* User must confirm backup on device within 60 seconds.
|
|
24
|
+
*/
|
|
25
|
+
async backup(
|
|
26
|
+
options: AdbBackupOptions,
|
|
27
|
+
): Promise<ReadableStream<Uint8Array>> {
|
|
28
|
+
const args = ["bu", "backup"];
|
|
29
|
+
|
|
30
|
+
if (options.user !== undefined) {
|
|
31
|
+
args.push("--user", options.user.toString());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
args.push(options.saveSharedStorage ? "--shared" : "--no-shared");
|
|
35
|
+
args.push(options.saveWidgets ? "--widgets" : "--no-widgets");
|
|
36
|
+
|
|
37
|
+
args.push(options.savePackageApk ? "--apk" : "--no-apk");
|
|
38
|
+
args.push(options.savePackageObb ? "--obb" : "--no-obb");
|
|
39
|
+
args.push(
|
|
40
|
+
options.savePackageKeyValue ? "--key-value" : "--no-key-value",
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
args.push(options.compress ? "--compress" : "--no-compress");
|
|
44
|
+
|
|
45
|
+
if (typeof options.packages === "string") {
|
|
46
|
+
switch (options.packages) {
|
|
47
|
+
case "user":
|
|
48
|
+
args.push("--all", "--no-system");
|
|
49
|
+
break;
|
|
50
|
+
case "all":
|
|
51
|
+
args.push("--all", "--system");
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
args.push(...options.packages);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const process = await this.adb.subprocess.spawn(args);
|
|
59
|
+
return process.stdout;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* User must enter the password (if any) and
|
|
64
|
+
* confirm restore on device within 60 seconds.
|
|
65
|
+
*/
|
|
66
|
+
async restore(options: AdbRestoreOptions): Promise<string> {
|
|
67
|
+
const args = ["bu", "restore"];
|
|
68
|
+
if (options.user !== undefined) {
|
|
69
|
+
args.push("--user", options.user.toString());
|
|
70
|
+
}
|
|
71
|
+
const process = await this.adb.subprocess.spawn(args);
|
|
72
|
+
const [output] = await Promise.all([
|
|
73
|
+
process.stdout
|
|
74
|
+
.pipeThrough(new TextDecoderStream())
|
|
75
|
+
.pipeThrough(new ConcatStringStream()),
|
|
76
|
+
options.file.pipeTo(process.stdin),
|
|
77
|
+
]);
|
|
78
|
+
return output;
|
|
79
|
+
}
|
|
80
|
+
}
|