@yume-chan/android-bin 0.0.17 → 0.0.18
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.json +6 -0
- package/CHANGELOG.md +6 -1
- package/README.md +15 -0
- package/esm/bu.d.ts +1 -1
- package/esm/bu.d.ts.map +1 -1
- package/esm/bu.js +6 -2
- package/esm/bu.js.map +1 -1
- package/esm/bug-report.d.ts +2 -2
- package/esm/bug-report.d.ts.map +1 -1
- package/esm/bug-report.js +27 -16
- package/esm/bug-report.js.map +1 -1
- package/esm/demo-mode.d.ts +3 -3
- package/esm/demo-mode.d.ts.map +1 -1
- package/esm/demo-mode.js +85 -53
- package/esm/demo-mode.js.map +1 -1
- package/esm/logcat.d.ts +4 -4
- package/esm/logcat.d.ts.map +1 -1
- package/esm/logcat.js +52 -44
- package/esm/logcat.js.map +1 -1
- package/esm/settings.d.ts +2 -2
- package/esm/settings.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/bu.ts +7 -3
- package/src/bug-report.ts +74 -48
- package/src/demo-mode.ts +113 -65
- package/src/logcat.ts +139 -89
- package/tsconfig.build.json +3 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/.rush/temp/package-deps_build.json +0 -17
- package/.rush/temp/package-deps_build_watch.json +0 -17
- package/.rush/temp/shrinkwrap-deps.json +0 -5
- package/android-bin.build.log +0 -1
- package/tsconfig.json +0 -11
package/esm/logcat.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// cspell: ignore logcat
|
|
2
|
-
import { AdbCommandBase, AdbSubprocessNoneProtocol } from
|
|
3
|
-
import { BufferedTransformStream, DecodeUtf8Stream, SplitStringStream, WrapReadableStream, WritableStream } from
|
|
4
|
-
import Struct, { decodeUtf8 } from
|
|
2
|
+
import { AdbCommandBase, AdbSubprocessNoneProtocol } from "@yume-chan/adb";
|
|
3
|
+
import { BufferedTransformStream, DecodeUtf8Stream, SplitStringStream, WrapReadableStream, WritableStream, } from "@yume-chan/stream-extra";
|
|
4
|
+
import Struct, { decodeUtf8, } from "@yume-chan/struct";
|
|
5
5
|
// `adb logcat` is an alias to `adb shell logcat`
|
|
6
6
|
// so instead of adding to core library, it's implemented here
|
|
7
7
|
// https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/android/log.h;l=141;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
|
|
@@ -16,7 +16,7 @@ export var LogId;
|
|
|
16
16
|
LogId[LogId["Stats"] = 5] = "Stats";
|
|
17
17
|
LogId[LogId["Security"] = 6] = "Security";
|
|
18
18
|
LogId[LogId["Kernel"] = 7] = "Kernel";
|
|
19
|
-
})(LogId || (LogId = {}));
|
|
19
|
+
})(LogId = LogId || (LogId = {}));
|
|
20
20
|
// https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/android/log.h;l=73;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
|
|
21
21
|
export var AndroidLogPriority;
|
|
22
22
|
(function (AndroidLogPriority) {
|
|
@@ -29,18 +29,18 @@ export var AndroidLogPriority;
|
|
|
29
29
|
AndroidLogPriority[AndroidLogPriority["Error"] = 6] = "Error";
|
|
30
30
|
AndroidLogPriority[AndroidLogPriority["Fatal"] = 7] = "Fatal";
|
|
31
31
|
AndroidLogPriority[AndroidLogPriority["Silent"] = 8] = "Silent";
|
|
32
|
-
})(AndroidLogPriority || (AndroidLogPriority = {}));
|
|
32
|
+
})(AndroidLogPriority = AndroidLogPriority || (AndroidLogPriority = {}));
|
|
33
33
|
// https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/logprint.cpp;l=140;drc=8dbf3b2bb6b6d1652d9797e477b9abd03278bb79
|
|
34
34
|
export const AndroidLogPriorityToCharacter = {
|
|
35
|
-
[AndroidLogPriority.Unknown]:
|
|
36
|
-
[AndroidLogPriority.Default]:
|
|
37
|
-
[AndroidLogPriority.Verbose]:
|
|
38
|
-
[AndroidLogPriority.Debug]:
|
|
39
|
-
[AndroidLogPriority.Info]:
|
|
40
|
-
[AndroidLogPriority.Warn]:
|
|
41
|
-
[AndroidLogPriority.Error]:
|
|
42
|
-
[AndroidLogPriority.Fatal]:
|
|
43
|
-
[AndroidLogPriority.Silent]:
|
|
35
|
+
[AndroidLogPriority.Unknown]: "?",
|
|
36
|
+
[AndroidLogPriority.Default]: "?",
|
|
37
|
+
[AndroidLogPriority.Verbose]: "V",
|
|
38
|
+
[AndroidLogPriority.Debug]: "D",
|
|
39
|
+
[AndroidLogPriority.Info]: "I",
|
|
40
|
+
[AndroidLogPriority.Warn]: "W",
|
|
41
|
+
[AndroidLogPriority.Error]: "E",
|
|
42
|
+
[AndroidLogPriority.Fatal]: "F",
|
|
43
|
+
[AndroidLogPriority.Silent]: "S",
|
|
44
44
|
};
|
|
45
45
|
export var LogcatFormat;
|
|
46
46
|
(function (LogcatFormat) {
|
|
@@ -52,47 +52,50 @@ export var LogcatFormat;
|
|
|
52
52
|
LogcatFormat[LogcatFormat["Time"] = 5] = "Time";
|
|
53
53
|
LogcatFormat[LogcatFormat["ThreadTime"] = 6] = "ThreadTime";
|
|
54
54
|
LogcatFormat[LogcatFormat["Long"] = 7] = "Long";
|
|
55
|
-
})(LogcatFormat || (LogcatFormat = {}));
|
|
55
|
+
})(LogcatFormat = LogcatFormat || (LogcatFormat = {}));
|
|
56
56
|
const NANOSECONDS_PER_SECOND = BigInt(1e9);
|
|
57
57
|
// https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/include/log/log_read.h;l=39;drc=82b5738732161dbaafb2e2f25cce19cd26b9157d
|
|
58
58
|
export const LoggerEntry = new Struct({ littleEndian: true })
|
|
59
|
-
.uint16(
|
|
60
|
-
.uint16(
|
|
61
|
-
.int32(
|
|
62
|
-
.uint32(
|
|
63
|
-
.uint32(
|
|
64
|
-
.uint32(
|
|
65
|
-
.uint32(
|
|
66
|
-
.uint32(
|
|
59
|
+
.uint16("payloadSize")
|
|
60
|
+
.uint16("headerSize")
|
|
61
|
+
.int32("pid")
|
|
62
|
+
.uint32("tid")
|
|
63
|
+
.uint32("second")
|
|
64
|
+
.uint32("nanoseconds")
|
|
65
|
+
.uint32("logId")
|
|
66
|
+
.uint32("uid")
|
|
67
67
|
.extra({
|
|
68
68
|
get timestamp() {
|
|
69
|
-
return BigInt(this.second) * NANOSECONDS_PER_SECOND +
|
|
69
|
+
return (BigInt(this.second) * NANOSECONDS_PER_SECOND +
|
|
70
|
+
BigInt(this.nanoseconds));
|
|
70
71
|
},
|
|
71
72
|
});
|
|
72
73
|
// https://cs.android.com/android/platform/superproject/+/master:system/logging/liblog/logprint.cpp;l=1415;drc=8dbf3b2bb6b6d1652d9797e477b9abd03278bb79
|
|
73
74
|
export function formatAndroidLogEntry(entry, format = LogcatFormat.Brief, modifier) {
|
|
74
|
-
const uid = modifier?.uid ? `${entry.uid.toString().padStart(5)}:` :
|
|
75
|
+
const uid = modifier?.uid ? `${entry.uid.toString().padStart(5)}:` : "";
|
|
75
76
|
switch (format) {
|
|
76
77
|
// TODO: implement other formats
|
|
77
78
|
default:
|
|
78
|
-
return `${AndroidLogPriorityToCharacter[entry.priority]}/${entry.tag.padEnd(8)}(${uid}${entry.pid
|
|
79
|
+
return `${AndroidLogPriorityToCharacter[entry.priority]}/${entry.tag.padEnd(8)}(${uid}${entry.pid
|
|
80
|
+
.toString()
|
|
81
|
+
.padStart(5)}): ${entry.message}`;
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
function findTagEnd(payload) {
|
|
82
|
-
for (const separator of [0,
|
|
85
|
+
for (const separator of [0, " ".charCodeAt(0), ":".charCodeAt(0)]) {
|
|
83
86
|
const index = payload.indexOf(separator);
|
|
84
87
|
if (index !== -1) {
|
|
85
88
|
return index;
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
const index = payload.findIndex(x => x >= 0x7f);
|
|
91
|
+
const index = payload.findIndex((x) => x >= 0x7f);
|
|
89
92
|
if (index !== -1) {
|
|
90
93
|
return index;
|
|
91
94
|
}
|
|
92
95
|
return payload.length;
|
|
93
96
|
}
|
|
94
97
|
export async function deserializeAndroidLogEntry(stream) {
|
|
95
|
-
const entry = await LoggerEntry.deserialize(stream);
|
|
98
|
+
const entry = (await LoggerEntry.deserialize(stream));
|
|
96
99
|
if (entry.headerSize !== LoggerEntry.size) {
|
|
97
100
|
await stream.read(entry.headerSize - LoggerEntry.size);
|
|
98
101
|
}
|
|
@@ -103,7 +106,10 @@ export async function deserializeAndroidLogEntry(stream) {
|
|
|
103
106
|
payload = payload.subarray(1);
|
|
104
107
|
const tagEnd = findTagEnd(payload);
|
|
105
108
|
entry.tag = decodeUtf8(payload.subarray(0, tagEnd));
|
|
106
|
-
entry.message =
|
|
109
|
+
entry.message =
|
|
110
|
+
tagEnd < payload.length - 1
|
|
111
|
+
? decodeUtf8(payload.subarray(tagEnd + 1))
|
|
112
|
+
: "";
|
|
107
113
|
return entry;
|
|
108
114
|
}
|
|
109
115
|
export class Logcat extends AdbCommandBase {
|
|
@@ -115,10 +121,10 @@ export class Logcat extends AdbCommandBase {
|
|
|
115
121
|
return LogId[key];
|
|
116
122
|
}
|
|
117
123
|
static joinLogId(ids) {
|
|
118
|
-
return ids.map(id => Logcat.logIdToName(id)).join(
|
|
124
|
+
return ids.map((id) => Logcat.logIdToName(id)).join(",");
|
|
119
125
|
}
|
|
120
126
|
static parseSize(value, multiplier) {
|
|
121
|
-
const MULTIPLIERS = [
|
|
127
|
+
const MULTIPLIERS = ["", "Ki", "Mi", "Gi"];
|
|
122
128
|
return value * 1024 ** (MULTIPLIERS.indexOf(multiplier) || 0);
|
|
123
129
|
}
|
|
124
130
|
// TODO: logcat: Support output format before Android 10
|
|
@@ -129,14 +135,14 @@ export class Logcat extends AdbCommandBase {
|
|
|
129
135
|
static LOG_SIZE_REGEX_11 = /(.*): ring buffer is (.*) (.*)B \((.*) (.*)B consumed, (.*) (.*)B readable\), max entry is (.*) B, max payload is (.*) B/;
|
|
130
136
|
async getLogSize(ids) {
|
|
131
137
|
const { stdout } = await this.adb.subprocess.spawn([
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
...(ids ? [
|
|
138
|
+
"logcat",
|
|
139
|
+
"-g",
|
|
140
|
+
...(ids ? ["-b", Logcat.joinLogId(ids)] : []),
|
|
135
141
|
]);
|
|
136
142
|
const result = [];
|
|
137
143
|
await stdout
|
|
138
144
|
.pipeThrough(new DecodeUtf8Stream())
|
|
139
|
-
.pipeThrough(new SplitStringStream(
|
|
145
|
+
.pipeThrough(new SplitStringStream("\n"))
|
|
140
146
|
.pipeTo(new WritableStream({
|
|
141
147
|
write(chunk) {
|
|
142
148
|
let match = chunk.match(Logcat.LOG_SIZE_REGEX_11);
|
|
@@ -166,9 +172,9 @@ export class Logcat extends AdbCommandBase {
|
|
|
166
172
|
}
|
|
167
173
|
async clear(ids) {
|
|
168
174
|
await this.adb.subprocess.spawnAndWait([
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
...(ids ? [
|
|
175
|
+
"logcat",
|
|
176
|
+
"-c",
|
|
177
|
+
...(ids ? ["-b", Logcat.joinLogId(ids)] : []),
|
|
172
178
|
]);
|
|
173
179
|
}
|
|
174
180
|
binary(options) {
|
|
@@ -176,16 +182,18 @@ export class Logcat extends AdbCommandBase {
|
|
|
176
182
|
// TODO: make `spawn` return synchronously with streams pending
|
|
177
183
|
// so it's easier to chain them.
|
|
178
184
|
const { stdout } = await this.adb.subprocess.spawn([
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
...(options?.pid ? [
|
|
182
|
-
...(options?.ids
|
|
185
|
+
"logcat",
|
|
186
|
+
"-B",
|
|
187
|
+
...(options?.pid ? ["--pid", options.pid.toString()] : []),
|
|
188
|
+
...(options?.ids
|
|
189
|
+
? ["-b", Logcat.joinLogId(options.ids)]
|
|
190
|
+
: []),
|
|
183
191
|
], {
|
|
184
192
|
// PERF: None protocol is 150% faster then Shell protocol
|
|
185
193
|
protocols: [AdbSubprocessNoneProtocol],
|
|
186
194
|
});
|
|
187
195
|
return stdout;
|
|
188
|
-
}).pipeThrough(new BufferedTransformStream(stream => {
|
|
196
|
+
}).pipeThrough(new BufferedTransformStream((stream) => {
|
|
189
197
|
return deserializeAndroidLogEntry(stream);
|
|
190
198
|
}));
|
|
191
199
|
}
|
package/esm/logcat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logcat.js","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"logcat.js","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EACH,uBAAuB,EACvB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GAEjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,MAAM,EAAE,EACX,UAAU,GAEb,MAAM,mBAAmB,CAAC;AAE3B,iDAAiD;AACjD,8DAA8D;AAE9D,+JAA+J;AAC/J,MAAM,CAAN,IAAY,KAUX;AAVD,WAAY,KAAK;IACb,gCAAQ,CAAA;IACR,iCAAI,CAAA;IACJ,mCAAK,CAAA;IACL,qCAAM,CAAA;IACN,qCAAM,CAAA;IACN,mCAAK,CAAA;IACL,mCAAK,CAAA;IACL,yCAAQ,CAAA;IACR,qCAAM,CAAA;AACV,CAAC,EAVW,KAAK,GAAL,KAAK,KAAL,KAAK,QAUhB;AAED,8JAA8J;AAC9J,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC1B,iEAAO,CAAA;IACP,iEAAO,CAAA;IACP,iEAAO,CAAA;IACP,6DAAK,CAAA;IACL,2DAAI,CAAA;IACJ,2DAAI,CAAA;IACJ,6DAAK,CAAA;IACL,6DAAK,CAAA;IACL,+DAAM,C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QAClB,CAAC,CAAC,CAAC,WAAW,CACV,IAAI,uBAAuB,CAAC,CAAC,MAAM,EAAE,EAAE;YACnC,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC,CAAC,CACL,CAAC;IACN,CAAC"}
|
package/esm/settings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdbCommandBase } from "@yume-chan/adb";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SettingsNamespace = 'system' | 'secure' | 'global';
|
|
3
|
+
export type SettingsResetMode = 'untrusted_defaults' | 'untrusted_clear' | 'trusted_defaults';
|
|
4
4
|
export declare class Settings extends AdbCommandBase {
|
|
5
5
|
base(command: string, namespace: SettingsNamespace, ...args: string[]): Promise<string>;
|
|
6
6
|
get(namespace: SettingsNamespace, key: string): Promise<string>;
|
package/esm/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAG9F,qBAAa,QAAS,SAAQ,cAAc;IAGjC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE;IAIrE,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM;IAI7C,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM;IAIhD,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO;IAWjG,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7E,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUjF,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAIrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/android-bin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Wrappers for Android built-in executables.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -25,17 +25,20 @@
|
|
|
25
25
|
"main": "esm/index.js",
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"@yume-chan/
|
|
28
|
+
"@yume-chan/eslint-config": "^1.0.0",
|
|
29
|
+
"@yume-chan/tsconfig": "^1.0.0",
|
|
30
|
+
"eslint": "^8.31.0",
|
|
31
|
+
"typescript": "^4.9.4"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@yume-chan/adb": "^0.0.
|
|
33
|
-
"@yume-chan/stream-extra": "^0.0.
|
|
34
|
-
"@yume-chan/struct": "^0.0.
|
|
35
|
-
"tslib": "^2.4.
|
|
34
|
+
"@yume-chan/adb": "^0.0.18",
|
|
35
|
+
"@yume-chan/stream-extra": "^0.0.18",
|
|
36
|
+
"@yume-chan/struct": "^0.0.18",
|
|
37
|
+
"tslib": "^2.4.1"
|
|
36
38
|
},
|
|
37
39
|
"scripts": {
|
|
38
|
-
"build": "build
|
|
39
|
-
"build:watch": "
|
|
40
|
+
"build": "tsc -b tsconfig.build.json",
|
|
41
|
+
"build:watch": "tsc -b tsconfig.build.json",
|
|
42
|
+
"lint": "eslint src/**/*.ts --fix"
|
|
40
43
|
}
|
|
41
44
|
}
|
package/src/bu.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { AdbCommandBase } from "@yume-chan/adb";
|
|
5
5
|
|
|
6
6
|
export interface AdbBackupOptions {
|
|
7
|
-
apps: string[] |
|
|
7
|
+
apps: string[] | "all" | "all-including-system";
|
|
8
8
|
apks: boolean;
|
|
9
9
|
obbs: boolean;
|
|
10
10
|
shared: boolean;
|
|
@@ -14,9 +14,13 @@ export interface AdbBackupOptions {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export class AdbBackup extends AdbCommandBase {
|
|
17
|
-
|
|
17
|
+
backup(options: AdbBackupOptions): Promise<void> {
|
|
18
|
+
void options;
|
|
19
|
+
throw new Error("Not implemented");
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
restore(options: AdbBackupOptions): Promise<void> {
|
|
23
|
+
void options;
|
|
24
|
+
throw new Error("Not implemented");
|
|
21
25
|
}
|
|
22
26
|
}
|
package/src/bug-report.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
// cspell: ignore bugreport
|
|
2
2
|
// cspell: ignore bugreportz
|
|
3
3
|
|
|
4
|
-
import { AdbCommandBase, AdbSubprocessShellProtocol } from
|
|
5
|
-
import {
|
|
4
|
+
import { AdbCommandBase, AdbSubprocessShellProtocol } from "@yume-chan/adb";
|
|
5
|
+
import {
|
|
6
|
+
DecodeUtf8Stream,
|
|
7
|
+
PushReadableStream,
|
|
8
|
+
SplitStringStream,
|
|
9
|
+
WrapReadableStream,
|
|
10
|
+
WritableStream,
|
|
11
|
+
type ReadableStream,
|
|
12
|
+
} from "@yume-chan/stream-extra";
|
|
6
13
|
|
|
7
14
|
export interface BugReportZVersion {
|
|
8
15
|
major: number;
|
|
@@ -34,8 +41,11 @@ export class BugReportZ extends AdbCommandBase {
|
|
|
34
41
|
return undefined;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait([
|
|
38
|
-
|
|
44
|
+
const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait([
|
|
45
|
+
"bugreportz",
|
|
46
|
+
"-v",
|
|
47
|
+
]);
|
|
48
|
+
if (exitCode !== 0 || stderr === "") {
|
|
39
49
|
return undefined;
|
|
40
50
|
}
|
|
41
51
|
|
|
@@ -68,10 +78,12 @@ export class BugReportZ extends AdbCommandBase {
|
|
|
68
78
|
* @param onProgress Progress callback. Only specify this if `supportsProgress` is `true`.
|
|
69
79
|
* @returns The path of the bugreport file.
|
|
70
80
|
*/
|
|
71
|
-
public async generate(
|
|
81
|
+
public async generate(
|
|
82
|
+
onProgress?: (progress: string, total: string) => void
|
|
83
|
+
): Promise<string> {
|
|
72
84
|
const process = await this.adb.subprocess.spawn([
|
|
73
|
-
|
|
74
|
-
...(onProgress ? [
|
|
85
|
+
"bugreportz",
|
|
86
|
+
...(onProgress ? ["-p"] : []),
|
|
75
87
|
]);
|
|
76
88
|
|
|
77
89
|
let filename: string | undefined;
|
|
@@ -79,40 +91,42 @@ export class BugReportZ extends AdbCommandBase {
|
|
|
79
91
|
|
|
80
92
|
await process.stdout
|
|
81
93
|
.pipeThrough(new DecodeUtf8Stream())
|
|
82
|
-
.pipeThrough(new SplitStringStream(
|
|
83
|
-
.pipeTo(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
94
|
+
.pipeThrough(new SplitStringStream("\n"))
|
|
95
|
+
.pipeTo(
|
|
96
|
+
new WritableStream<string>({
|
|
97
|
+
write(line) {
|
|
98
|
+
// `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
|
|
99
|
+
let match = line.match(BugReportZ.PROGRESS_REGEX);
|
|
100
|
+
if (match) {
|
|
101
|
+
onProgress?.(match[1]!, match[2]!);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
match = line.match(BugReportZ.BEGIN_REGEX);
|
|
105
|
+
if (match) {
|
|
106
|
+
filename = match[1]!;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
match = line.match(BugReportZ.OK_REGEX);
|
|
110
|
+
if (match) {
|
|
111
|
+
filename = match[1];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
match = line.match(BugReportZ.FAIL_REGEX);
|
|
115
|
+
if (match) {
|
|
116
|
+
// Don't report error now
|
|
117
|
+
// We want to gather all output.
|
|
118
|
+
error = match[1];
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
);
|
|
109
123
|
|
|
110
124
|
if (error) {
|
|
111
125
|
throw new Error(error);
|
|
112
126
|
}
|
|
113
127
|
|
|
114
128
|
if (!filename) {
|
|
115
|
-
throw new Error(
|
|
129
|
+
throw new Error("bugreportz did not return file name");
|
|
116
130
|
}
|
|
117
131
|
|
|
118
132
|
// Design choice: we don't automatically pull the file to avoid more dependency on `@yume-chan/adb`
|
|
@@ -125,22 +139,34 @@ export class BugReportZ extends AdbCommandBase {
|
|
|
125
139
|
|
|
126
140
|
public stream(): ReadableStream<Uint8Array> {
|
|
127
141
|
return new PushReadableStream(async (controller) => {
|
|
128
|
-
const process = await this.adb.subprocess.spawn([
|
|
142
|
+
const process = await this.adb.subprocess.spawn([
|
|
143
|
+
"bugreportz",
|
|
144
|
+
"-s",
|
|
145
|
+
]);
|
|
129
146
|
process.stdout
|
|
130
|
-
.pipeTo(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
147
|
+
.pipeTo(
|
|
148
|
+
new WritableStream({
|
|
149
|
+
async write(chunk) {
|
|
150
|
+
await controller.enqueue(chunk);
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
)
|
|
154
|
+
.catch((e) => {
|
|
155
|
+
void e;
|
|
156
|
+
});
|
|
135
157
|
process.stderr
|
|
136
158
|
.pipeThrough(new DecodeUtf8Stream())
|
|
137
|
-
.pipeTo(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
.pipeTo(
|
|
160
|
+
new WritableStream({
|
|
161
|
+
write(chunk) {
|
|
162
|
+
controller.error(new Error(chunk));
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
)
|
|
166
|
+
.catch((e) => {
|
|
167
|
+
void e;
|
|
168
|
+
});
|
|
142
169
|
await process.exit;
|
|
143
|
-
controller.close();
|
|
144
170
|
});
|
|
145
171
|
}
|
|
146
172
|
}
|
|
@@ -149,7 +175,7 @@ export class BugReportZ extends AdbCommandBase {
|
|
|
149
175
|
export class BugReport extends AdbCommandBase {
|
|
150
176
|
public generate(): ReadableStream<Uint8Array> {
|
|
151
177
|
return new WrapReadableStream(async () => {
|
|
152
|
-
const process = await this.adb.subprocess.spawn([
|
|
178
|
+
const process = await this.adb.subprocess.spawn(["bugreport"]);
|
|
153
179
|
return process.stdout;
|
|
154
180
|
});
|
|
155
181
|
}
|