@yume-chan/android-bin 0.0.15 → 0.0.16
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/.rush/temp/package-deps_build.json +5 -5
- package/.rush/temp/package-deps_build_watch.json +5 -5
- package/.rush/temp/shrinkwrap-deps.json +1 -1
- package/CHANGELOG.json +15 -0
- package/CHANGELOG.md +9 -1
- package/README.md +5 -5
- package/esm/logcat.d.ts.map +1 -1
- package/esm/logcat.js +11 -4
- package/esm/logcat.js.map +1 -1
- package/package.json +5 -5
- package/src/bu.ts +22 -22
- package/src/bug-report.ts +155 -155
- package/src/demo-mode.ts +179 -179
- package/src/index.ts +6 -6
- package/src/logcat.ts +11 -4
- package/src/settings.ts +49 -49
- package/tsconfig.json +8 -8
- package/.rush/temp/package-deps_build +0 -0
- package/.rush/temp/package-deps_postinstall.json +0 -13
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"libraries/android-bin/.rush/temp/shrinkwrap-deps.json": "
|
|
4
|
-
"libraries/android-bin/CHANGELOG.json": "
|
|
5
|
-
"libraries/android-bin/CHANGELOG.md": "
|
|
3
|
+
"libraries/android-bin/.rush/temp/shrinkwrap-deps.json": "7a8b693a797f929a5184cf7a08cda9ced8e4a529",
|
|
4
|
+
"libraries/android-bin/CHANGELOG.json": "7841c67fb164723bb7794b00dc8c16bd89b6b637",
|
|
5
|
+
"libraries/android-bin/CHANGELOG.md": "d482e630baa62381336b5f33434f34f642a2fa54",
|
|
6
6
|
"libraries/android-bin/README.md": "96d1e739d73df6dc17920182c1c5799b65652b69",
|
|
7
|
-
"libraries/android-bin/package.json": "
|
|
7
|
+
"libraries/android-bin/package.json": "fd78491208045108132158872c1af1075c286dae",
|
|
8
8
|
"libraries/android-bin/src/bu.ts": "cd4d6867127ea824c524989626268b26dde3c7de",
|
|
9
9
|
"libraries/android-bin/src/bug-report.ts": "b4d7c78eaa2abb610a88f240872d209d083b70c9",
|
|
10
10
|
"libraries/android-bin/src/demo-mode.ts": "1ee4a2d1bc238a1600387fc39549241a2a6bb161",
|
|
11
11
|
"libraries/android-bin/src/index.ts": "829476e842a0c136d900c623e14a6f341dba5651",
|
|
12
|
-
"libraries/android-bin/src/logcat.ts": "
|
|
12
|
+
"libraries/android-bin/src/logcat.ts": "8144312c653710ecabe10186f9eb2afa0aeaf2db",
|
|
13
13
|
"libraries/android-bin/src/settings.ts": "a323081296746d78ea07f473680321331ff0d46c",
|
|
14
14
|
"libraries/android-bin/tsconfig.json": "39805c3201f468dc5a1a584b592970777c655bca"
|
|
15
15
|
},
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"libraries/android-bin/.rush/temp/shrinkwrap-deps.json": "
|
|
4
|
-
"libraries/android-bin/CHANGELOG.json": "
|
|
5
|
-
"libraries/android-bin/CHANGELOG.md": "
|
|
3
|
+
"libraries/android-bin/.rush/temp/shrinkwrap-deps.json": "7a8b693a797f929a5184cf7a08cda9ced8e4a529",
|
|
4
|
+
"libraries/android-bin/CHANGELOG.json": "7841c67fb164723bb7794b00dc8c16bd89b6b637",
|
|
5
|
+
"libraries/android-bin/CHANGELOG.md": "d482e630baa62381336b5f33434f34f642a2fa54",
|
|
6
6
|
"libraries/android-bin/README.md": "96d1e739d73df6dc17920182c1c5799b65652b69",
|
|
7
|
-
"libraries/android-bin/package.json": "
|
|
7
|
+
"libraries/android-bin/package.json": "fd78491208045108132158872c1af1075c286dae",
|
|
8
8
|
"libraries/android-bin/src/bu.ts": "cd4d6867127ea824c524989626268b26dde3c7de",
|
|
9
9
|
"libraries/android-bin/src/bug-report.ts": "b4d7c78eaa2abb610a88f240872d209d083b70c9",
|
|
10
10
|
"libraries/android-bin/src/demo-mode.ts": "1ee4a2d1bc238a1600387fc39549241a2a6bb161",
|
|
11
11
|
"libraries/android-bin/src/index.ts": "829476e842a0c136d900c623e14a6f341dba5651",
|
|
12
|
-
"libraries/android-bin/src/logcat.ts": "
|
|
12
|
+
"libraries/android-bin/src/logcat.ts": "8144312c653710ecabe10186f9eb2afa0aeaf2db",
|
|
13
13
|
"libraries/android-bin/src/settings.ts": "a323081296746d78ea07f473680321331ff0d46c",
|
|
14
14
|
"libraries/android-bin/tsconfig.json": "39805c3201f468dc5a1a584b592970777c655bca"
|
|
15
15
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"tslib@2.4.0": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
|
|
3
|
-
"typescript@4.7.
|
|
3
|
+
"typescript@4.7.2": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A=="
|
|
4
4
|
}
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/android-bin",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.16",
|
|
6
|
+
"tag": "@yume-chan/android-bin_v0.0.16",
|
|
7
|
+
"date": "Sat, 28 May 2022 03:56:37 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Upgrade TypeScript to 4.7.2 to enable Node.js ESM"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Improve performance of `Logcat#binary()` by up to 150%"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
4
19
|
{
|
|
5
20
|
"version": "0.0.15",
|
|
6
21
|
"tag": "@yume-chan/android-bin_v0.0.15",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Change Log - @yume-chan/android-bin
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Sat, 28 May 2022 03:56:37 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.16
|
|
6
|
+
Sat, 28 May 2022 03:56:37 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Upgrade TypeScript to 4.7.2 to enable Node.js ESM
|
|
11
|
+
- Improve performance of `Logcat#binary()` by up to 150%
|
|
4
12
|
|
|
5
13
|
## 0.0.15
|
|
6
14
|
Mon, 02 May 2022 04:18:01 GMT
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# `@yume-chan/android-bin`
|
|
2
|
-
|
|
3
|
-
Wrappers for Android built-in executables.
|
|
4
|
-
|
|
5
|
-
Currently it's bound to `@yume-chan/adb`, maybe one day it can be used with other executors.
|
|
1
|
+
# `@yume-chan/android-bin`
|
|
2
|
+
|
|
3
|
+
Wrappers for Android built-in executables.
|
|
4
|
+
|
|
5
|
+
Currently it's bound to `@yume-chan/adb`, maybe one day it can be used with other executors.
|
package/esm/logcat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logcat.d.ts","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"logcat.d.ts","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAyF,cAAc,EAAmC,MAAM,gBAAgB,CAAC;AACxL,OAAO,MAAM,EAAE,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAMzE,oBAAY,KAAK;IACb,GAAG,KAAK;IACR,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,KAAK,IAAA;IACL,QAAQ,IAAA;IACR,MAAM,IAAA;CACT;AAED,oBAAY,WAAW;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QzB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,cAAc,CAAC,UAAU,CAAC;CAiCrE"}
|
package/esm/logcat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// cspell: ignore logcat
|
|
2
|
-
import { AdbCommandBase, BufferedStream, BufferedStreamEndedError, DecodeUtf8Stream, ReadableStream, SplitLineStream, WritableStream } from "@yume-chan/adb";
|
|
2
|
+
import { AdbCommandBase, AdbSubprocessNoneProtocol, BufferedStream, BufferedStreamEndedError, DecodeUtf8Stream, ReadableStream, SplitLineStream, WritableStream } from "@yume-chan/adb";
|
|
3
3
|
import Struct from "@yume-chan/struct";
|
|
4
4
|
// `adb logcat` is an alias to `adb shell logcat`
|
|
5
5
|
// so instead of adding to core library, it's implemented here
|
|
@@ -45,10 +45,14 @@ export const LoggerEntry = new Struct({ littleEndian: true })
|
|
|
45
45
|
});
|
|
46
46
|
export async function deserializeLogMessage(stream) {
|
|
47
47
|
const entry = await LoggerEntry.deserialize(stream);
|
|
48
|
-
|
|
48
|
+
if (entry.headerSize !== LoggerEntry.size) {
|
|
49
|
+
await stream.read(entry.headerSize - LoggerEntry.size);
|
|
50
|
+
}
|
|
49
51
|
const priority = (await stream.read(1))[0];
|
|
50
52
|
const payload = await stream.read(entry.payloadSize - 1);
|
|
51
|
-
|
|
53
|
+
entry.priority = priority;
|
|
54
|
+
entry.payload = payload;
|
|
55
|
+
return entry;
|
|
52
56
|
}
|
|
53
57
|
export class Logcat extends AdbCommandBase {
|
|
54
58
|
static logIdToName(id) {
|
|
@@ -124,7 +128,10 @@ export class Logcat extends AdbCommandBase {
|
|
|
124
128
|
'-B',
|
|
125
129
|
...(options?.pid ? ['--pid', options.pid.toString()] : []),
|
|
126
130
|
...(options?.ids ? ['-b', Logcat.joinLogId(options.ids)] : [])
|
|
127
|
-
]
|
|
131
|
+
], {
|
|
132
|
+
// PERF: None protocol is 150% faster then Shell protocol
|
|
133
|
+
protocols: [AdbSubprocessNoneProtocol],
|
|
134
|
+
});
|
|
128
135
|
bufferedStream = new BufferedStream(stdout);
|
|
129
136
|
},
|
|
130
137
|
async pull(controller) {
|
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,cAAc,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"logcat.js","sourceRoot":"","sources":["../src/logcat.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxL,OAAO,MAAwC,MAAM,mBAAmB,CAAC;AAEzE,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,KAAL,KAAK,QAUhB;AAED,MAAM,CAAN,IAAY,WASX;AATD,WAAY,WAAW;IACnB,mDAAO,CAAA;IACP,mDAAO,CAAA;IACP,mDAAO,CAAA;IACP,6CAAI,CAAA;IACJ,6CAAI,CAAA;IACJ,+CAAK,CAAA;IACL,+CAAK,CAAA;IACL,iDAAM,CAAA;AACV,CAAC,EATW,WAAW,KAAX,WAAW,QAStB;AAOD,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AAE3C,+JAA+J;A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,CAAC;iBACjE,EAAE;oBACC,yDAAyD;oBACzD,SAAS,EAAE,CAAC,yBAAyB,CAAC;iBACzC,CAAC,CAAC;gBACH,cAAc,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;YAChD,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,UAAU;gBACjB,IAAI;oBACA,MAAM,KAAK,GAAG,MAAM,qBAAqB,CAAC,cAAc,CAAC,CAAC;oBAC1D,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC7B;gBAAC,OAAO,CAAC,EAAE;oBACR,IAAI,CAAC,YAAY,wBAAwB,EAAE;wBACvC,UAAU,CAAC,KAAK,EAAE,CAAC;wBACnB,OAAO;qBACV;oBAED,MAAM,CAAC,CAAC;iBACX;YACL,CAAC;YACD,MAAM;gBACF,cAAc,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;SACJ,CAAC,CAAC;IACP,CAAC"}
|
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.16",
|
|
4
4
|
"description": "Wrappers for Android built-in executables.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"main": "esm/index.js",
|
|
26
26
|
"types": "esm/index.d.ts",
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"typescript": "4.7.
|
|
28
|
+
"typescript": "4.7.2",
|
|
29
29
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@yume-chan/adb": "^0.0.
|
|
33
|
-
"@yume-chan/struct": "^0.0.
|
|
32
|
+
"@yume-chan/adb": "^0.0.16",
|
|
33
|
+
"@yume-chan/struct": "^0.0.16",
|
|
34
34
|
"tslib": "^2.3.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "build-ts-package",
|
|
38
38
|
"build:watch": "build-ts-package --incremental"
|
|
39
39
|
},
|
|
40
|
-
"readme": "# `@yume-chan/android-bin`\
|
|
40
|
+
"readme": "# `@yume-chan/android-bin`\n\nWrappers for Android built-in executables.\n\nCurrently it's bound to `@yume-chan/adb`, maybe one day it can be used with other executors.\n"
|
|
41
41
|
}
|
package/src/bu.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// cspell: ignore apks
|
|
2
|
-
// cspell: ignore obbs
|
|
3
|
-
|
|
4
|
-
import { AdbCommandBase } from "@yume-chan/adb";
|
|
5
|
-
|
|
6
|
-
export interface AdbBackupOptions {
|
|
7
|
-
apps: string[] | 'all' | 'all-including-system';
|
|
8
|
-
apks: boolean;
|
|
9
|
-
obbs: boolean;
|
|
10
|
-
shared: boolean;
|
|
11
|
-
widgets: boolean;
|
|
12
|
-
compress: boolean;
|
|
13
|
-
user: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class AdbBackup extends AdbCommandBase {
|
|
17
|
-
async backup(options: AdbBackupOptions): Promise<void> {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async restore(options: AdbBackupOptions): Promise<void> {
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
// cspell: ignore apks
|
|
2
|
+
// cspell: ignore obbs
|
|
3
|
+
|
|
4
|
+
import { AdbCommandBase } from "@yume-chan/adb";
|
|
5
|
+
|
|
6
|
+
export interface AdbBackupOptions {
|
|
7
|
+
apps: string[] | 'all' | 'all-including-system';
|
|
8
|
+
apks: boolean;
|
|
9
|
+
obbs: boolean;
|
|
10
|
+
shared: boolean;
|
|
11
|
+
widgets: boolean;
|
|
12
|
+
compress: boolean;
|
|
13
|
+
user: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class AdbBackup extends AdbCommandBase {
|
|
17
|
+
async backup(options: AdbBackupOptions): Promise<void> {
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async restore(options: AdbBackupOptions): Promise<void> {
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/bug-report.ts
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
// cspell: ignore bugreport
|
|
2
|
-
// cspell: ignore bugreportz
|
|
3
|
-
|
|
4
|
-
import { AdbCommandBase, AdbSubprocessShellProtocol, DecodeUtf8Stream, PushReadableStream, ReadableStream, SplitLineStream, WrapReadableStream, WritableStream } from "@yume-chan/adb";
|
|
5
|
-
|
|
6
|
-
export interface BugReportZVersion {
|
|
7
|
-
major: number;
|
|
8
|
-
minor: number;
|
|
9
|
-
|
|
10
|
-
supportProgress: boolean;
|
|
11
|
-
supportStream: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class BugReportZ extends AdbCommandBase {
|
|
15
|
-
public static VERSION_REGEX = /(\d+)\.(\d+)/;
|
|
16
|
-
|
|
17
|
-
public static BEGIN_REGEX = /BEGIN:(.*)/;
|
|
18
|
-
|
|
19
|
-
public static PROGRESS_REGEX = /PROGRESS:(.*)\/(.*)/;
|
|
20
|
-
|
|
21
|
-
public static OK_REGEX = /OK:(.*)/;
|
|
22
|
-
|
|
23
|
-
public static FAIL_REGEX = /FAIL:(.*)/;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Retrieve the version of bugreportz.
|
|
27
|
-
*
|
|
28
|
-
* @returns a `BugReportVersion` object, or `undefined` if `bugreportz` is not available.
|
|
29
|
-
*/
|
|
30
|
-
public async version(): Promise<BugReportZVersion | undefined> {
|
|
31
|
-
// bugreportz requires shell protocol
|
|
32
|
-
if (!AdbSubprocessShellProtocol.isSupported(this.adb)) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait(['bugreportz', '-v']);
|
|
37
|
-
if (exitCode !== 0 || stderr === '') {
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const match = stderr.match(BugReportZ.VERSION_REGEX);
|
|
42
|
-
if (!match) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const major = parseInt(match[1]!, 10);
|
|
47
|
-
const minor = parseInt(match[2]!, 10);
|
|
48
|
-
return {
|
|
49
|
-
major,
|
|
50
|
-
minor,
|
|
51
|
-
|
|
52
|
-
supportProgress: this.supportProgress(major, minor),
|
|
53
|
-
supportStream: this.supportStream(major, minor),
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public supportProgress(major: number, minor: number): boolean {
|
|
58
|
-
return major > 1 || minor >= 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Create a zipped bugreport file.
|
|
63
|
-
*
|
|
64
|
-
* Compare to `stream`, this method will write the output to a file on device.
|
|
65
|
-
* You can pull it later using sync protocol.
|
|
66
|
-
*
|
|
67
|
-
* @param onProgress Progress callback. Only specify this if `supportsProgress` is `true`.
|
|
68
|
-
* @returns The path of the bugreport file.
|
|
69
|
-
*/
|
|
70
|
-
public async generate(onProgress?: (progress: string, total: string) => void): Promise<string> {
|
|
71
|
-
const process = await this.adb.subprocess.spawn([
|
|
72
|
-
'bugreportz',
|
|
73
|
-
...(onProgress ? ['-p'] : []),
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
let filename: string | undefined;
|
|
77
|
-
let error: string | undefined;
|
|
78
|
-
|
|
79
|
-
await process.stdout
|
|
80
|
-
.pipeThrough(new DecodeUtf8Stream())
|
|
81
|
-
.pipeThrough(new SplitLineStream())
|
|
82
|
-
.pipeTo(new WritableStream<string>({
|
|
83
|
-
write(line) {
|
|
84
|
-
// `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
|
|
85
|
-
let match = line.match(BugReportZ.PROGRESS_REGEX);
|
|
86
|
-
if (match) {
|
|
87
|
-
onProgress?.(match[1]!, match[2]!);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
match = line.match(BugReportZ.BEGIN_REGEX);
|
|
91
|
-
if (match) {
|
|
92
|
-
filename = match[1]!;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
match = line.match(BugReportZ.OK_REGEX);
|
|
96
|
-
if (match) {
|
|
97
|
-
filename = match[1];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
match = line.match(BugReportZ.FAIL_REGEX);
|
|
101
|
-
if (match) {
|
|
102
|
-
// Don't report error now
|
|
103
|
-
// We want to gather all output.
|
|
104
|
-
error = match[1];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}));
|
|
108
|
-
|
|
109
|
-
if (error) {
|
|
110
|
-
throw new Error(error);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!filename) {
|
|
114
|
-
throw new Error('bugreportz did not return file name');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Design choice: we don't automatically pull the file to avoid more dependency on `@yume-chan/adb`
|
|
118
|
-
return filename;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
public supportStream(major: number, minor: number): boolean {
|
|
122
|
-
return major > 1 || minor >= 2;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public stream(): ReadableStream<Uint8Array> {
|
|
126
|
-
return new PushReadableStream(async (controller) => {
|
|
127
|
-
const process = await this.adb.subprocess.spawn(['bugreportz', '-s']);
|
|
128
|
-
process.stdout
|
|
129
|
-
.pipeTo(new WritableStream({
|
|
130
|
-
async write(chunk) {
|
|
131
|
-
await controller.enqueue(chunk);
|
|
132
|
-
},
|
|
133
|
-
}));
|
|
134
|
-
process.stderr
|
|
135
|
-
.pipeThrough(new DecodeUtf8Stream())
|
|
136
|
-
.pipeTo(new WritableStream({
|
|
137
|
-
async write(chunk) {
|
|
138
|
-
controller.error(new Error(chunk));
|
|
139
|
-
}
|
|
140
|
-
}));
|
|
141
|
-
await process.exit;
|
|
142
|
-
controller.close();
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/native/cmds/bugreport/bugreport.cpp;drc=9b73bf07d73dbab5b792632e1e233edbad77f5fd;bpv=0;bpt=0
|
|
148
|
-
export class BugReport extends AdbCommandBase {
|
|
149
|
-
public generate(): ReadableStream<Uint8Array> {
|
|
150
|
-
return new WrapReadableStream(async () => {
|
|
151
|
-
const process = await this.adb.subprocess.spawn(['bugreport']);
|
|
152
|
-
return process.stdout;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
1
|
+
// cspell: ignore bugreport
|
|
2
|
+
// cspell: ignore bugreportz
|
|
3
|
+
|
|
4
|
+
import { AdbCommandBase, AdbSubprocessShellProtocol, DecodeUtf8Stream, PushReadableStream, ReadableStream, SplitLineStream, WrapReadableStream, WritableStream } from "@yume-chan/adb";
|
|
5
|
+
|
|
6
|
+
export interface BugReportZVersion {
|
|
7
|
+
major: number;
|
|
8
|
+
minor: number;
|
|
9
|
+
|
|
10
|
+
supportProgress: boolean;
|
|
11
|
+
supportStream: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class BugReportZ extends AdbCommandBase {
|
|
15
|
+
public static VERSION_REGEX = /(\d+)\.(\d+)/;
|
|
16
|
+
|
|
17
|
+
public static BEGIN_REGEX = /BEGIN:(.*)/;
|
|
18
|
+
|
|
19
|
+
public static PROGRESS_REGEX = /PROGRESS:(.*)\/(.*)/;
|
|
20
|
+
|
|
21
|
+
public static OK_REGEX = /OK:(.*)/;
|
|
22
|
+
|
|
23
|
+
public static FAIL_REGEX = /FAIL:(.*)/;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve the version of bugreportz.
|
|
27
|
+
*
|
|
28
|
+
* @returns a `BugReportVersion` object, or `undefined` if `bugreportz` is not available.
|
|
29
|
+
*/
|
|
30
|
+
public async version(): Promise<BugReportZVersion | undefined> {
|
|
31
|
+
// bugreportz requires shell protocol
|
|
32
|
+
if (!AdbSubprocessShellProtocol.isSupported(this.adb)) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { stderr, exitCode } = await this.adb.subprocess.spawnAndWait(['bugreportz', '-v']);
|
|
37
|
+
if (exitCode !== 0 || stderr === '') {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const match = stderr.match(BugReportZ.VERSION_REGEX);
|
|
42
|
+
if (!match) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const major = parseInt(match[1]!, 10);
|
|
47
|
+
const minor = parseInt(match[2]!, 10);
|
|
48
|
+
return {
|
|
49
|
+
major,
|
|
50
|
+
minor,
|
|
51
|
+
|
|
52
|
+
supportProgress: this.supportProgress(major, minor),
|
|
53
|
+
supportStream: this.supportStream(major, minor),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public supportProgress(major: number, minor: number): boolean {
|
|
58
|
+
return major > 1 || minor >= 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create a zipped bugreport file.
|
|
63
|
+
*
|
|
64
|
+
* Compare to `stream`, this method will write the output to a file on device.
|
|
65
|
+
* You can pull it later using sync protocol.
|
|
66
|
+
*
|
|
67
|
+
* @param onProgress Progress callback. Only specify this if `supportsProgress` is `true`.
|
|
68
|
+
* @returns The path of the bugreport file.
|
|
69
|
+
*/
|
|
70
|
+
public async generate(onProgress?: (progress: string, total: string) => void): Promise<string> {
|
|
71
|
+
const process = await this.adb.subprocess.spawn([
|
|
72
|
+
'bugreportz',
|
|
73
|
+
...(onProgress ? ['-p'] : []),
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
let filename: string | undefined;
|
|
77
|
+
let error: string | undefined;
|
|
78
|
+
|
|
79
|
+
await process.stdout
|
|
80
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
81
|
+
.pipeThrough(new SplitLineStream())
|
|
82
|
+
.pipeTo(new WritableStream<string>({
|
|
83
|
+
write(line) {
|
|
84
|
+
// `BEGIN:` and `PROGRESS:` only appear when `-p` is specified.
|
|
85
|
+
let match = line.match(BugReportZ.PROGRESS_REGEX);
|
|
86
|
+
if (match) {
|
|
87
|
+
onProgress?.(match[1]!, match[2]!);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
match = line.match(BugReportZ.BEGIN_REGEX);
|
|
91
|
+
if (match) {
|
|
92
|
+
filename = match[1]!;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
match = line.match(BugReportZ.OK_REGEX);
|
|
96
|
+
if (match) {
|
|
97
|
+
filename = match[1];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
match = line.match(BugReportZ.FAIL_REGEX);
|
|
101
|
+
if (match) {
|
|
102
|
+
// Don't report error now
|
|
103
|
+
// We want to gather all output.
|
|
104
|
+
error = match[1];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
|
|
109
|
+
if (error) {
|
|
110
|
+
throw new Error(error);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!filename) {
|
|
114
|
+
throw new Error('bugreportz did not return file name');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Design choice: we don't automatically pull the file to avoid more dependency on `@yume-chan/adb`
|
|
118
|
+
return filename;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public supportStream(major: number, minor: number): boolean {
|
|
122
|
+
return major > 1 || minor >= 2;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public stream(): ReadableStream<Uint8Array> {
|
|
126
|
+
return new PushReadableStream(async (controller) => {
|
|
127
|
+
const process = await this.adb.subprocess.spawn(['bugreportz', '-s']);
|
|
128
|
+
process.stdout
|
|
129
|
+
.pipeTo(new WritableStream({
|
|
130
|
+
async write(chunk) {
|
|
131
|
+
await controller.enqueue(chunk);
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
process.stderr
|
|
135
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
136
|
+
.pipeTo(new WritableStream({
|
|
137
|
+
async write(chunk) {
|
|
138
|
+
controller.error(new Error(chunk));
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
await process.exit;
|
|
142
|
+
controller.close();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/native/cmds/bugreport/bugreport.cpp;drc=9b73bf07d73dbab5b792632e1e233edbad77f5fd;bpv=0;bpt=0
|
|
148
|
+
export class BugReport extends AdbCommandBase {
|
|
149
|
+
public generate(): ReadableStream<Uint8Array> {
|
|
150
|
+
return new WrapReadableStream(async () => {
|
|
151
|
+
const process = await this.adb.subprocess.spawn(['bugreport']);
|
|
152
|
+
return process.stdout;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
package/src/demo-mode.ts
CHANGED
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
// cspell: ignore carriernetworkchange
|
|
2
|
-
// cspell: ignore powersave
|
|
3
|
-
// cspell: ignore nosim
|
|
4
|
-
// cspell: ignore systemui
|
|
5
|
-
// cspell: ignore sysui
|
|
6
|
-
|
|
7
|
-
import { Adb, AdbCommandBase } from '@yume-chan/adb';
|
|
8
|
-
import { Settings } from "./settings.js";
|
|
9
|
-
|
|
10
|
-
export enum DemoModeSignalStrength {
|
|
11
|
-
Hidden = 'null',
|
|
12
|
-
Level0 = '0',
|
|
13
|
-
Level1 = '1',
|
|
14
|
-
Level2 = '2',
|
|
15
|
-
Level3 = '3',
|
|
16
|
-
Level4 = '4',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java;l=1073
|
|
20
|
-
export const DemoModeMobileDataTypes = ['1x', '3g', '4g', '4g+', '5g', '5ge', '5g+',
|
|
21
|
-
'e', 'g', 'h', 'h+', 'lte', 'lte+', 'dis', 'not', 'null'] as const;
|
|
22
|
-
|
|
23
|
-
export type DemoModeMobileDataType = (typeof DemoModeMobileDataTypes)[number];
|
|
24
|
-
|
|
25
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3136
|
|
26
|
-
export const DemoModeStatusBarModes = ['opaque', 'translucent', 'semi-transparent', 'transparent', 'warning'] as const;
|
|
27
|
-
|
|
28
|
-
export type DemoModeStatusBarMode = (typeof DemoModeStatusBarModes)[number];
|
|
29
|
-
|
|
30
|
-
export class DemoMode extends AdbCommandBase {
|
|
31
|
-
private settings: Settings;
|
|
32
|
-
|
|
33
|
-
constructor(adb: Adb) {
|
|
34
|
-
super(adb);
|
|
35
|
-
this.settings = new Settings(adb);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public static readonly AllowedSettingKey = 'sysui_demo_allowed';
|
|
39
|
-
|
|
40
|
-
// Demo Mode actually doesn't have a setting indicates its enablement
|
|
41
|
-
// However Developer Mode menu uses this key
|
|
42
|
-
// So we can only try our best to guess if it's enabled
|
|
43
|
-
public static readonly EnabledSettingKey = 'sysui_tuner_demo_on';
|
|
44
|
-
|
|
45
|
-
public async getAllowed(): Promise<boolean> {
|
|
46
|
-
const output = await this.settings.get('global', DemoMode.AllowedSettingKey);
|
|
47
|
-
return output.trim() === '1';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async setAllowed(value: boolean): Promise<void> {
|
|
51
|
-
if (value) {
|
|
52
|
-
await this.settings.put('global', DemoMode.AllowedSettingKey, '1');
|
|
53
|
-
} else {
|
|
54
|
-
await this.setEnabled(false);
|
|
55
|
-
await this.settings.delete('global', DemoMode.AllowedSettingKey);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public async getEnabled(): Promise<boolean> {
|
|
60
|
-
const result = await this.settings.get('global', DemoMode.EnabledSettingKey);
|
|
61
|
-
return result.trim() === '1';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public async setEnabled(value: boolean): Promise<void> {
|
|
65
|
-
if (value) {
|
|
66
|
-
await this.settings.put('global', DemoMode.EnabledSettingKey, '1');
|
|
67
|
-
} else {
|
|
68
|
-
await this.settings.delete('global', DemoMode.EnabledSettingKey);
|
|
69
|
-
await this.broadcast('exit');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public async broadcast(command: string, extra?: Record<string, string>): Promise<void> {
|
|
74
|
-
await this.adb.subprocess.spawnAndWaitLegacy([
|
|
75
|
-
'am',
|
|
76
|
-
'broadcast',
|
|
77
|
-
'-a',
|
|
78
|
-
'com.android.systemui.demo',
|
|
79
|
-
'-e',
|
|
80
|
-
'command',
|
|
81
|
-
command,
|
|
82
|
-
...(extra ? Object.entries(extra).flatMap(([key, value]) => ['-e', key, value]) : []),
|
|
83
|
-
]);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
public async setBatteryLevel(level: number): Promise<void> {
|
|
87
|
-
await this.broadcast('battery', { level: level.toString() });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public async setBatteryCharging(value: boolean): Promise<void> {
|
|
91
|
-
await this.broadcast('battery', { plugged: value.toString() });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public async setPowerSaveMode(value: boolean): Promise<void> {
|
|
95
|
-
await this.broadcast('battery', { powersave: value.toString() });
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public async setAirplaneMode(show: boolean): Promise<void> {
|
|
99
|
-
await this.broadcast('network', { airplane: show ? 'show' : 'hide' });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
public async setWifiSignalStrength(value: DemoModeSignalStrength): Promise<void> {
|
|
103
|
-
await this.broadcast('network', { wifi: 'show', level: value });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public async setMobileDataType(value: DemoModeMobileDataType): Promise<void> {
|
|
107
|
-
for (let i = 0; i < 2; i += 1) {
|
|
108
|
-
await this.broadcast('network', {
|
|
109
|
-
mobile: 'show',
|
|
110
|
-
sims: '1',
|
|
111
|
-
nosim: 'hide',
|
|
112
|
-
slot: '0',
|
|
113
|
-
datatype: value,
|
|
114
|
-
fully: 'true',
|
|
115
|
-
roam: 'false',
|
|
116
|
-
level: '4',
|
|
117
|
-
inflate: 'false',
|
|
118
|
-
activity: 'in',
|
|
119
|
-
carriernetworkchange: 'hide',
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public async setMobileSignalStrength(value: DemoModeSignalStrength): Promise<void> {
|
|
125
|
-
await this.broadcast('network', { mobile: 'show', level: value });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public async setNoSimCardIcon(show: boolean): Promise<void> {
|
|
129
|
-
await this.broadcast('network', { nosim: show ? 'show' : 'hide' });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public async setStatusBarMode(mode: DemoModeStatusBarMode): Promise<void> {
|
|
133
|
-
await this.broadcast('bars', { mode });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public async setVibrateModeEnabled(value: boolean): Promise<void> {
|
|
137
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=103
|
|
138
|
-
await this.broadcast('status', { volume: value ? 'vibrate' : 'hide' });
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public async setBluetoothConnected(value: boolean): Promise<void> {
|
|
142
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=114
|
|
143
|
-
await this.broadcast('status', { bluetooth: value ? 'connected' : 'hide' });
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
public async setLocatingIcon(show: boolean): Promise<void> {
|
|
147
|
-
await this.broadcast('status', { location: show ? 'show' : 'hide' });
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
public async setAlarmIcon(show: boolean): Promise<void> {
|
|
151
|
-
await this.broadcast('status', { alarm: show ? 'show' : 'hide' });
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public async setSyncingIcon(show: boolean): Promise<void> {
|
|
155
|
-
await this.broadcast('status', { sync: show ? 'show' : 'hide' });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public async setMuteIcon(show: boolean): Promise<void> {
|
|
159
|
-
await this.broadcast('status', { mute: show ? 'show' : 'hide' });
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public async setSpeakerPhoneIcon(show: boolean): Promise<void> {
|
|
163
|
-
await this.broadcast('status', { speakerphone: show ? 'show' : 'hide' });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
public async setNotificationsVisibility(show: boolean): Promise<void> {
|
|
167
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3131
|
|
168
|
-
await this.broadcast('notifications', { visible: show.toString() });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public async setTime(hour: number, minute: number): Promise<void> {
|
|
172
|
-
await this.broadcast('clock', {
|
|
173
|
-
// cspell: disable-next-line
|
|
174
|
-
hhmm:
|
|
175
|
-
hour.toString().padStart(2, '0') +
|
|
176
|
-
minute.toString().padStart(2, '0'),
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
1
|
+
// cspell: ignore carriernetworkchange
|
|
2
|
+
// cspell: ignore powersave
|
|
3
|
+
// cspell: ignore nosim
|
|
4
|
+
// cspell: ignore systemui
|
|
5
|
+
// cspell: ignore sysui
|
|
6
|
+
|
|
7
|
+
import { Adb, AdbCommandBase } from '@yume-chan/adb';
|
|
8
|
+
import { Settings } from "./settings.js";
|
|
9
|
+
|
|
10
|
+
export enum DemoModeSignalStrength {
|
|
11
|
+
Hidden = 'null',
|
|
12
|
+
Level0 = '0',
|
|
13
|
+
Level1 = '1',
|
|
14
|
+
Level2 = '2',
|
|
15
|
+
Level3 = '3',
|
|
16
|
+
Level4 = '4',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java;l=1073
|
|
20
|
+
export const DemoModeMobileDataTypes = ['1x', '3g', '4g', '4g+', '5g', '5ge', '5g+',
|
|
21
|
+
'e', 'g', 'h', 'h+', 'lte', 'lte+', 'dis', 'not', 'null'] as const;
|
|
22
|
+
|
|
23
|
+
export type DemoModeMobileDataType = (typeof DemoModeMobileDataTypes)[number];
|
|
24
|
+
|
|
25
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3136
|
|
26
|
+
export const DemoModeStatusBarModes = ['opaque', 'translucent', 'semi-transparent', 'transparent', 'warning'] as const;
|
|
27
|
+
|
|
28
|
+
export type DemoModeStatusBarMode = (typeof DemoModeStatusBarModes)[number];
|
|
29
|
+
|
|
30
|
+
export class DemoMode extends AdbCommandBase {
|
|
31
|
+
private settings: Settings;
|
|
32
|
+
|
|
33
|
+
constructor(adb: Adb) {
|
|
34
|
+
super(adb);
|
|
35
|
+
this.settings = new Settings(adb);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public static readonly AllowedSettingKey = 'sysui_demo_allowed';
|
|
39
|
+
|
|
40
|
+
// Demo Mode actually doesn't have a setting indicates its enablement
|
|
41
|
+
// However Developer Mode menu uses this key
|
|
42
|
+
// So we can only try our best to guess if it's enabled
|
|
43
|
+
public static readonly EnabledSettingKey = 'sysui_tuner_demo_on';
|
|
44
|
+
|
|
45
|
+
public async getAllowed(): Promise<boolean> {
|
|
46
|
+
const output = await this.settings.get('global', DemoMode.AllowedSettingKey);
|
|
47
|
+
return output.trim() === '1';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async setAllowed(value: boolean): Promise<void> {
|
|
51
|
+
if (value) {
|
|
52
|
+
await this.settings.put('global', DemoMode.AllowedSettingKey, '1');
|
|
53
|
+
} else {
|
|
54
|
+
await this.setEnabled(false);
|
|
55
|
+
await this.settings.delete('global', DemoMode.AllowedSettingKey);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public async getEnabled(): Promise<boolean> {
|
|
60
|
+
const result = await this.settings.get('global', DemoMode.EnabledSettingKey);
|
|
61
|
+
return result.trim() === '1';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public async setEnabled(value: boolean): Promise<void> {
|
|
65
|
+
if (value) {
|
|
66
|
+
await this.settings.put('global', DemoMode.EnabledSettingKey, '1');
|
|
67
|
+
} else {
|
|
68
|
+
await this.settings.delete('global', DemoMode.EnabledSettingKey);
|
|
69
|
+
await this.broadcast('exit');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public async broadcast(command: string, extra?: Record<string, string>): Promise<void> {
|
|
74
|
+
await this.adb.subprocess.spawnAndWaitLegacy([
|
|
75
|
+
'am',
|
|
76
|
+
'broadcast',
|
|
77
|
+
'-a',
|
|
78
|
+
'com.android.systemui.demo',
|
|
79
|
+
'-e',
|
|
80
|
+
'command',
|
|
81
|
+
command,
|
|
82
|
+
...(extra ? Object.entries(extra).flatMap(([key, value]) => ['-e', key, value]) : []),
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public async setBatteryLevel(level: number): Promise<void> {
|
|
87
|
+
await this.broadcast('battery', { level: level.toString() });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public async setBatteryCharging(value: boolean): Promise<void> {
|
|
91
|
+
await this.broadcast('battery', { plugged: value.toString() });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public async setPowerSaveMode(value: boolean): Promise<void> {
|
|
95
|
+
await this.broadcast('battery', { powersave: value.toString() });
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public async setAirplaneMode(show: boolean): Promise<void> {
|
|
99
|
+
await this.broadcast('network', { airplane: show ? 'show' : 'hide' });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public async setWifiSignalStrength(value: DemoModeSignalStrength): Promise<void> {
|
|
103
|
+
await this.broadcast('network', { wifi: 'show', level: value });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public async setMobileDataType(value: DemoModeMobileDataType): Promise<void> {
|
|
107
|
+
for (let i = 0; i < 2; i += 1) {
|
|
108
|
+
await this.broadcast('network', {
|
|
109
|
+
mobile: 'show',
|
|
110
|
+
sims: '1',
|
|
111
|
+
nosim: 'hide',
|
|
112
|
+
slot: '0',
|
|
113
|
+
datatype: value,
|
|
114
|
+
fully: 'true',
|
|
115
|
+
roam: 'false',
|
|
116
|
+
level: '4',
|
|
117
|
+
inflate: 'false',
|
|
118
|
+
activity: 'in',
|
|
119
|
+
carriernetworkchange: 'hide',
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public async setMobileSignalStrength(value: DemoModeSignalStrength): Promise<void> {
|
|
125
|
+
await this.broadcast('network', { mobile: 'show', level: value });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public async setNoSimCardIcon(show: boolean): Promise<void> {
|
|
129
|
+
await this.broadcast('network', { nosim: show ? 'show' : 'hide' });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public async setStatusBarMode(mode: DemoModeStatusBarMode): Promise<void> {
|
|
133
|
+
await this.broadcast('bars', { mode });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public async setVibrateModeEnabled(value: boolean): Promise<void> {
|
|
137
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=103
|
|
138
|
+
await this.broadcast('status', { volume: value ? 'vibrate' : 'hide' });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public async setBluetoothConnected(value: boolean): Promise<void> {
|
|
142
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=114
|
|
143
|
+
await this.broadcast('status', { bluetooth: value ? 'connected' : 'hide' });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
public async setLocatingIcon(show: boolean): Promise<void> {
|
|
147
|
+
await this.broadcast('status', { location: show ? 'show' : 'hide' });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public async setAlarmIcon(show: boolean): Promise<void> {
|
|
151
|
+
await this.broadcast('status', { alarm: show ? 'show' : 'hide' });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public async setSyncingIcon(show: boolean): Promise<void> {
|
|
155
|
+
await this.broadcast('status', { sync: show ? 'show' : 'hide' });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public async setMuteIcon(show: boolean): Promise<void> {
|
|
159
|
+
await this.broadcast('status', { mute: show ? 'show' : 'hide' });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public async setSpeakerPhoneIcon(show: boolean): Promise<void> {
|
|
163
|
+
await this.broadcast('status', { speakerphone: show ? 'show' : 'hide' });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public async setNotificationsVisibility(show: boolean): Promise<void> {
|
|
167
|
+
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3131
|
|
168
|
+
await this.broadcast('notifications', { visible: show.toString() });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public async setTime(hour: number, minute: number): Promise<void> {
|
|
172
|
+
await this.broadcast('clock', {
|
|
173
|
+
// cspell: disable-next-line
|
|
174
|
+
hhmm:
|
|
175
|
+
hour.toString().padStart(2, '0') +
|
|
176
|
+
minute.toString().padStart(2, '0'),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// cspell: ignore logcat
|
|
2
|
-
|
|
3
|
-
export * from './bug-report.js';
|
|
4
|
-
export * from './demo-mode.js';
|
|
5
|
-
export * from './logcat.js';
|
|
6
|
-
export * from './settings.js';
|
|
1
|
+
// cspell: ignore logcat
|
|
2
|
+
|
|
3
|
+
export * from './bug-report.js';
|
|
4
|
+
export * from './demo-mode.js';
|
|
5
|
+
export * from './logcat.js';
|
|
6
|
+
export * from './settings.js';
|
package/src/logcat.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// cspell: ignore logcat
|
|
2
2
|
|
|
3
|
-
import { AdbCommandBase, BufferedStream, BufferedStreamEndedError, DecodeUtf8Stream, ReadableStream, SplitLineStream, WritableStream } from "@yume-chan/adb";
|
|
3
|
+
import { AdbCommandBase, AdbSubprocessNoneProtocol, BufferedStream, BufferedStreamEndedError, DecodeUtf8Stream, ReadableStream, SplitLineStream, WritableStream } from "@yume-chan/adb";
|
|
4
4
|
import Struct, { StructAsyncDeserializeStream } from "@yume-chan/struct";
|
|
5
5
|
|
|
6
6
|
// `adb logcat` is an alias to `adb shell logcat`
|
|
@@ -63,10 +63,14 @@ export interface LogMessage extends LoggerEntry {
|
|
|
63
63
|
|
|
64
64
|
export async function deserializeLogMessage(stream: StructAsyncDeserializeStream): Promise<LogMessage> {
|
|
65
65
|
const entry = await LoggerEntry.deserialize(stream);
|
|
66
|
-
|
|
66
|
+
if (entry.headerSize !== LoggerEntry.size) {
|
|
67
|
+
await stream.read(entry.headerSize - LoggerEntry.size);
|
|
68
|
+
}
|
|
67
69
|
const priority = (await stream.read(1))[0] as LogPriority;
|
|
68
70
|
const payload = await stream.read(entry.payloadSize - 1);
|
|
69
|
-
|
|
71
|
+
(entry as any).priority = priority;
|
|
72
|
+
(entry as any).payload = payload;
|
|
73
|
+
return entry as LogMessage;
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
export interface LogSize {
|
|
@@ -163,7 +167,10 @@ export class Logcat extends AdbCommandBase {
|
|
|
163
167
|
'-B',
|
|
164
168
|
...(options?.pid ? ['--pid', options.pid.toString()] : []),
|
|
165
169
|
...(options?.ids ? ['-b', Logcat.joinLogId(options.ids)] : [])
|
|
166
|
-
]
|
|
170
|
+
], {
|
|
171
|
+
// PERF: None protocol is 150% faster then Shell protocol
|
|
172
|
+
protocols: [AdbSubprocessNoneProtocol],
|
|
173
|
+
});
|
|
167
174
|
bufferedStream = new BufferedStream(stdout);
|
|
168
175
|
},
|
|
169
176
|
async pull(controller) {
|
package/src/settings.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { AdbCommandBase } from "@yume-chan/adb";
|
|
2
|
-
|
|
3
|
-
export type SettingsNamespace = 'system' | 'secure' | 'global';
|
|
4
|
-
|
|
5
|
-
export type SettingsResetMode = 'untrusted_defaults' | 'untrusted_clear' | 'trusted_defaults';
|
|
6
|
-
|
|
7
|
-
// frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java
|
|
8
|
-
export class Settings extends AdbCommandBase {
|
|
9
|
-
// TODO: `--user <user>` argument
|
|
10
|
-
|
|
11
|
-
public base(command: string, namespace: SettingsNamespace, ...args: string[]) {
|
|
12
|
-
return this.adb.subprocess.spawnAndWaitLegacy(['settings', command, namespace, ...args]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public get(namespace: SettingsNamespace, key: string) {
|
|
16
|
-
return this.base('get', namespace, key);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public delete(namespace: SettingsNamespace, key: string) {
|
|
20
|
-
return this.base('delete', namespace, key);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public put(namespace: SettingsNamespace, key: string, value: string, tag?: string, makeDefault?: boolean) {
|
|
24
|
-
return this.base(
|
|
25
|
-
'put',
|
|
26
|
-
namespace,
|
|
27
|
-
key,
|
|
28
|
-
value,
|
|
29
|
-
...(tag ? [tag] : []),
|
|
30
|
-
...(makeDefault ? ['default'] : []),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public reset(namespace: SettingsNamespace, mode: SettingsResetMode): Promise<string>;
|
|
35
|
-
public reset(namespace: SettingsNamespace, packageName: string, tag?: string): Promise<string>;
|
|
36
|
-
public reset(namespace: SettingsNamespace, modeOrPackageName: string, tag?: string): Promise<string> {
|
|
37
|
-
return this.base(
|
|
38
|
-
'reset',
|
|
39
|
-
namespace,
|
|
40
|
-
modeOrPackageName,
|
|
41
|
-
...(tag ? [tag] : []),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async list(namespace: SettingsNamespace): Promise<string[]> {
|
|
46
|
-
const output = await this.base('list', namespace);
|
|
47
|
-
return output.split('\n');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
import { AdbCommandBase } from "@yume-chan/adb";
|
|
2
|
+
|
|
3
|
+
export type SettingsNamespace = 'system' | 'secure' | 'global';
|
|
4
|
+
|
|
5
|
+
export type SettingsResetMode = 'untrusted_defaults' | 'untrusted_clear' | 'trusted_defaults';
|
|
6
|
+
|
|
7
|
+
// frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java
|
|
8
|
+
export class Settings extends AdbCommandBase {
|
|
9
|
+
// TODO: `--user <user>` argument
|
|
10
|
+
|
|
11
|
+
public base(command: string, namespace: SettingsNamespace, ...args: string[]) {
|
|
12
|
+
return this.adb.subprocess.spawnAndWaitLegacy(['settings', command, namespace, ...args]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public get(namespace: SettingsNamespace, key: string) {
|
|
16
|
+
return this.base('get', namespace, key);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public delete(namespace: SettingsNamespace, key: string) {
|
|
20
|
+
return this.base('delete', namespace, key);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public put(namespace: SettingsNamespace, key: string, value: string, tag?: string, makeDefault?: boolean) {
|
|
24
|
+
return this.base(
|
|
25
|
+
'put',
|
|
26
|
+
namespace,
|
|
27
|
+
key,
|
|
28
|
+
value,
|
|
29
|
+
...(tag ? [tag] : []),
|
|
30
|
+
...(makeDefault ? ['default'] : []),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public reset(namespace: SettingsNamespace, mode: SettingsResetMode): Promise<string>;
|
|
35
|
+
public reset(namespace: SettingsNamespace, packageName: string, tag?: string): Promise<string>;
|
|
36
|
+
public reset(namespace: SettingsNamespace, modeOrPackageName: string, tag?: string): Promise<string> {
|
|
37
|
+
return this.base(
|
|
38
|
+
'reset',
|
|
39
|
+
namespace,
|
|
40
|
+
modeOrPackageName,
|
|
41
|
+
...(tag ? [tag] : []),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public async list(namespace: SettingsNamespace): Promise<string[]> {
|
|
46
|
+
const output = await this.base('list', namespace);
|
|
47
|
+
return output.split('\n');
|
|
48
|
+
}
|
|
49
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json",
|
|
3
|
-
"references": [
|
|
4
|
-
{
|
|
5
|
-
"path": "../adb/tsconfig.build.json"
|
|
6
|
-
}
|
|
7
|
-
]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json",
|
|
3
|
+
"references": [
|
|
4
|
+
{
|
|
5
|
+
"path": "../adb/tsconfig.build.json"
|
|
6
|
+
}
|
|
7
|
+
]
|
|
8
|
+
}
|
|
File without changes
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"libraries/android-bin/.rush/temp/shrinkwrap-deps.json": "4a66ebc96ce486db90e703e033412dd27055264b",
|
|
4
|
-
"libraries/android-bin/README.md": "96d1e739d73df6dc17920182c1c5799b65652b69",
|
|
5
|
-
"libraries/android-bin/package.json": "368868c45277e097267c990798e20b72c52d06a7",
|
|
6
|
-
"libraries/android-bin/src/bug-report.ts": "d1fab2f22bca38081c763abff9a42836d90803e5",
|
|
7
|
-
"libraries/android-bin/src/demo-mode.ts": "60feecacac2a9a8587e72e3b4f85334acf96f169",
|
|
8
|
-
"libraries/android-bin/src/index.ts": "b821d7309b6ef03a9c81044250d632b4c52c9d2c",
|
|
9
|
-
"libraries/android-bin/src/settings.ts": "a323081296746d78ea07f473680321331ff0d46c",
|
|
10
|
-
"libraries/android-bin/tsconfig.json": "07f9242b115ab18b8e8d2564d25d32349ffb21cb"
|
|
11
|
-
},
|
|
12
|
-
"arguments": ""
|
|
13
|
-
}
|