@yume-chan/android-bin 2.0.1 → 3.0.0-beta.0
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/LICENSE +1 -1
- package/README.md +5 -2
- package/esm/am.d.ts +20 -15
- package/esm/am.d.ts.map +1 -1
- package/esm/am.js +60 -13
- package/esm/am.js.map +1 -1
- package/esm/bu.d.ts +22 -18
- package/esm/bu.d.ts.map +1 -1
- package/esm/bu.js +10 -4
- package/esm/bu.js.map +1 -1
- package/esm/bug-report.d.ts +21 -20
- package/esm/bug-report.d.ts.map +1 -1
- package/esm/bug-report.js +15 -21
- package/esm/bug-report.js.map +1 -1
- package/esm/cmd/index.d.ts +2 -0
- package/esm/cmd/index.d.ts.map +1 -0
- package/esm/cmd/index.js +2 -0
- package/esm/cmd/index.js.map +1 -0
- package/esm/cmd/none.d.ts +5 -0
- package/esm/cmd/none.d.ts.map +1 -0
- package/esm/cmd/none.js +39 -0
- package/esm/cmd/none.js.map +1 -0
- package/esm/cmd/service.d.ts +29 -0
- package/esm/cmd/service.d.ts.map +1 -0
- package/esm/cmd/service.js +24 -0
- package/esm/cmd/service.js.map +1 -0
- package/esm/cmd/shell.d.ts +5 -0
- package/esm/cmd/shell.d.ts.map +1 -0
- package/esm/cmd/shell.js +43 -0
- package/esm/cmd/shell.js.map +1 -0
- package/esm/cmd/utils.d.ts +5 -0
- package/esm/cmd/utils.d.ts.map +1 -0
- package/esm/cmd/utils.js +24 -0
- package/esm/cmd/utils.js.map +1 -0
- package/esm/demo-mode.d.ts +3 -4
- package/esm/demo-mode.d.ts.map +1 -1
- package/esm/demo-mode.js +13 -21
- package/esm/demo-mode.js.map +1 -1
- package/esm/dumpsys.d.ts +4 -2
- package/esm/dumpsys.d.ts.map +1 -1
- package/esm/dumpsys.js +13 -10
- package/esm/dumpsys.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/intent.d.ts +37 -9
- package/esm/intent.d.ts.map +1 -1
- package/esm/intent.js +116 -53
- package/esm/intent.js.map +1 -1
- package/esm/logcat.d.ts +8 -6
- package/esm/logcat.d.ts.map +1 -1
- package/esm/logcat.js +9 -6
- package/esm/logcat.js.map +1 -1
- package/esm/overlay-display.d.ts +17 -14
- package/esm/overlay-display.d.ts.map +1 -1
- package/esm/overlay-display.js +2 -4
- package/esm/overlay-display.js.map +1 -1
- package/esm/pm.d.ts +131 -168
- package/esm/pm.d.ts.map +1 -1
- package/esm/pm.js +229 -112
- package/esm/pm.js.map +1 -1
- package/esm/settings.d.ts +1 -2
- package/esm/settings.d.ts.map +1 -1
- package/esm/settings.js +9 -9
- package/esm/settings.js.map +1 -1
- package/esm/string-format.d.ts +2 -2
- package/esm/string-format.d.ts.map +1 -1
- package/esm/string-format.js.map +1 -1
- package/esm/utils.d.ts +4 -1
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +25 -14
- package/esm/utils.js.map +1 -1
- package/package.json +8 -8
- package/src/am.ts +94 -34
- package/src/bu.ts +31 -20
- package/src/bug-report.ts +42 -42
- package/src/cmd/index.ts +1 -0
- package/src/cmd/none.ts +62 -0
- package/src/cmd/service.ts +54 -0
- package/src/cmd/shell.ts +67 -0
- package/src/cmd/utils.ts +35 -0
- package/src/demo-mode.ts +13 -24
- package/src/dumpsys.ts +16 -10
- package/src/index.ts +1 -1
- package/src/intent.ts +187 -49
- package/src/logcat.ts +16 -10
- package/src/overlay-display.ts +21 -19
- package/src/pm.ts +375 -302
- package/src/settings.ts +11 -10
- package/src/string-format.ts +3 -3
- package/src/utils.ts +32 -15
- package/tsconfig.build.json +0 -11
- package/CHANGELOG.md +0 -171
- package/esm/cmd.d.ts +0 -23
- package/esm/cmd.d.ts.map +0 -1
- package/esm/cmd.js +0 -102
- package/esm/cmd.js.map +0 -1
- package/src/cmd.ts +0 -164
- package/tsconfig.build.tsbuildinfo +0 -1
package/src/settings.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Adb } from "@yume-chan/adb";
|
|
2
|
-
import { AdbServiceBase } from "@yume-chan/adb";
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { Cmd } from "./cmd/index.js";
|
|
5
4
|
import type { SingleUser } from "./utils.js";
|
|
6
5
|
|
|
7
6
|
export type SettingsNamespace = "system" | "secure" | "global";
|
|
@@ -25,15 +24,14 @@ export interface SettingsPutOptions extends SettingsOptions {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsService.java
|
|
28
|
-
export class Settings
|
|
27
|
+
export class Settings {
|
|
29
28
|
static ServiceName = "settings";
|
|
30
29
|
static CommandName = "settings";
|
|
31
30
|
|
|
32
|
-
#cmd:
|
|
31
|
+
readonly #cmd: Cmd.NoneProtocolService;
|
|
33
32
|
|
|
34
33
|
constructor(adb: Adb) {
|
|
35
|
-
|
|
36
|
-
this.#cmd = new CmdNoneProtocolService(adb, Settings.CommandName);
|
|
34
|
+
this.#cmd = Cmd.createNoneProtocol(adb, Settings.CommandName);
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
base(
|
|
@@ -42,16 +40,19 @@ export class Settings extends AdbServiceBase {
|
|
|
42
40
|
options: SettingsOptions | undefined,
|
|
43
41
|
...args: string[]
|
|
44
42
|
): Promise<string> {
|
|
45
|
-
|
|
43
|
+
const command = [Settings.ServiceName];
|
|
46
44
|
|
|
47
45
|
if (options?.user !== undefined) {
|
|
48
46
|
command.push("--user", options.user.toString());
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
command.push(verb, namespace);
|
|
52
|
-
command = command.concat(args);
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
for (const arg of args) {
|
|
52
|
+
command.push(arg);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return this.#cmd.spawn(command).wait().toString();
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
async get(
|
|
@@ -61,7 +62,7 @@ export class Settings extends AdbServiceBase {
|
|
|
61
62
|
): Promise<string> {
|
|
62
63
|
const output = await this.base("get", namespace, options, key);
|
|
63
64
|
// Remove last \n
|
|
64
|
-
return output.
|
|
65
|
+
return output.endsWith("\n") ? output.slice(0, -1) : output;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
async delete(
|
package/src/string-format.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export class ParseError extends Error {
|
|
2
|
-
#expected: string[];
|
|
2
|
+
#expected: readonly string[];
|
|
3
3
|
|
|
4
|
-
get expected(): string[] {
|
|
4
|
+
get expected(): readonly string[] {
|
|
5
5
|
return this.#expected;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
constructor(expected: string[]) {
|
|
8
|
+
constructor(expected: readonly string[]) {
|
|
9
9
|
super(`Expected ${expected.join(", ")}`);
|
|
10
10
|
this.#expected = expected;
|
|
11
11
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
|
-
export function
|
|
2
|
-
commands: string[],
|
|
1
|
+
export function buildCommand<T>(
|
|
2
|
+
commands: readonly string[],
|
|
3
3
|
options: Partial<T> | undefined,
|
|
4
4
|
map: Partial<Record<keyof T, string>>,
|
|
5
5
|
): string[] {
|
|
6
|
-
const args = commands;
|
|
6
|
+
const args = commands.slice();
|
|
7
7
|
if (options) {
|
|
8
8
|
for (const [key, value] of Object.entries(options)) {
|
|
9
|
-
if (value) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
if (value === undefined || value === null) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const option = map[key as keyof T];
|
|
14
|
+
// Empty string means positional argument,
|
|
15
|
+
// they must be added at the end,
|
|
16
|
+
// so let the caller handle it.
|
|
17
|
+
if (option === undefined || option === "") {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
switch (typeof value) {
|
|
22
|
+
case "boolean":
|
|
23
|
+
if (value) {
|
|
24
|
+
args.push(option);
|
|
20
25
|
}
|
|
21
|
-
|
|
26
|
+
break;
|
|
27
|
+
case "number":
|
|
28
|
+
args.push(option, value.toString());
|
|
29
|
+
break;
|
|
30
|
+
case "string":
|
|
31
|
+
args.push(option, value);
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Unsupported type for option ${key}: ${typeof value}`,
|
|
36
|
+
);
|
|
22
37
|
}
|
|
23
38
|
}
|
|
24
39
|
}
|
|
@@ -27,3 +42,5 @@ export function buildArguments<T>(
|
|
|
27
42
|
|
|
28
43
|
export type SingleUser = number | "current";
|
|
29
44
|
export type SingleUserOrAll = SingleUser | "all";
|
|
45
|
+
|
|
46
|
+
export type Optional<T extends object> = { [K in keyof T]?: T[K] | undefined };
|
package/tsconfig.build.json
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./node_modules/@yume-chan/tsconfig/tsconfig.base.json",
|
|
3
|
-
"references": [
|
|
4
|
-
{
|
|
5
|
-
"path": "../adb/tsconfig.build.json"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"path": "../stream-extra/tsconfig.build.json"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"path": "../struct/tsconfig.build.json"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
3
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# Change Log - @yume-chan/android-bin
|
|
2
|
-
|
|
3
|
-
## 2.0.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [0bcb9b8]
|
|
8
|
-
- @yume-chan/struct@2.0.1
|
|
9
|
-
- @yume-chan/adb@2.0.1
|
|
10
|
-
- @yume-chan/stream-extra@2.0.1
|
|
11
|
-
|
|
12
|
-
## 2.0.0
|
|
13
|
-
|
|
14
|
-
### Major Changes
|
|
15
|
-
|
|
16
|
-
- Redesign subprocess API
|
|
17
|
-
|
|
18
|
-
### Minor Changes
|
|
19
|
-
|
|
20
|
-
- 0f29501: Add `PackageManager.prototype.getPackages` method to get apk paths
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- Updated dependencies
|
|
25
|
-
- Updated dependencies [05c01ad]
|
|
26
|
-
- Updated dependencies [b79df96]
|
|
27
|
-
- @yume-chan/adb@2.0.0
|
|
28
|
-
- @yume-chan/struct@2.0.0
|
|
29
|
-
- @yume-chan/stream-extra@2.0.0
|
|
30
|
-
|
|
31
|
-
## 1.1.0
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- Updated dependencies [ab98953]
|
|
36
|
-
- @yume-chan/adb@1.1.0
|
|
37
|
-
|
|
38
|
-
## 1.0.1
|
|
39
|
-
|
|
40
|
-
### Patch Changes
|
|
41
|
-
|
|
42
|
-
- 53688d3: Use PNPM workspace and Changesets to manage the monorepo.
|
|
43
|
-
|
|
44
|
-
Because Changesets doesn't support alpha versions (`0.x.x`), this version is `1.0.0`. Future versions will follow SemVer rules, for example, breaking API changes will introduce a new major version.
|
|
45
|
-
|
|
46
|
-
- Updated dependencies [53688d3]
|
|
47
|
-
- Updated dependencies [db8466f]
|
|
48
|
-
- Updated dependencies [db8466f]
|
|
49
|
-
- Updated dependencies [ea5002b]
|
|
50
|
-
- Updated dependencies [db8466f]
|
|
51
|
-
- @yume-chan/stream-extra@1.0.1
|
|
52
|
-
- @yume-chan/struct@1.0.1
|
|
53
|
-
- @yume-chan/adb@1.0.1
|
|
54
|
-
|
|
55
|
-
This log was last generated on Tue, 18 Jun 2024 02:49:43 GMT and should not be manually modified.
|
|
56
|
-
|
|
57
|
-
## 0.0.24
|
|
58
|
-
|
|
59
|
-
Tue, 18 Jun 2024 02:49:43 GMT
|
|
60
|
-
|
|
61
|
-
### Updates
|
|
62
|
-
|
|
63
|
-
- Allow streams to accept both `Uint8Array` and `Consumable<Uint8Array>` as inputs
|
|
64
|
-
- Add all supported fields to `DumpSys.Battery.Info`
|
|
65
|
-
|
|
66
|
-
## 0.0.23
|
|
67
|
-
|
|
68
|
-
Thu, 21 Mar 2024 03:15:10 GMT
|
|
69
|
-
|
|
70
|
-
### Updates
|
|
71
|
-
|
|
72
|
-
- Add support for pm install session
|
|
73
|
-
|
|
74
|
-
## 0.0.22
|
|
75
|
-
|
|
76
|
-
Wed, 13 Dec 2023 05:57:27 GMT
|
|
77
|
-
|
|
78
|
-
### Updates
|
|
79
|
-
|
|
80
|
-
- Add wrapper for `pm uninstall`
|
|
81
|
-
- Change `PackageManager#listPackages` to return an async generator
|
|
82
|
-
- Add wrapper for `am start`
|
|
83
|
-
- Add wrapper for `pm resolve-activity`
|
|
84
|
-
- Add `status` and `health` fields to `DumpSys#battery`
|
|
85
|
-
|
|
86
|
-
## 0.0.21
|
|
87
|
-
|
|
88
|
-
Fri, 25 Aug 2023 14:05:18 GMT
|
|
89
|
-
|
|
90
|
-
### Updates
|
|
91
|
-
|
|
92
|
-
- Add wrapper for `bu`
|
|
93
|
-
- Remove the last `\n` from `Settings#get`
|
|
94
|
-
- Add wrappers for `dumpsys diskstats` and `dumpsys battery`
|
|
95
|
-
- Add wrapper for `pm list packages`
|
|
96
|
-
- Rewrite `Settings` to use `Cmd` if available
|
|
97
|
-
- Add support to stop `bugreport`
|
|
98
|
-
- Merge `bugreport` and `bugreportz` wrappers, providing an `automatic` method to choose the best available bugreport method
|
|
99
|
-
|
|
100
|
-
## 0.0.20
|
|
101
|
-
|
|
102
|
-
Mon, 05 Jun 2023 02:51:41 GMT
|
|
103
|
-
|
|
104
|
-
_Version update only_
|
|
105
|
-
|
|
106
|
-
## 0.0.19
|
|
107
|
-
|
|
108
|
-
Sun, 09 Apr 2023 05:55:33 GMT
|
|
109
|
-
|
|
110
|
-
### Updates
|
|
111
|
-
|
|
112
|
-
- Add wrapper for `cmd`, with support for Android Binder Bridge (abb)
|
|
113
|
-
- Add `OverlayDisplay` wrapper for managing overlay displays
|
|
114
|
-
|
|
115
|
-
## 0.0.18
|
|
116
|
-
|
|
117
|
-
Wed, 25 Jan 2023 21:33:49 GMT
|
|
118
|
-
|
|
119
|
-
_Version update only_
|
|
120
|
-
|
|
121
|
-
## 0.0.17
|
|
122
|
-
|
|
123
|
-
Tue, 18 Oct 2022 09:32:30 GMT
|
|
124
|
-
|
|
125
|
-
### Updates
|
|
126
|
-
|
|
127
|
-
- Update to use new stream util package
|
|
128
|
-
|
|
129
|
-
## 0.0.16
|
|
130
|
-
|
|
131
|
-
Sat, 28 May 2022 03:56:37 GMT
|
|
132
|
-
|
|
133
|
-
### Updates
|
|
134
|
-
|
|
135
|
-
- Upgrade TypeScript to 4.7.2 to enable Node.js ESM
|
|
136
|
-
- Improve performance of `Logcat#binary()` by up to 150%
|
|
137
|
-
|
|
138
|
-
## 0.0.15
|
|
139
|
-
|
|
140
|
-
Mon, 02 May 2022 04:18:01 GMT
|
|
141
|
-
|
|
142
|
-
_Version update only_
|
|
143
|
-
|
|
144
|
-
## 0.0.14
|
|
145
|
-
|
|
146
|
-
Sat, 30 Apr 2022 14:05:48 GMT
|
|
147
|
-
|
|
148
|
-
_Version update only_
|
|
149
|
-
|
|
150
|
-
## 0.0.13
|
|
151
|
-
|
|
152
|
-
Thu, 28 Apr 2022 01:23:53 GMT
|
|
153
|
-
|
|
154
|
-
### Updates
|
|
155
|
-
|
|
156
|
-
- Add support for bugreport/bugreportz
|
|
157
|
-
- Add basic support for logcat
|
|
158
|
-
|
|
159
|
-
## 0.0.12
|
|
160
|
-
|
|
161
|
-
Sun, 03 Apr 2022 11:18:47 GMT
|
|
162
|
-
|
|
163
|
-
_Version update only_
|
|
164
|
-
|
|
165
|
-
## 0.0.11
|
|
166
|
-
|
|
167
|
-
Sun, 03 Apr 2022 10:54:15 GMT
|
|
168
|
-
|
|
169
|
-
### Updates
|
|
170
|
-
|
|
171
|
-
- Improve compatibility with Node.js 12 ESM format
|
package/esm/cmd.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Adb } from "@yume-chan/adb";
|
|
2
|
-
import { AdbNoneProtocolSpawner, AdbServiceBase, AdbShellProtocolSpawner } from "@yume-chan/adb";
|
|
3
|
-
export declare class CmdNoneProtocolService extends AdbNoneProtocolSpawner {
|
|
4
|
-
#private;
|
|
5
|
-
get supportsAbbExec(): boolean;
|
|
6
|
-
get supportsCmd(): boolean;
|
|
7
|
-
get isSupported(): boolean;
|
|
8
|
-
constructor(adb: Adb, fallback?: string | Record<string, string> | ((service: string) => string));
|
|
9
|
-
}
|
|
10
|
-
export declare class CmdShellProtocolService extends AdbShellProtocolSpawner {
|
|
11
|
-
#private;
|
|
12
|
-
get supportsCmd(): boolean;
|
|
13
|
-
get supportsAbb(): boolean;
|
|
14
|
-
get isSupported(): boolean;
|
|
15
|
-
constructor(adb: Adb, fallback?: string | Record<string, string> | ((service: string) => string));
|
|
16
|
-
}
|
|
17
|
-
export declare class Cmd extends AdbServiceBase {
|
|
18
|
-
#private;
|
|
19
|
-
get noneProtocol(): CmdNoneProtocolService | undefined;
|
|
20
|
-
get shellProtocol(): CmdShellProtocolService | undefined;
|
|
21
|
-
constructor(adb: Adb, fallback?: string | Record<string, string> | ((service: string) => string));
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=cmd.d.ts.map
|
package/esm/cmd.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.d.ts","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAGH,sBAAsB,EACtB,cAAc,EAEd,uBAAuB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,qBAAa,sBAAuB,SAAQ,sBAAsB;;IAE9D,IAAI,eAAe,IAAI,OAAO,CAE7B;IAGD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,WAAW,YAEd;gBAGG,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EACH,MAAM,GACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAgC1C;AAED,qBAAa,uBAAwB,SAAQ,uBAAuB;;IAIhE,IAAI,WAAW,IAAI,OAAO,CAEzB;IAGD,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,IAAI,WAAW,YAKd;gBAGG,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EACH,MAAM,GACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAqC1C;AAED,qBAAa,GAAI,SAAQ,cAAc;;IAEnC,IAAI,YAAY,uCAEf;IAGD,IAAI,aAAa,wCAEhB;gBAGG,GAAG,EAAE,GAAG,EACR,QAAQ,CAAC,EACH,MAAM,GACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAmB1C"}
|
package/esm/cmd.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { AdbFeature, AdbNoneProtocolProcessImpl, AdbNoneProtocolSpawner, AdbServiceBase, AdbShellProtocolProcessImpl, AdbShellProtocolSpawner, } from "@yume-chan/adb";
|
|
2
|
-
export class CmdNoneProtocolService extends AdbNoneProtocolSpawner {
|
|
3
|
-
#supportsAbbExec;
|
|
4
|
-
get supportsAbbExec() {
|
|
5
|
-
return this.#supportsAbbExec;
|
|
6
|
-
}
|
|
7
|
-
#supportsCmd;
|
|
8
|
-
get supportsCmd() {
|
|
9
|
-
return this.#supportsCmd;
|
|
10
|
-
}
|
|
11
|
-
get isSupported() {
|
|
12
|
-
return this.#supportsAbbExec || this.#supportsCmd;
|
|
13
|
-
}
|
|
14
|
-
constructor(adb, fallback) {
|
|
15
|
-
super(async (command) => {
|
|
16
|
-
if (this.#supportsAbbExec) {
|
|
17
|
-
return new AdbNoneProtocolProcessImpl(await adb.createSocket(`abb_exec:${command.join("\0")}\0`));
|
|
18
|
-
}
|
|
19
|
-
if (this.#supportsCmd) {
|
|
20
|
-
return adb.subprocess.noneProtocol.spawn(`cmd ${command.join(" ")}`);
|
|
21
|
-
}
|
|
22
|
-
if (typeof fallback === "function") {
|
|
23
|
-
fallback = fallback(command[0]);
|
|
24
|
-
}
|
|
25
|
-
else if (typeof fallback === "object") {
|
|
26
|
-
fallback = fallback[command[0]];
|
|
27
|
-
}
|
|
28
|
-
if (!fallback) {
|
|
29
|
-
throw new Error("Unsupported");
|
|
30
|
-
}
|
|
31
|
-
command[0] = fallback;
|
|
32
|
-
return adb.subprocess.noneProtocol.spawn(command);
|
|
33
|
-
});
|
|
34
|
-
this.#supportsCmd = adb.canUseFeature(AdbFeature.Cmd);
|
|
35
|
-
this.#supportsAbbExec = adb.canUseFeature(AdbFeature.AbbExec);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export class CmdShellProtocolService extends AdbShellProtocolSpawner {
|
|
39
|
-
#adb;
|
|
40
|
-
#supportsCmd;
|
|
41
|
-
get supportsCmd() {
|
|
42
|
-
return this.#supportsCmd;
|
|
43
|
-
}
|
|
44
|
-
#supportsAbb;
|
|
45
|
-
get supportsAbb() {
|
|
46
|
-
return this.#supportsAbb;
|
|
47
|
-
}
|
|
48
|
-
get isSupported() {
|
|
49
|
-
return (this.#supportsAbb ||
|
|
50
|
-
(this.#supportsCmd && !!this.#adb.subprocess.shellProtocol));
|
|
51
|
-
}
|
|
52
|
-
constructor(adb, fallback) {
|
|
53
|
-
super(async (command) => {
|
|
54
|
-
if (this.#supportsAbb) {
|
|
55
|
-
return new AdbShellProtocolProcessImpl(await this.#adb.createSocket(`abb:${command.join("\0")}\0`));
|
|
56
|
-
}
|
|
57
|
-
if (!adb.subprocess.shellProtocol) {
|
|
58
|
-
throw new Error("Unsupported");
|
|
59
|
-
}
|
|
60
|
-
if (this.#supportsCmd) {
|
|
61
|
-
return adb.subprocess.shellProtocol.spawn(`cmd ${command.join(" ")}`);
|
|
62
|
-
}
|
|
63
|
-
if (typeof fallback === "function") {
|
|
64
|
-
fallback = fallback(command[0]);
|
|
65
|
-
}
|
|
66
|
-
else if (typeof fallback === "object") {
|
|
67
|
-
fallback = fallback[command[0]];
|
|
68
|
-
}
|
|
69
|
-
if (!fallback) {
|
|
70
|
-
throw new Error("Unsupported");
|
|
71
|
-
}
|
|
72
|
-
command[0] = fallback;
|
|
73
|
-
return adb.subprocess.shellProtocol.spawn(command);
|
|
74
|
-
});
|
|
75
|
-
this.#adb = adb;
|
|
76
|
-
this.#supportsCmd = adb.canUseFeature(AdbFeature.Cmd);
|
|
77
|
-
this.#supportsAbb = adb.canUseFeature(AdbFeature.Abb);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
export class Cmd extends AdbServiceBase {
|
|
81
|
-
#noneProtocol;
|
|
82
|
-
get noneProtocol() {
|
|
83
|
-
return this.#noneProtocol;
|
|
84
|
-
}
|
|
85
|
-
#shellProtocol;
|
|
86
|
-
get shellProtocol() {
|
|
87
|
-
return this.#shellProtocol;
|
|
88
|
-
}
|
|
89
|
-
constructor(adb, fallback) {
|
|
90
|
-
super(adb);
|
|
91
|
-
if (adb.canUseFeature(AdbFeature.AbbExec) ||
|
|
92
|
-
adb.canUseFeature(AdbFeature.Cmd)) {
|
|
93
|
-
this.#noneProtocol = new CmdNoneProtocolService(adb, fallback);
|
|
94
|
-
}
|
|
95
|
-
if (adb.canUseFeature(AdbFeature.Abb) ||
|
|
96
|
-
(adb.canUseFeature(AdbFeature.Cmd) &&
|
|
97
|
-
adb.canUseFeature(AdbFeature.ShellV2))) {
|
|
98
|
-
this.#shellProtocol = new CmdShellProtocolService(adb, fallback);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=cmd.js.map
|
package/esm/cmd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cmd.js","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":"AACA,OAAO,EACH,UAAU,EACV,0BAA0B,EAC1B,sBAAsB,EACtB,cAAc,EACd,2BAA2B,EAC3B,uBAAuB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,sBAAuB,SAAQ,sBAAsB;IAC9D,gBAAgB,CAAU;IAC1B,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,gBAAgB,CAAC;IACjC,CAAC;IAED,YAAY,CAAU;IACtB,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,YAAY,CAAC;IACtD,CAAC;IAED,YACI,GAAQ,EACR,QAGmC;QAEnC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACpB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACxB,OAAO,IAAI,0BAA0B,CACjC,MAAM,GAAG,CAAC,YAAY,CAAC,YAAY,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7D,CAAC;YACN,CAAC;YAED,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpB,OAAO,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CACpC,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAC7B,CAAC;YACN,CAAC;YAED,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;gBACjC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,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O,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,YACI,GAAQ,EACR,QAGmC;QAEnC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEX,IACI,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC;YACrC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,EACnC,CAAC;YACC,IAAI,CAAC,aAAa,GAAG,IAAI,sBAAsB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnE,CAAC;QAED,IACI,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC;YACjC,CAAC,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC;gBAC9B,GAAG,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAC5C,CAAC;YACC,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAuB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrE,CAAC;IACL,CAAC;CACJ"}
|
package/src/cmd.ts
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import type { Adb, AdbShellProtocolProcess } from "@yume-chan/adb";
|
|
2
|
-
import {
|
|
3
|
-
AdbFeature,
|
|
4
|
-
AdbNoneProtocolProcessImpl,
|
|
5
|
-
AdbNoneProtocolSpawner,
|
|
6
|
-
AdbServiceBase,
|
|
7
|
-
AdbShellProtocolProcessImpl,
|
|
8
|
-
AdbShellProtocolSpawner,
|
|
9
|
-
} from "@yume-chan/adb";
|
|
10
|
-
|
|
11
|
-
export class CmdNoneProtocolService extends AdbNoneProtocolSpawner {
|
|
12
|
-
#supportsAbbExec: boolean;
|
|
13
|
-
get supportsAbbExec(): boolean {
|
|
14
|
-
return this.#supportsAbbExec;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
#supportsCmd: boolean;
|
|
18
|
-
get supportsCmd(): boolean {
|
|
19
|
-
return this.#supportsCmd;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get isSupported() {
|
|
23
|
-
return this.#supportsAbbExec || this.#supportsCmd;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
adb: Adb,
|
|
28
|
-
fallback?:
|
|
29
|
-
| string
|
|
30
|
-
| Record<string, string>
|
|
31
|
-
| ((service: string) => string),
|
|
32
|
-
) {
|
|
33
|
-
super(async (command) => {
|
|
34
|
-
if (this.#supportsAbbExec) {
|
|
35
|
-
return new AdbNoneProtocolProcessImpl(
|
|
36
|
-
await adb.createSocket(`abb_exec:${command.join("\0")}\0`),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (this.#supportsCmd) {
|
|
41
|
-
return adb.subprocess.noneProtocol.spawn(
|
|
42
|
-
`cmd ${command.join(" ")}`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (typeof fallback === "function") {
|
|
47
|
-
fallback = fallback(command[0]!);
|
|
48
|
-
} else if (typeof fallback === "object") {
|
|
49
|
-
fallback = fallback[command[0]!];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!fallback) {
|
|
53
|
-
throw new Error("Unsupported");
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
command[0] = fallback;
|
|
57
|
-
return adb.subprocess.noneProtocol.spawn(command);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
this.#supportsCmd = adb.canUseFeature(AdbFeature.Cmd);
|
|
61
|
-
this.#supportsAbbExec = adb.canUseFeature(AdbFeature.AbbExec);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export class CmdShellProtocolService extends AdbShellProtocolSpawner {
|
|
66
|
-
#adb: Adb;
|
|
67
|
-
|
|
68
|
-
#supportsCmd: boolean;
|
|
69
|
-
get supportsCmd(): boolean {
|
|
70
|
-
return this.#supportsCmd;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
#supportsAbb: boolean;
|
|
74
|
-
get supportsAbb(): boolean {
|
|
75
|
-
return this.#supportsAbb;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
get isSupported() {
|
|
79
|
-
return (
|
|
80
|
-
this.#supportsAbb ||
|
|
81
|
-
(this.#supportsCmd && !!this.#adb.subprocess.shellProtocol)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
constructor(
|
|
86
|
-
adb: Adb,
|
|
87
|
-
fallback?:
|
|
88
|
-
| string
|
|
89
|
-
| Record<string, string>
|
|
90
|
-
| ((service: string) => string),
|
|
91
|
-
) {
|
|
92
|
-
super(async (command): Promise<AdbShellProtocolProcess> => {
|
|
93
|
-
if (this.#supportsAbb) {
|
|
94
|
-
return new AdbShellProtocolProcessImpl(
|
|
95
|
-
await this.#adb.createSocket(`abb:${command.join("\0")}\0`),
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!adb.subprocess.shellProtocol) {
|
|
100
|
-
throw new Error("Unsupported");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (this.#supportsCmd) {
|
|
104
|
-
return adb.subprocess.shellProtocol.spawn(
|
|
105
|
-
`cmd ${command.join(" ")}`,
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (typeof fallback === "function") {
|
|
110
|
-
fallback = fallback(command[0]!);
|
|
111
|
-
} else if (typeof fallback === "object") {
|
|
112
|
-
fallback = fallback[command[0]!];
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (!fallback) {
|
|
116
|
-
throw new Error("Unsupported");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
command[0] = fallback;
|
|
120
|
-
return adb.subprocess.shellProtocol.spawn(command);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
this.#adb = adb;
|
|
124
|
-
this.#supportsCmd = adb.canUseFeature(AdbFeature.Cmd);
|
|
125
|
-
this.#supportsAbb = adb.canUseFeature(AdbFeature.Abb);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export class Cmd extends AdbServiceBase {
|
|
130
|
-
#noneProtocol: CmdNoneProtocolService | undefined;
|
|
131
|
-
get noneProtocol() {
|
|
132
|
-
return this.#noneProtocol;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
#shellProtocol: CmdShellProtocolService | undefined;
|
|
136
|
-
get shellProtocol() {
|
|
137
|
-
return this.#shellProtocol;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
constructor(
|
|
141
|
-
adb: Adb,
|
|
142
|
-
fallback?:
|
|
143
|
-
| string
|
|
144
|
-
| Record<string, string>
|
|
145
|
-
| ((service: string) => string),
|
|
146
|
-
) {
|
|
147
|
-
super(adb);
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
adb.canUseFeature(AdbFeature.AbbExec) ||
|
|
151
|
-
adb.canUseFeature(AdbFeature.Cmd)
|
|
152
|
-
) {
|
|
153
|
-
this.#noneProtocol = new CmdNoneProtocolService(adb, fallback);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
adb.canUseFeature(AdbFeature.Abb) ||
|
|
158
|
-
(adb.canUseFeature(AdbFeature.Cmd) &&
|
|
159
|
-
adb.canUseFeature(AdbFeature.ShellV2))
|
|
160
|
-
) {
|
|
161
|
-
this.#shellProtocol = new CmdShellProtocolService(adb, fallback);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|