@yume-chan/android-bin 0.0.20 → 0.0.22

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.
Files changed (76) hide show
  1. package/CHANGELOG.json +54 -0
  2. package/CHANGELOG.md +25 -1
  3. package/LICENSE +21 -0
  4. package/README.md +40 -14
  5. package/esm/am.d.ts +17 -0
  6. package/esm/am.d.ts.map +1 -0
  7. package/esm/am.js +42 -0
  8. package/esm/am.js.map +1 -0
  9. package/esm/bu.d.ts +20 -7
  10. package/esm/bu.d.ts.map +1 -1
  11. package/esm/bu.js +47 -8
  12. package/esm/bu.js.map +1 -1
  13. package/esm/bug-report.d.ts +82 -21
  14. package/esm/bug-report.d.ts.map +1 -1
  15. package/esm/bug-report.js +187 -53
  16. package/esm/bug-report.js.map +1 -1
  17. package/esm/cmd.d.ts +4 -6
  18. package/esm/cmd.d.ts.map +1 -1
  19. package/esm/cmd.js +36 -21
  20. package/esm/cmd.js.map +1 -1
  21. package/esm/demo-mode.d.ts +3 -3
  22. package/esm/demo-mode.d.ts.map +1 -1
  23. package/esm/demo-mode.js +14 -15
  24. package/esm/demo-mode.js.map +1 -1
  25. package/esm/dumpsys.d.ts +39 -0
  26. package/esm/dumpsys.d.ts.map +1 -1
  27. package/esm/dumpsys.js +111 -0
  28. package/esm/dumpsys.js.map +1 -1
  29. package/esm/index.d.ts +6 -0
  30. package/esm/index.d.ts.map +1 -1
  31. package/esm/index.js +6 -0
  32. package/esm/index.js.map +1 -1
  33. package/esm/intent.d.ts +10 -0
  34. package/esm/intent.d.ts.map +1 -0
  35. package/esm/intent.js +51 -0
  36. package/esm/intent.js.map +1 -0
  37. package/esm/logcat.d.ts +1 -0
  38. package/esm/logcat.d.ts.map +1 -1
  39. package/esm/logcat.js +20 -18
  40. package/esm/logcat.js.map +1 -1
  41. package/esm/overlay-display.d.ts +20 -3
  42. package/esm/overlay-display.d.ts.map +1 -1
  43. package/esm/overlay-display.js +34 -61
  44. package/esm/overlay-display.js.map +1 -1
  45. package/esm/pm.d.ts +42 -5
  46. package/esm/pm.d.ts.map +1 -1
  47. package/esm/pm.js +164 -46
  48. package/esm/pm.js.map +1 -1
  49. package/esm/settings.d.ts +22 -8
  50. package/esm/settings.d.ts.map +1 -1
  51. package/esm/settings.js +50 -25
  52. package/esm/settings.js.map +1 -1
  53. package/esm/string-format.d.ts +40 -0
  54. package/esm/string-format.d.ts.map +1 -0
  55. package/esm/string-format.js +153 -0
  56. package/esm/string-format.js.map +1 -0
  57. package/esm/utils.d.ts +4 -0
  58. package/esm/utils.d.ts.map +1 -0
  59. package/esm/utils.js +23 -0
  60. package/esm/utils.js.map +1 -0
  61. package/package.json +13 -8
  62. package/src/am.ts +69 -0
  63. package/src/bu.ts +68 -14
  64. package/src/bug-report.ts +234 -68
  65. package/src/cmd.ts +64 -30
  66. package/src/demo-mode.ts +47 -43
  67. package/src/dumpsys.ts +129 -0
  68. package/src/index.ts +6 -0
  69. package/src/intent.ts +63 -0
  70. package/src/logcat.ts +45 -42
  71. package/src/overlay-display.ts +82 -85
  72. package/src/pm.ts +274 -61
  73. package/src/settings.ts +94 -43
  74. package/src/string-format.ts +199 -0
  75. package/src/utils.ts +29 -0
  76. package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@yume-chan/android-bin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.0.22",
6
+ "tag": "@yume-chan/android-bin_v0.0.22",
7
+ "date": "Wed, 13 Dec 2023 05:57:27 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Add wrapper for `pm uninstall`"
12
+ },
13
+ {
14
+ "comment": "Change `PackageManager#listPackages` to return an async generator"
15
+ },
16
+ {
17
+ "comment": "Add wrapper for `am start`"
18
+ },
19
+ {
20
+ "comment": "Add wrapper for `pm resolve-activity`"
21
+ },
22
+ {
23
+ "comment": "Add `status` and `health` fields to `DumpSys#battery`"
24
+ }
25
+ ]
26
+ }
27
+ },
28
+ {
29
+ "version": "0.0.21",
30
+ "tag": "@yume-chan/android-bin_v0.0.21",
31
+ "date": "Fri, 25 Aug 2023 14:05:18 GMT",
32
+ "comments": {
33
+ "none": [
34
+ {
35
+ "comment": "Add wrapper for `bu`"
36
+ },
37
+ {
38
+ "comment": "Remove the last `\\n` from `Settings#get`"
39
+ },
40
+ {
41
+ "comment": "Add wrappers for `dumpsys diskstats` and `dumpsys battery`"
42
+ },
43
+ {
44
+ "comment": "Add wrapper for `pm list packages`"
45
+ },
46
+ {
47
+ "comment": "Rewrite `Settings` to use `Cmd` if available"
48
+ },
49
+ {
50
+ "comment": "Add support to stop `bugreport`"
51
+ },
52
+ {
53
+ "comment": "Merge `bugreport` and `bugreportz` wrappers, providing an `automatic` method to choose the best available bugreport method"
54
+ }
55
+ ]
56
+ }
57
+ },
4
58
  {
5
59
  "version": "0.0.20",
6
60
  "tag": "@yume-chan/android-bin_v0.0.20",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  # Change Log - @yume-chan/android-bin
2
2
 
3
- This log was last generated on Mon, 05 Jun 2023 02:51:41 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 13 Dec 2023 05:57:27 GMT and should not be manually modified.
4
+
5
+ ## 0.0.22
6
+ Wed, 13 Dec 2023 05:57:27 GMT
7
+
8
+ ### Updates
9
+
10
+ - Add wrapper for `pm uninstall`
11
+ - Change `PackageManager#listPackages` to return an async generator
12
+ - Add wrapper for `am start`
13
+ - Add wrapper for `pm resolve-activity`
14
+ - Add `status` and `health` fields to `DumpSys#battery`
15
+
16
+ ## 0.0.21
17
+ Fri, 25 Aug 2023 14:05:18 GMT
18
+
19
+ ### Updates
20
+
21
+ - Add wrapper for `bu`
22
+ - Remove the last `\n` from `Settings#get`
23
+ - Add wrappers for `dumpsys diskstats` and `dumpsys battery`
24
+ - Add wrapper for `pm list packages`
25
+ - Rewrite `Settings` to use `Cmd` if available
26
+ - Add support to stop `bugreport`
27
+ - Merge `bugreport` and `bugreportz` wrappers, providing an `automatic` method to choose the best available bugreport method
4
28
 
5
29
  ## 0.0.20
6
30
  Mon, 05 Jun 2023 02:51:41 GMT
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2023 Simon Chan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,20 +1,46 @@
1
- # `@yume-chan/android-bin`
1
+ <p align="center">
2
+ <img alt="Tango" src="https://raw.githubusercontent.com/yume-chan/ya-webadb/main/.github/logo.svg" width="200">
3
+ </p>
2
4
 
3
- Wrappers for Android built-in executables.
5
+ <h1 align="center">@yume-chan/android-bin</h1>
4
6
 
5
- Currently it's bound to `@yume-chan/adb`, maybe one day it can be used with other executors.
7
+ <p align="center">
8
+ Wrappers for Android built-in executables.
9
+ </p>
6
10
 
7
- ## Implemented
11
+ <p align="center">
12
+ <a href="https://github.com/yume-chan/ya-webadb/blob/main/LICENSE">
13
+ <img alt="MIT License" src="https://img.shields.io/github/license/yume-chan/ya-webadb">
14
+ </a>
15
+ <a href="https://github.com/yume-chan/ya-webadb/releases">
16
+ <img alt="GitHub release" src="https://img.shields.io/github/v/release/yume-chan/ya-webadb?logo=github">
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/@yume-chan/adb">
19
+ <img alt="npm" src="https://img.shields.io/npm/dm/%40yume-chan/adb?logo=npm">
20
+ </a>
21
+ <a href="https://discord.gg/26k3ttC2PN">
22
+ <img alt="Discord" src="https://img.shields.io/discord/1120215514732564502?logo=discord&logoColor=%23ffffff&label=Discord">
23
+ </a>
24
+ </p>
8
25
 
9
- * `bugreport`
10
- * `bugreportz`
11
- * `settings`
12
- * Demo mode
13
- * `logcat`
26
+ This package is part of [Tango ADB](https://github.com/yume-chan/ya-webadb). Generally you need multiple packages to build a complete ADB client that can run on Web browsers and Node.js. Read the documentation for more information.
14
27
 
15
- ## Planned
28
+ ## Documentation
16
29
 
17
- - [ ] `bu` ([#354](https://github.com/yume-chan/ya-webadb/issues/354))
18
- - [ ] `input` ([#363](https://github.com/yume-chan/ya-webadb/issues/363))
19
- - [ ] `am` ([#366](https://github.com/yume-chan/ya-webadb/issues/366))
20
- - [ ] `pm` ([#373](https://github.com/yume-chan/ya-webadb/issues/373))
30
+ Check the latest documentation at https://tango-adb.github.io/docs/
31
+
32
+ ## Sponsors
33
+
34
+ [Become a backer](https://opencollective.com/ya-webadb) and get your image on our README on Github with a link to your site.
35
+
36
+ <a href="https://opencollective.com/ya-webadb/backer/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/0/avatar.svg?requireActive=false"></a>
37
+ <a href="https://opencollective.com/ya-webadb/backer/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/1/avatar.svg?requireActive=false"></a>
38
+ <a href="https://opencollective.com/ya-webadb/backer/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/2/avatar.svg?requireActive=false"></a>
39
+ <a href="https://opencollective.com/ya-webadb/backer/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/3/avatar.svg?requireActive=false"></a>
40
+ <a href="https://opencollective.com/ya-webadb/backer/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/4/avatar.svg?requireActive=false"></a>
41
+ <a href="https://opencollective.com/ya-webadb/backer/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/5/avatar.svg?requireActive=false"></a>
42
+ <a href="https://opencollective.com/ya-webadb/backer/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/6/avatar.svg?requireActive=false"></a>
43
+ <a href="https://opencollective.com/ya-webadb/backer/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/7/avatar.svg?requireActive=false"></a>
44
+ <a href="https://opencollective.com/ya-webadb/backer/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/8/avatar.svg?requireActive=false"></a>
45
+ <a href="https://opencollective.com/ya-webadb/backer/9/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/9/avatar.svg?requireActive=false"></a>
46
+ <a href="https://opencollective.com/ya-webadb/backer/10/website?requireActive=false" target="_blank"><img src="https://opencollective.com/ya-webadb/backer/10/avatar.svg?requireActive=false"></a>
package/esm/am.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { Adb } from "@yume-chan/adb";
2
+ import { AdbCommandBase } from "@yume-chan/adb";
3
+ import type { IntentBuilder } from "./intent.js";
4
+ import type { SingleUser } from "./utils.js";
5
+ export interface ActivityManagerStartActivityOptions {
6
+ displayId?: number;
7
+ windowingMode?: number;
8
+ forceStop?: boolean;
9
+ user?: SingleUser;
10
+ intent: IntentBuilder;
11
+ }
12
+ export declare class ActivityManager extends AdbCommandBase {
13
+ #private;
14
+ constructor(adb: Adb);
15
+ startActivity(options: ActivityManagerStartActivityOptions): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=am.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"am.d.ts","sourceRoot":"","sources":["../src/am.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,MAAM,WAAW,mCAAmC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;CACzB;AAWD,qBAAa,eAAgB,SAAQ,cAAc;;gBAGnC,GAAG,EAAE,GAAG;IAcd,aAAa,CAAC,OAAO,EAAE,mCAAmC;CAyBnE"}
package/esm/am.js ADDED
@@ -0,0 +1,42 @@
1
+ import { AdbCommandBase } from "@yume-chan/adb";
2
+ import { ConcatStringStream, DecodeUtf8Stream } from "@yume-chan/stream-extra";
3
+ import { Cmd } from "./cmd.js";
4
+ import { buildArguments } from "./utils.js";
5
+ const START_ACTIVITY_OPTIONS_MAP = {
6
+ displayId: "--display",
7
+ windowingMode: "--windowingMode",
8
+ forceStop: "-S",
9
+ user: "--user",
10
+ };
11
+ export class ActivityManager extends AdbCommandBase {
12
+ #cmd;
13
+ constructor(adb) {
14
+ super(adb);
15
+ this.#cmd = new Cmd(adb);
16
+ }
17
+ async #cmdOrSubprocess(args) {
18
+ if (this.#cmd.supportsCmd) {
19
+ args.shift();
20
+ return await this.#cmd.spawn(false, "activity", ...args);
21
+ }
22
+ return this.adb.subprocess.spawn(args);
23
+ }
24
+ async startActivity(options) {
25
+ let args = buildArguments(["am", "start-activity", "-W"], options, START_ACTIVITY_OPTIONS_MAP);
26
+ args = args.concat(options.intent.build());
27
+ const process = await this.#cmdOrSubprocess(args);
28
+ const output = await process.stdout
29
+ .pipeThrough(new DecodeUtf8Stream())
30
+ .pipeThrough(new ConcatStringStream())
31
+ .then((output) => output.trim());
32
+ for (const line of output) {
33
+ if (line.startsWith("Error:")) {
34
+ throw new Error(line.substring("Error:".length).trim());
35
+ }
36
+ if (line === "Complete") {
37
+ return;
38
+ }
39
+ }
40
+ }
41
+ }
42
+ //# sourceMappingURL=am.js.map
package/esm/am.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"am.js","sourceRoot":"","sources":["../src/am.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE/E,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAU5C,MAAM,0BAA0B,GAE5B;IACA,SAAS,EAAE,WAAW;IACtB,aAAa,EAAE,iBAAiB;IAChC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,OAAO,eAAgB,SAAQ,cAAc;IAC/C,IAAI,CAAM;IAEV,YAAY,GAAQ;QAChB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAc;QACjC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;QAC7D,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAA4C;QAC5D,IAAI,IAAI,GAAG,cAAc,CACrB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAC9B,OAAO,EACP,0BAA0B,CAC7B,CAAC;QAEF,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAE3C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM;aAC9B,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;aACnC,WAAW,CAAC,IAAI,kBAAkB,EAAE,CAAC;aACrC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAErC,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YACxB,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACtB,OAAO;YACX,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
package/esm/bu.d.ts CHANGED
@@ -1,15 +1,28 @@
1
1
  import { AdbCommandBase } from "@yume-chan/adb";
2
+ import type { Consumable, ReadableStream } from "@yume-chan/stream-extra";
2
3
  export interface AdbBackupOptions {
3
- apps: string[] | "all" | "all-including-system";
4
- apks: boolean;
5
- obbs: boolean;
6
- shared: boolean;
7
- widgets: boolean;
4
+ user: number;
5
+ saveSharedStorage?: boolean;
6
+ saveWidgets?: boolean;
7
+ packages: string[] | "user" | "all";
8
+ savePackageApk: boolean;
9
+ savePackageObb: boolean;
10
+ savePackageKeyValue: boolean;
8
11
  compress: boolean;
12
+ }
13
+ export interface AdbRestoreOptions {
9
14
  user: number;
15
+ file: ReadableStream<Consumable<Uint8Array>>;
10
16
  }
11
17
  export declare class AdbBackup extends AdbCommandBase {
12
- backup(options: AdbBackupOptions): Promise<void>;
13
- restore(options: AdbBackupOptions): Promise<void>;
18
+ /**
19
+ * User must confirm backup on device within 60 seconds.
20
+ */
21
+ backup(options: AdbBackupOptions): Promise<ReadableStream<Uint8Array>>;
22
+ /**
23
+ * User must enter the password (if any) and
24
+ * confirm restore on device within 60 seconds.
25
+ */
26
+ restore(options: AdbRestoreOptions): Promise<string>;
14
27
  }
15
28
  //# sourceMappingURL=bu.d.ts.map
package/esm/bu.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bu.d.ts","sourceRoot":"","sources":["../src/bu.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,sBAAsB,CAAC;IAChD,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,SAAU,SAAQ,cAAc;IACzC,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpD"}
1
+ {"version":3,"file":"bu.d.ts","sourceRoot":"","sources":["../src/bu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG1E,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC;IACpC,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;CAChD;AAED,qBAAa,SAAU,SAAQ,cAAc;IACzC;;OAEG;IACG,MAAM,CACR,OAAO,EAAE,gBAAgB,GAC1B,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAmCtC;;;OAGG;IACG,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;CAc7D"}
package/esm/bu.js CHANGED
@@ -1,14 +1,53 @@
1
- // cspell: ignore apks
2
- // cspell: ignore obbs
3
1
  import { AdbCommandBase } from "@yume-chan/adb";
2
+ import { ConcatStringStream, DecodeUtf8Stream } from "@yume-chan/stream-extra";
4
3
  export class AdbBackup extends AdbCommandBase {
5
- backup(options) {
6
- void options;
7
- throw new Error("Not implemented");
4
+ /**
5
+ * User must confirm backup on device within 60 seconds.
6
+ */
7
+ async backup(options) {
8
+ const args = ["bu", "backup"];
9
+ if (options.user !== undefined) {
10
+ args.push("--user", options.user.toString());
11
+ }
12
+ args.push(options.saveSharedStorage ? "--shared" : "--no-shared");
13
+ args.push(options.saveWidgets ? "--widgets" : "--no-widgets");
14
+ args.push(options.savePackageApk ? "--apk" : "--no-apk");
15
+ args.push(options.savePackageObb ? "--obb" : "--no-obb");
16
+ args.push(options.savePackageKeyValue ? "--key-value" : "--no-key-value");
17
+ args.push(options.compress ? "--compress" : "--no-compress");
18
+ if (typeof options.packages === "string") {
19
+ switch (options.packages) {
20
+ case "user":
21
+ args.push("--all", "--no-system");
22
+ break;
23
+ case "all":
24
+ args.push("--all", "--system");
25
+ break;
26
+ }
27
+ }
28
+ else {
29
+ args.push(...options.packages);
30
+ }
31
+ const process = await this.adb.subprocess.spawn(args);
32
+ return process.stdout;
8
33
  }
9
- restore(options) {
10
- void options;
11
- throw new Error("Not implemented");
34
+ /**
35
+ * User must enter the password (if any) and
36
+ * confirm restore on device within 60 seconds.
37
+ */
38
+ async restore(options) {
39
+ const args = ["bu", "restore"];
40
+ if (options.user !== undefined) {
41
+ args.push("--user", options.user.toString());
42
+ }
43
+ const process = await this.adb.subprocess.spawn(args);
44
+ const [output] = await Promise.all([
45
+ process.stdout
46
+ .pipeThrough(new DecodeUtf8Stream())
47
+ .pipeThrough(new ConcatStringStream()),
48
+ options.file.pipeTo(process.stdin),
49
+ ]);
50
+ return output;
12
51
  }
13
52
  }
14
53
  //# sourceMappingURL=bu.js.map
package/esm/bu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bu.js","sourceRoot":"","sources":["../src/bu.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,sBAAsB;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAYhD,MAAM,OAAO,SAAU,SAAQ,cAAc;IACzC,MAAM,CAAC,OAAyB;QAC5B,KAAK,OAAO,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,OAAyB;QAC7B,KAAK,OAAO,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ"}
1
+ {"version":3,"file":"bu.js","sourceRoot":"","sources":["../src/bu.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oBACP,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,KAAK;oBACN,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC/B,MAAM;YACd,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtD,OAAO,OAAO,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,OAA0B;QACpC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/B,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC/B,OAAO,CAAC,MAAM;iBACT,WAAW,CAAC,IAAI,gBAAgB,EAAE,CAAC;iBACnC,WAAW,CAAC,IAAI,kBAAkB,EAAE,CAAC;YAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;SACrC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
@@ -1,38 +1,99 @@
1
+ import type { Adb } from "@yume-chan/adb";
1
2
  import { AdbCommandBase } from "@yume-chan/adb";
2
- import type { ReadableStream } from "@yume-chan/stream-extra";
3
- export interface BugReportZVersion {
4
- major: number;
5
- minor: number;
6
- supportProgress: boolean;
7
- supportStream: boolean;
3
+ import type { AbortSignal, ReadableStream } from "@yume-chan/stream-extra";
4
+ export interface BugReportCapabilities {
5
+ supportsBugReport: boolean;
6
+ bugReportZVersion?: string | undefined;
7
+ supportsBugReportZ: boolean;
8
+ supportsBugReportZProgress: boolean;
9
+ supportsBugReportZStream: boolean;
8
10
  }
9
- export declare class BugReportZ extends AdbCommandBase {
11
+ export interface BugReportZOptions {
12
+ signal?: AbortSignal;
13
+ /**
14
+ * A callback that will be called when progress is updated.
15
+ *
16
+ * Specify `onProgress` when `supportsBugReportZProgress` is `false` will throw an error.
17
+ */
18
+ onProgress?: ((completed: string, total: string) => void) | undefined;
19
+ }
20
+ export declare class BugReport extends AdbCommandBase {
21
+ #private;
10
22
  static VERSION_REGEX: RegExp;
11
23
  static BEGIN_REGEX: RegExp;
12
24
  static PROGRESS_REGEX: RegExp;
13
25
  static OK_REGEX: RegExp;
14
26
  static FAIL_REGEX: RegExp;
15
27
  /**
16
- * Retrieve the version of bugreportz.
28
+ * Queries the device's bugreport capabilities.
29
+ */
30
+ static queryCapabilities(adb: Adb): Promise<BugReport>;
31
+ /**
32
+ * Gets whether the device supports flat (text file, non-zipped) bugreport.
33
+ *
34
+ * Should be `true` for Android version <= 11.
35
+ */
36
+ get supportsBugReport(): boolean;
37
+ /**
38
+ * Gets the version of BugReportZ.
39
+ *
40
+ * Will be `undefined` if BugReportZ is not supported.
41
+ */
42
+ get bugReportZVersion(): string | undefined;
43
+ /**
44
+ * Gets whether the device supports zipped bugreport.
45
+ *
46
+ * Should be `true` for Android version >= 7.
47
+ */
48
+ get supportsBugReportZ(): boolean;
49
+ /**
50
+ * Gets whether the device supports progress report for zipped bugreport.
17
51
  *
18
- * @returns a `BugReportVersion` object, or `undefined` if `bugreportz` is not available.
52
+ * Should be `true` for Android version >= 8.
19
53
  */
20
- version(): Promise<BugReportZVersion | undefined>;
21
- supportProgress(major: number, minor: number): boolean;
54
+ get supportsBugReportZProgress(): boolean;
22
55
  /**
23
- * Create a zipped bugreport file.
56
+ * Gets whether the device supports streaming zipped bugreport.
24
57
  *
25
- * Compare to `stream`, this method will write the output to a file on device.
58
+ * Should be `true` for Android version >= 12.
59
+ */
60
+ get supportsBugReportZStream(): boolean;
61
+ constructor(adb: Adb, capabilities: BugReportCapabilities);
62
+ /**
63
+ * Creates a legacy, non-zipped bugreport file, or throws an error if `supportsBugReport` is `false`.
64
+ *
65
+ * @returns A flat (text file, non-zipped) bugreport.
66
+ */
67
+ bugReport(): ReadableStream<Uint8Array>;
68
+ /**
69
+ * Creates a zipped bugreport file, or throws an error if `supportsBugReportZ` is `false`.
70
+ *
71
+ * Compare to `bugReportZStream`, this method will write the output to a file on device.
26
72
  * You can pull it later using sync protocol.
27
73
  *
28
- * @param onProgress Progress callback. Only specify this if `supportsProgress` is `true`.
29
- * @returns The path of the bugreport file.
74
+ * @returns The path to the generated bugreport file on device filesystem.
30
75
  */
31
- generate(onProgress?: (progress: string, total: string) => void): Promise<string>;
32
- supportStream(major: number, minor: number): boolean;
33
- stream(): ReadableStream<Uint8Array>;
34
- }
35
- export declare class BugReport extends AdbCommandBase {
36
- generate(): ReadableStream<Uint8Array>;
76
+ bugReportZ(options?: BugReportZOptions): Promise<string>;
77
+ /**
78
+ * Creates a zipped bugreport file, or throws an error if `supportsBugReportZStream` is `false`.
79
+ *
80
+ * @returns The content of the generated bugreport file.
81
+ */
82
+ bugReportZStream(): ReadableStream<Uint8Array>;
83
+ /**
84
+ * Automatically choose the best bugreport method.
85
+ *
86
+ * * If `supportsBugReportZStream` is `true`, this method will return a stream of zipped bugreport.
87
+ * * 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.
88
+ * * If `supportsBugReport` is `true`, this method will return a stream of flat bugreport.
89
+ *
90
+ * @param onProgress
91
+ * If `supportsBugReportZStream` is `false` and `supportsBugReportZProgress` is `true`,
92
+ * this callback will be called when progress is updated.
93
+ */
94
+ automatic(onProgress?: (completed: string, total: string) => void): {
95
+ type: "bugreport" | "bugreportz";
96
+ stream: ReadableStream<Uint8Array>;
97
+ };
37
98
  }
38
99
  //# sourceMappingURL=bug-report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bug-report.d.ts","sourceRoot":"","sources":["../src/bug-report.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAA8B,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAS9D,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,qBAAa,UAAW,SAAQ,cAAc;IAC1C,OAAc,aAAa,SAAkB;IAE7C,OAAc,WAAW,SAAgB;IAEzC,OAAc,cAAc,SAAyB;IAErD,OAAc,QAAQ,SAAa;IAEnC,OAAc,UAAU,SAAe;IAEvC;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA8BvD,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAI7D;;;;;;;;OAQG;IACU,QAAQ,CACjB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACvD,OAAO,CAAC,MAAM,CAAC;IAqDX,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAIpD,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC;CAgC9C;AAGD,qBAAa,SAAU,SAAQ,cAAc;IAClC,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC;CAMhD"}
1
+ {"version":3,"file":"bug-report.d.ts","sourceRoot":"","sources":["../src/bug-report.ts"],"names":[],"mappings":"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