@@ -96,22 +205,22 @@ export class BugReportZ extends AdbCommandBase {
newWritableStream<string>({
write(line){
// `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
letmatch=line.match(BugReportZ.PROGRESS_REGEX);
letmatch=line.match(BugReport.PROGRESS_REGEX);
if (match){
onProgress?.(match[1]!,match[2]!);
}
match=line.match(BugReportZ.BEGIN_REGEX);
match=line.match(BugReport.BEGIN_REGEX);
if (match){
filename=match[1]!;
}
match=line.match(BugReportZ.OK_REGEX);
match=line.match(BugReport.OK_REGEX);
if (match){
filename=match[1];
}
match=line.match(BugReportZ.FAIL_REGEX);
match=line.match(BugReport.FAIL_REGEX);
if (match){
// Don't report error now
// We want to gather all output.
@@ -133,16 +242,17 @@ export class BugReportZ extends AdbCommandBase {
returnfilename;
}
supportStream(major:number,minor:number):boolean{
returnmajor>1||minor>=2;
}
stream():ReadableStream<Uint8Array>{
/**
* Creates a zipped bugreport file, or throws an error if `supportsBugReportZStream` is `false`.
*
* @returns The content of the generated bugreport file.
*/
bugReportZStream():ReadableStream<Uint8Array>{
returnnewPushReadableStream(async (controller)=>{
constprocess=awaitthis.adb.subprocess.spawn([
"bugreportz",
"-s",
]);
constprocess=awaitthis.adb.subprocess.spawn(
["bugreportz","-s"],
{protocols:[AdbSubprocessShellProtocol]},
);
process.stdout
.pipeTo(
newWritableStream({
@@ -169,14 +279,54 @@ export class BugReportZ extends AdbCommandBase {
awaitprocess.exit;
});
}
/**
* Automatically choose the best bugreport method.
*
* * If `supportsBugReportZStream` is `true`, this method will return a stream of zipped bugreport.
* * If `supportsBugReportZ` is `true`, this method will return a stream of zipped bugreport, and will delete the file on device after the stream is closed.
* * If `supportsBugReport` is `true`, this method will return a stream of flat bugreport.
*
* @param onProgress
* If `supportsBugReportZStream` is `false` and `supportsBugReportZProgress` is `true`,
* this callback will be called when progress is updated.