@yume-chan/adb 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +57 -0
- package/CHANGELOG.md +26 -1
- package/README.md +222 -103
- package/esm/adb.d.ts +28 -45
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +34 -213
- package/esm/adb.js.map +1 -1
- package/esm/banner.d.ts +17 -0
- package/esm/banner.d.ts.map +1 -0
- package/esm/banner.js +67 -0
- package/esm/banner.js.map +1 -0
- package/esm/commands/base.d.ts.map +1 -1
- package/esm/commands/base.js.map +1 -1
- package/esm/commands/framebuffer.d.ts +9 -0
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +27 -3
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/power.d.ts +1 -1
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +2 -2
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +17 -18
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +53 -48
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +1 -1
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +15 -13
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/protocols/none.d.ts +3 -8
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +16 -16
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +3 -9
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +63 -57
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +1 -2
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/sync/list.js +2 -2
- package/esm/commands/sync/push.d.ts +14 -3
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +9 -9
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.js +2 -2
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +5 -3
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +7 -5
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +8 -14
- package/esm/commands/sync/socket.d.ts.map +1 -1
- package/esm/commands/sync/socket.js +35 -32
- package/esm/commands/sync/socket.js.map +1 -1
- package/esm/commands/sync/stat.js +4 -4
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +26 -18
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +36 -25
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +2 -2
- package/esm/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +4 -2
- package/esm/commands/tcpip.js.map +1 -1
- package/esm/{auth.d.ts → daemon/auth.d.ts} +12 -11
- package/esm/daemon/auth.d.ts.map +1 -0
- package/esm/{auth.js → daemon/auth.js} +31 -22
- package/esm/daemon/auth.js.map +1 -0
- package/esm/{crypto.d.ts → daemon/crypto.d.ts} +5 -5
- package/esm/daemon/crypto.d.ts.map +1 -0
- package/esm/{crypto.js → daemon/crypto.js} +24 -28
- package/esm/daemon/crypto.js.map +1 -0
- package/esm/{backend.d.ts → daemon/device.d.ts} +2 -2
- package/esm/daemon/device.d.ts.map +1 -0
- package/esm/daemon/device.js +2 -0
- package/esm/daemon/device.js.map +1 -0
- package/esm/{socket → daemon}/dispatcher.d.ts +12 -30
- package/esm/daemon/dispatcher.d.ts.map +1 -0
- package/esm/{socket → daemon}/dispatcher.js +80 -78
- package/esm/daemon/dispatcher.js.map +1 -0
- package/esm/daemon/index.d.ts +8 -0
- package/esm/daemon/index.d.ts.map +1 -0
- package/esm/daemon/index.js +8 -0
- package/esm/daemon/index.js.map +1 -0
- package/esm/{packet.d.ts → daemon/packet.d.ts} +4 -4
- package/esm/daemon/packet.d.ts.map +1 -0
- package/esm/{packet.js → daemon/packet.js} +2 -2
- package/esm/{packet.js.map → daemon/packet.js.map} +1 -1
- package/esm/{socket → daemon}/socket.d.ts +15 -19
- package/esm/daemon/socket.d.ts.map +1 -0
- package/esm/{socket → daemon}/socket.js +49 -42
- package/esm/daemon/socket.js.map +1 -0
- package/esm/daemon/transport.d.ts +53 -0
- package/esm/daemon/transport.d.ts.map +1 -0
- package/esm/daemon/transport.js +186 -0
- package/esm/daemon/transport.js.map +1 -0
- package/esm/features.js +1 -1
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +3 -5
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -5
- package/esm/index.js.map +1 -1
- package/esm/server/client.d.ts +78 -0
- package/esm/server/client.d.ts.map +1 -0
- package/esm/server/client.js +328 -0
- package/esm/server/client.js.map +1 -0
- package/esm/server/index.d.ts +3 -0
- package/esm/server/index.d.ts.map +1 -0
- package/esm/server/index.js +3 -0
- package/esm/server/index.js.map +1 -0
- package/esm/server/transport.d.ts +19 -0
- package/esm/server/transport.d.ts.map +1 -0
- package/esm/server/transport.js +44 -0
- package/esm/server/transport.js.map +1 -0
- package/esm/utils/auto-reset-event.d.ts +1 -2
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +12 -12
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.js +5 -5
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +1 -2
- package/esm/utils/conditional-variable.d.ts.map +1 -1
- package/esm/utils/conditional-variable.js +10 -10
- package/esm/utils/conditional-variable.js.map +1 -1
- package/esm/utils/hex.d.ts +3 -0
- package/esm/utils/hex.d.ts.map +1 -0
- package/esm/utils/hex.js +55 -0
- package/esm/utils/hex.js.map +1 -0
- package/esm/utils/index.d.ts +2 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +2 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/no-op.d.ts +7 -0
- package/esm/utils/no-op.d.ts.map +1 -0
- package/esm/utils/no-op.js +12 -0
- package/esm/utils/no-op.js.map +1 -0
- package/package.json +12 -12
- package/src/adb.ts +75 -274
- package/src/banner.ts +82 -0
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +31 -3
- package/src/commands/power.ts +10 -10
- package/src/commands/reverse.ts +77 -82
- package/src/commands/subprocess/command.ts +24 -25
- package/src/commands/subprocess/protocols/none.ts +29 -30
- package/src/commands/subprocess/protocols/shell.ts +87 -89
- package/src/commands/subprocess/protocols/types.ts +1 -2
- package/src/commands/sync/list.ts +7 -7
- package/src/commands/sync/pull.ts +4 -4
- package/src/commands/sync/push.ts +28 -16
- package/src/commands/sync/request.ts +4 -4
- package/src/commands/sync/response.ts +13 -11
- package/src/commands/sync/socket.ts +48 -46
- package/src/commands/sync/stat.ts +5 -5
- package/src/commands/sync/sync.ts +55 -43
- package/src/commands/tcpip.ts +6 -4
- package/src/{auth.ts → daemon/auth.ts} +62 -43
- package/src/{crypto.ts → daemon/crypto.ts} +33 -41
- package/src/{backend.ts → daemon/device.ts} +1 -1
- package/src/{socket → daemon}/dispatcher.ts +103 -109
- package/src/daemon/index.ts +7 -0
- package/src/{packet.ts → daemon/packet.ts} +6 -6
- package/src/{socket → daemon}/socket.ts +77 -67
- package/src/daemon/transport.ts +281 -0
- package/src/index.ts +3 -5
- package/src/server/client.ts +473 -0
- package/src/server/index.ts +2 -0
- package/src/server/transport.ts +77 -0
- package/src/utils/auto-reset-event.ts +16 -16
- package/src/utils/base64.ts +5 -5
- package/src/utils/conditional-variable.ts +14 -14
- package/src/utils/hex.ts +58 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/no-op.ts +12 -0
- package/tsconfig.build.json +12 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/esm/auth.d.ts.map +0 -1
- package/esm/auth.js.map +0 -1
- package/esm/backend.d.ts.map +0 -1
- package/esm/backend.js +0 -2
- package/esm/backend.js.map +0 -1
- package/esm/commands/install.d.ts +0 -10
- package/esm/commands/install.d.ts.map +0 -1
- package/esm/commands/install.js +0 -29
- package/esm/commands/install.js.map +0 -1
- package/esm/crypto.d.ts.map +0 -1
- package/esm/crypto.js.map +0 -1
- package/esm/packet.d.ts.map +0 -1
- package/esm/socket/dispatcher.d.ts.map +0 -1
- package/esm/socket/dispatcher.js.map +0 -1
- package/esm/socket/index.d.ts +0 -3
- package/esm/socket/index.d.ts.map +0 -1
- package/esm/socket/index.js +0 -3
- package/esm/socket/index.js.map +0 -1
- package/esm/socket/socket.d.ts.map +0 -1
- package/esm/socket/socket.js.map +0 -1
- package/src/socket/index.ts +0 -2
package/esm/adb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EACH,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,eAAe,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,SACb,SAAQ,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,EAC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AAG,OAAO,CAAC,SAAS,CAAC;IAIjD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQrC,EAAE,CACJ,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GACnD,OAAO,CAAC,MAAM,CAAC;IAqBZ,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAItC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
package/esm/adb.js
CHANGED
|
@@ -1,225 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AbortController, ConsumableWritableStream, DecodeUtf8Stream, GatherStringStream, WritableStream, } from "@yume-chan/stream-extra";
|
|
3
|
-
import { ADB_DEFAULT_AUTHENTICATORS, AdbAuthenticationProcessor, } from "./auth.js";
|
|
1
|
+
import { ConcatStringStream, DecodeUtf8Stream } from "@yume-chan/stream-extra";
|
|
4
2
|
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, } from "./commands/index.js";
|
|
5
|
-
import { AdbFeature } from "./features.js";
|
|
6
|
-
import { AdbCommand, calculateChecksum } from "./packet.js";
|
|
7
|
-
import { AdbPacketDispatcher } from "./socket/index.js";
|
|
8
|
-
import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
|
|
9
|
-
export var AdbPropKey;
|
|
10
|
-
(function (AdbPropKey) {
|
|
11
|
-
AdbPropKey["Product"] = "ro.product.name";
|
|
12
|
-
AdbPropKey["Model"] = "ro.product.model";
|
|
13
|
-
AdbPropKey["Device"] = "ro.product.device";
|
|
14
|
-
AdbPropKey["Features"] = "features";
|
|
15
|
-
})(AdbPropKey = AdbPropKey || (AdbPropKey = {}));
|
|
16
|
-
export const VERSION_OMIT_CHECKSUM = 0x01000001;
|
|
17
3
|
export class Adb {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* and starts a new authentication process.
|
|
22
|
-
*/
|
|
23
|
-
static async authenticate(connection, credentialStore, authenticators = ADB_DEFAULT_AUTHENTICATORS) {
|
|
24
|
-
// Initially, set to highest-supported version and payload size.
|
|
25
|
-
let version = 0x01000001;
|
|
26
|
-
// Android 4: 4K, Android 7: 256K, Android 9: 1M
|
|
27
|
-
let maxPayloadSize = 1024 * 1024;
|
|
28
|
-
const resolver = new PromiseResolver();
|
|
29
|
-
const authProcessor = new AdbAuthenticationProcessor(authenticators, credentialStore);
|
|
30
|
-
// Here is similar to `AdbPacketDispatcher`,
|
|
31
|
-
// But the received packet types and send packet processing are different.
|
|
32
|
-
const abortController = new AbortController();
|
|
33
|
-
const pipe = connection.readable
|
|
34
|
-
.pipeTo(new WritableStream({
|
|
35
|
-
async write(packet) {
|
|
36
|
-
switch (packet.command) {
|
|
37
|
-
case AdbCommand.Connect:
|
|
38
|
-
version = Math.min(version, packet.arg0);
|
|
39
|
-
maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
|
|
40
|
-
resolver.resolve(decodeUtf8(packet.payload));
|
|
41
|
-
break;
|
|
42
|
-
case AdbCommand.Auth: {
|
|
43
|
-
const response = await authProcessor.process(packet);
|
|
44
|
-
await sendPacket(response);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
default:
|
|
48
|
-
// Maybe the previous ADB client exited without reading all packets,
|
|
49
|
-
// so they are still waiting in OS internal buffer.
|
|
50
|
-
// Just ignore them.
|
|
51
|
-
// Because a `Connect` packet will reset the device,
|
|
52
|
-
// Eventually there will be `Connect` and `Auth` response packets.
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
}), {
|
|
57
|
-
// Don't cancel the source ReadableStream on AbortSignal abort.
|
|
58
|
-
preventCancel: true,
|
|
59
|
-
signal: abortController.signal,
|
|
60
|
-
})
|
|
61
|
-
.catch((e) => {
|
|
62
|
-
resolver.reject(e);
|
|
63
|
-
});
|
|
64
|
-
const writer = connection.writable.getWriter();
|
|
65
|
-
async function sendPacket(init) {
|
|
66
|
-
// Always send checksum in auth steps
|
|
67
|
-
// Because we don't know if the device needs it or not.
|
|
68
|
-
init.checksum = calculateChecksum(init.payload);
|
|
69
|
-
init.magic = init.command ^ 0xffffffff;
|
|
70
|
-
await ConsumableWritableStream.write(writer, init);
|
|
71
|
-
}
|
|
72
|
-
let banner;
|
|
73
|
-
try {
|
|
74
|
-
// https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
|
|
75
|
-
// There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
|
|
76
|
-
const features = [
|
|
77
|
-
AdbFeature.ShellV2,
|
|
78
|
-
AdbFeature.Cmd,
|
|
79
|
-
AdbFeature.StatV2,
|
|
80
|
-
AdbFeature.ListV2,
|
|
81
|
-
AdbFeature.FixedPushMkdir,
|
|
82
|
-
"apex",
|
|
83
|
-
AdbFeature.Abb,
|
|
84
|
-
// only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
|
|
85
|
-
// No special handling required.
|
|
86
|
-
"fixed_push_symlink_timestamp",
|
|
87
|
-
AdbFeature.AbbExec,
|
|
88
|
-
"remount_shell",
|
|
89
|
-
"track_app",
|
|
90
|
-
"sendrecv_v2",
|
|
91
|
-
"sendrecv_v2_brotli",
|
|
92
|
-
"sendrecv_v2_lz4",
|
|
93
|
-
"sendrecv_v2_zstd",
|
|
94
|
-
"sendrecv_v2_dry_run_send",
|
|
95
|
-
].join(",");
|
|
96
|
-
await sendPacket({
|
|
97
|
-
command: AdbCommand.Connect,
|
|
98
|
-
arg0: version,
|
|
99
|
-
arg1: maxPayloadSize,
|
|
100
|
-
// The terminating `;` is required in formal definition
|
|
101
|
-
// But ADB daemon (all versions) can still work without it
|
|
102
|
-
payload: encodeUtf8(`host::features=${features};`),
|
|
103
|
-
});
|
|
104
|
-
banner = await resolver.promise;
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
// When failed, release locks on `connection` so the caller can try again.
|
|
108
|
-
// When success, also release locks so `AdbPacketDispatcher` can use them.
|
|
109
|
-
abortController.abort();
|
|
110
|
-
writer.releaseLock();
|
|
111
|
-
// Wait until pipe stops (`ReadableStream` lock released)
|
|
112
|
-
await pipe;
|
|
113
|
-
}
|
|
114
|
-
return new Adb(connection, version, maxPayloadSize, banner);
|
|
115
|
-
}
|
|
116
|
-
dispatcher;
|
|
117
|
-
get disconnected() {
|
|
118
|
-
return this.dispatcher.disconnected;
|
|
119
|
-
}
|
|
120
|
-
_protocolVersion;
|
|
121
|
-
get protocolVersion() {
|
|
122
|
-
return this._protocolVersion;
|
|
4
|
+
transport;
|
|
5
|
+
get serial() {
|
|
6
|
+
return this.transport.serial;
|
|
123
7
|
}
|
|
124
|
-
_maxPayloadSize;
|
|
125
8
|
get maxPayloadSize() {
|
|
126
|
-
return this.
|
|
9
|
+
return this.transport.maxPayloadSize;
|
|
127
10
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return this._product;
|
|
11
|
+
get banner() {
|
|
12
|
+
return this.transport.banner;
|
|
131
13
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return this._model;
|
|
135
|
-
}
|
|
136
|
-
_device;
|
|
137
|
-
get device() {
|
|
138
|
-
return this._device;
|
|
139
|
-
}
|
|
140
|
-
_features = [];
|
|
141
|
-
get features() {
|
|
142
|
-
return this._features;
|
|
14
|
+
get disconnected() {
|
|
15
|
+
return this.transport.disconnected;
|
|
143
16
|
}
|
|
144
17
|
subprocess;
|
|
145
18
|
power;
|
|
146
19
|
reverse;
|
|
147
20
|
tcpip;
|
|
148
|
-
constructor(
|
|
149
|
-
this.
|
|
150
|
-
let calculateChecksum;
|
|
151
|
-
let appendNullToServiceString;
|
|
152
|
-
if (version >= VERSION_OMIT_CHECKSUM) {
|
|
153
|
-
calculateChecksum = false;
|
|
154
|
-
appendNullToServiceString = false;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
calculateChecksum = true;
|
|
158
|
-
appendNullToServiceString = true;
|
|
159
|
-
}
|
|
160
|
-
this.dispatcher = new AdbPacketDispatcher(connection, {
|
|
161
|
-
calculateChecksum,
|
|
162
|
-
appendNullToServiceString,
|
|
163
|
-
maxPayloadSize,
|
|
164
|
-
});
|
|
165
|
-
this._protocolVersion = version;
|
|
166
|
-
this._maxPayloadSize = maxPayloadSize;
|
|
21
|
+
constructor(transport) {
|
|
22
|
+
this.transport = transport;
|
|
167
23
|
this.subprocess = new AdbSubprocess(this);
|
|
168
24
|
this.power = new AdbPower(this);
|
|
169
25
|
this.reverse = new AdbReverseCommand(this);
|
|
170
26
|
this.tcpip = new AdbTcpIpCommand(this);
|
|
171
27
|
}
|
|
172
|
-
parseBanner(banner) {
|
|
173
|
-
const pieces = banner.split("::");
|
|
174
|
-
if (pieces.length > 1) {
|
|
175
|
-
const props = pieces[1];
|
|
176
|
-
for (const prop of props.split(";")) {
|
|
177
|
-
if (!prop) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
const keyValue = prop.split("=");
|
|
181
|
-
if (keyValue.length !== 2) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const [key, value] = keyValue;
|
|
185
|
-
switch (key) {
|
|
186
|
-
case AdbPropKey.Product:
|
|
187
|
-
this._product = value;
|
|
188
|
-
break;
|
|
189
|
-
case AdbPropKey.Model:
|
|
190
|
-
this._model = value;
|
|
191
|
-
break;
|
|
192
|
-
case AdbPropKey.Device:
|
|
193
|
-
this._device = value;
|
|
194
|
-
break;
|
|
195
|
-
case AdbPropKey.Features:
|
|
196
|
-
this._features = value.split(",");
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
28
|
supportsFeature(feature) {
|
|
203
|
-
return this.
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Add a handler for incoming socket.
|
|
207
|
-
* @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
|
|
208
|
-
* @returns A function to remove the handler.
|
|
209
|
-
*/
|
|
210
|
-
onIncomingSocket(handler) {
|
|
211
|
-
return this.dispatcher.onIncomingSocket(handler);
|
|
29
|
+
return this.banner.features.includes(feature);
|
|
212
30
|
}
|
|
213
31
|
async createSocket(service) {
|
|
214
|
-
return this.
|
|
32
|
+
return this.transport.connect(service);
|
|
215
33
|
}
|
|
216
34
|
async createSocketAndWait(service) {
|
|
217
35
|
const socket = await this.createSocket(service);
|
|
218
|
-
|
|
219
|
-
await socket.readable
|
|
36
|
+
return await socket.readable
|
|
220
37
|
.pipeThrough(new DecodeUtf8Stream())
|
|
221
|
-
.
|
|
222
|
-
return gatherStream.result;
|
|
38
|
+
.pipeThrough(new ConcatStringStream());
|
|
223
39
|
}
|
|
224
40
|
async getProp(key) {
|
|
225
41
|
const stdout = await this.subprocess.spawnAndWaitLegacy([
|
|
@@ -228,13 +44,25 @@ export class Adb {
|
|
|
228
44
|
]);
|
|
229
45
|
return stdout.trim();
|
|
230
46
|
}
|
|
231
|
-
async rm(
|
|
47
|
+
async rm(filenames, options) {
|
|
48
|
+
const args = ["rm"];
|
|
49
|
+
if (options?.recursive) {
|
|
50
|
+
args.push("-r");
|
|
51
|
+
}
|
|
52
|
+
if (options?.force) {
|
|
53
|
+
args.push("-f");
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(filenames)) {
|
|
56
|
+
for (const filename of filenames) {
|
|
57
|
+
args.push(escapeArg(filename));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
args.push(escapeArg(filenames));
|
|
62
|
+
}
|
|
232
63
|
// https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
...filenames.map((arg) => escapeArg(arg)),
|
|
236
|
-
"</dev/null",
|
|
237
|
-
]);
|
|
64
|
+
args.push("</dev/null");
|
|
65
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy(args);
|
|
238
66
|
return stdout;
|
|
239
67
|
}
|
|
240
68
|
async sync() {
|
|
@@ -244,15 +72,8 @@ export class Adb {
|
|
|
244
72
|
async framebuffer() {
|
|
245
73
|
return framebuffer(this);
|
|
246
74
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Close the ADB connection.
|
|
249
|
-
*
|
|
250
|
-
* Note that it won't close the streams from backends.
|
|
251
|
-
* The streams are both physically and logically intact,
|
|
252
|
-
* and can be reused.
|
|
253
|
-
*/
|
|
254
75
|
async close() {
|
|
255
|
-
await this.
|
|
76
|
+
await this.transport.close();
|
|
256
77
|
}
|
|
257
78
|
}
|
|
258
79
|
//# sourceMappingURL=adb.js.map
|
package/esm/adb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAK/E,OAAO,EACH,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,eAAe,EACf,SAAS,EACT,WAAW,GACd,MAAM,qBAAqB,CAAC;AAsC7B,MAAM,OAAO,GAAG;IACH,SAAS,CAAe;IAEjC,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC;IACzC,CAAC;IAED,IAAI,MAAM;QACN,OAA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B,CAAC;IAED,KAAK,CAAC,EAAE,CACJ,SAA4B,EAC5B,OAAkD;QAElD,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,OAAO,EAAE,SAAS,EAAE;YACpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;QACD,IAAI,OAAO,EAAE,KAAK,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACnB;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC1B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;gBAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;aAClC;SACJ;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;SACnC;QACD,uIAAuI;QACvI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,IAAI;QACN,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,WAAW;QACb,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,KAAK;QACP,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACJ"}
|
package/esm/banner.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AdbFeature } from "./features.js";
|
|
2
|
+
export declare enum AdbBannerKey {
|
|
3
|
+
Product = "ro.product.name",
|
|
4
|
+
Model = "ro.product.model",
|
|
5
|
+
Device = "ro.product.device",
|
|
6
|
+
Features = "features"
|
|
7
|
+
}
|
|
8
|
+
export declare class AdbBanner {
|
|
9
|
+
#private;
|
|
10
|
+
static parse(banner: string): AdbBanner;
|
|
11
|
+
get product(): string | undefined;
|
|
12
|
+
get model(): string | undefined;
|
|
13
|
+
get device(): string | undefined;
|
|
14
|
+
get features(): AdbFeature[];
|
|
15
|
+
constructor(product: string | undefined, model: string | undefined, device: string | undefined, features: AdbFeature[]);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=banner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../src/banner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,oBAAY,YAAY;IACpB,OAAO,oBAAoB;IAC3B,KAAK,qBAAqB;IAC1B,MAAM,sBAAsB;IAC5B,QAAQ,aAAa;CACxB;AAED,qBAAa,SAAS;;IAClB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IAyC3B,IAAI,OAAO,uBAEV;IAGD,IAAI,KAAK,uBAER;IAGD,IAAI,MAAM,uBAET;IAGD,IAAI,QAAQ,iBAEX;gBAGG,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,UAAU,EAAE;CAO7B"}
|
package/esm/banner.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export var AdbBannerKey;
|
|
2
|
+
(function (AdbBannerKey) {
|
|
3
|
+
AdbBannerKey["Product"] = "ro.product.name";
|
|
4
|
+
AdbBannerKey["Model"] = "ro.product.model";
|
|
5
|
+
AdbBannerKey["Device"] = "ro.product.device";
|
|
6
|
+
AdbBannerKey["Features"] = "features";
|
|
7
|
+
})(AdbBannerKey || (AdbBannerKey = {}));
|
|
8
|
+
export class AdbBanner {
|
|
9
|
+
static parse(banner) {
|
|
10
|
+
let product;
|
|
11
|
+
let model;
|
|
12
|
+
let device;
|
|
13
|
+
let features = [];
|
|
14
|
+
const pieces = banner.split("::");
|
|
15
|
+
if (pieces.length > 1) {
|
|
16
|
+
const props = pieces[1];
|
|
17
|
+
for (const prop of props.split(";")) {
|
|
18
|
+
if (!prop) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const keyValue = prop.split("=");
|
|
22
|
+
if (keyValue.length !== 2) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const [key, value] = keyValue;
|
|
26
|
+
switch (key) {
|
|
27
|
+
case AdbBannerKey.Product:
|
|
28
|
+
product = value;
|
|
29
|
+
break;
|
|
30
|
+
case AdbBannerKey.Model:
|
|
31
|
+
model = value;
|
|
32
|
+
break;
|
|
33
|
+
case AdbBannerKey.Device:
|
|
34
|
+
device = value;
|
|
35
|
+
break;
|
|
36
|
+
case AdbBannerKey.Features:
|
|
37
|
+
features = value.split(",");
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return new AdbBanner(product, model, device, features);
|
|
43
|
+
}
|
|
44
|
+
#product;
|
|
45
|
+
get product() {
|
|
46
|
+
return this.#product;
|
|
47
|
+
}
|
|
48
|
+
#model;
|
|
49
|
+
get model() {
|
|
50
|
+
return this.#model;
|
|
51
|
+
}
|
|
52
|
+
#device;
|
|
53
|
+
get device() {
|
|
54
|
+
return this.#device;
|
|
55
|
+
}
|
|
56
|
+
#features = [];
|
|
57
|
+
get features() {
|
|
58
|
+
return this.#features;
|
|
59
|
+
}
|
|
60
|
+
constructor(product, model, device, features) {
|
|
61
|
+
this.#product = product;
|
|
62
|
+
this.#model = model;
|
|
63
|
+
this.#device = device;
|
|
64
|
+
this.#features = features;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=banner.js.map
|
|
@@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KAAM,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAC;wBAC7C,MAAM;iBACb;aACJ;SACJ;QAED,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;IAED,QAAQ,CAAqB;IAC7B,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED,MAAM,CAAqB;IAC3B,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,OAAO,CAAqB;IAC5B,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,SAAS,GAAiB,EAAE,CAAC;IAC7B,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,YACI,OAA2B,EAC3B,KAAyB,EACzB,MAA0B,EAC1B,QAAsB;QAEtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,cAAe,SAAQ,cAAc;IAC9C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC,qBAAa,cAAe,SAAQ,cAAc;IAC9C,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;gBAEP,GAAG,EAAE,GAAG;CAIvB"}
|
package/esm/commands/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,OAAO,cAAe,SAAQ,cAAc;IACpC,GAAG,CAAM;IAEnB,
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,OAAO,cAAe,SAAQ,cAAc;IACpC,GAAG,CAAM;IAEnB,YAAY,GAAQ;QAChB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -50,5 +50,14 @@ export type AdbFrameBufferV2 = (typeof AdbFrameBufferV2)["TDeserializeResult"];
|
|
|
50
50
|
* But it doesn't mean that other combinations are not possible.
|
|
51
51
|
*/
|
|
52
52
|
export type AdbFrameBuffer = AdbFrameBufferV1 | AdbFrameBufferV2;
|
|
53
|
+
export declare class AdbFrameBufferError extends Error {
|
|
54
|
+
constructor(message: string, options?: ErrorOptions);
|
|
55
|
+
}
|
|
56
|
+
export declare class AdbFrameBufferUnsupportedVersionError extends AdbFrameBufferError {
|
|
57
|
+
constructor(version: number);
|
|
58
|
+
}
|
|
59
|
+
export declare class AdbFrameBufferForbiddenError extends AdbFrameBufferError {
|
|
60
|
+
constructor();
|
|
61
|
+
}
|
|
53
62
|
export declare function framebuffer(adb: Adb): Promise<AdbFrameBuffer>;
|
|
54
63
|
//# sourceMappingURL=framebuffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"framebuffer.d.ts","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AACA,OAAO,MAA4B,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAIrC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;2CAamB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;2CAcmB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,CAAC;AAE/E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEjE,qBAAa,mBAAoB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGtD;AAED,qBAAa,qCAAsC,SAAQ,mBAAmB;gBAC9D,OAAO,EAAE,MAAM;CAG9B;AAED,qBAAa,4BAA6B,SAAQ,mBAAmB;;CAIpE;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC,CAuBnE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferedReadableStream } from "@yume-chan/stream-extra";
|
|
2
|
-
import Struct from "@yume-chan/struct";
|
|
2
|
+
import Struct, { StructEmptyError } from "@yume-chan/struct";
|
|
3
3
|
const Version = new Struct({ littleEndian: true }).uint32("version");
|
|
4
4
|
export const AdbFrameBufferV1 = new Struct({ littleEndian: true })
|
|
5
5
|
.uint32("bpp")
|
|
@@ -30,10 +30,34 @@ export const AdbFrameBufferV2 = new Struct({ littleEndian: true })
|
|
|
30
30
|
.uint32("alpha_offset")
|
|
31
31
|
.uint32("alpha_length")
|
|
32
32
|
.uint8Array("data", { lengthField: "size" });
|
|
33
|
+
export class AdbFrameBufferError extends Error {
|
|
34
|
+
constructor(message, options) {
|
|
35
|
+
super(message, options);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class AdbFrameBufferUnsupportedVersionError extends AdbFrameBufferError {
|
|
39
|
+
constructor(version) {
|
|
40
|
+
super(`Unsupported FrameBuffer version ${version}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class AdbFrameBufferForbiddenError extends AdbFrameBufferError {
|
|
44
|
+
constructor() {
|
|
45
|
+
super("FrameBuffer is disabled by current app");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
33
48
|
export async function framebuffer(adb) {
|
|
34
49
|
const socket = await adb.createSocket("framebuffer:");
|
|
35
50
|
const stream = new BufferedReadableStream(socket.readable);
|
|
36
|
-
|
|
51
|
+
let version;
|
|
52
|
+
try {
|
|
53
|
+
({ version } = await Version.deserialize(stream));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (e instanceof StructEmptyError) {
|
|
57
|
+
throw new AdbFrameBufferForbiddenError();
|
|
58
|
+
}
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
37
61
|
switch (version) {
|
|
38
62
|
case 1:
|
|
39
63
|
// TODO: AdbFrameBuffer: does all v1 responses uses the same color space? Add it so the command returns same format for all versions.
|
|
@@ -41,7 +65,7 @@ export async function framebuffer(adb) {
|
|
|
41
65
|
case 2:
|
|
42
66
|
return AdbFrameBufferV2.deserialize(stream);
|
|
43
67
|
default:
|
|
44
|
-
throw new
|
|
68
|
+
throw new AdbFrameBufferUnsupportedVersionError(version);
|
|
45
69
|
}
|
|
46
70
|
}
|
|
47
71
|
//# sourceMappingURL=framebuffer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framebuffer.js","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,MAAM,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"framebuffer.js","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI7D,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7D,MAAM,CAAC,KAAK,CAAC;KACb,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,OAAO,CAAC;KACf,MAAM,CAAC,QAAQ,CAAC;KAChB,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,aAAa,CAAC;KACrB,MAAM,CAAC,aAAa,CAAC;KACrB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,MAAM,CAAC,cAAc,CAAC;KACtB,UAAU,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAIjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;KAC7D,MAAM,CAAC,KAAK,CAAC;KACb,MAAM,CAAC,YAAY,CAAC;KACpB,MAAM,CAAC,MAAM,CAAC;KACd,MAAM,CAAC,OAAO,CAAC;KACf,MAAM,CAAC,QAAQ,CAAC;K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AAW,CAAC,MAAM,CAAC,CAAC;QAChD,KAAK,CAAC;YACF,OAAO,gBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAChD;YACI,MAAM,IAAI,qCAAqC,CAAC,OAAO,CAAC,CAAC;KAChE;AACL,CAAC"}
|
package/esm/commands/power.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdbCommandBase } from "./base.js";
|
|
2
2
|
export declare class AdbPower extends AdbCommandBase {
|
|
3
|
-
reboot(
|
|
3
|
+
reboot(mode?: string): Promise<string>;
|
|
4
4
|
bootloader(): Promise<string>;
|
|
5
5
|
fastboot(): Promise<string>;
|
|
6
6
|
recovery(): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;
|
|
1
|
+
{"version":3,"file":"power.d.ts","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,qBAAa,QAAS,SAAQ,cAAc;IACxC,MAAM,CAAC,IAAI,SAAK;IAIhB,UAAU;IAIV,QAAQ;IAIR,QAAQ;IAIR,QAAQ;IAIR;;;;OAIG;IACH,eAAe;IAIf,QAAQ;IAIR,WAAW,CAAC,SAAS,UAAQ;IAQ7B;;;;OAIG;IACH,WAAW;CAGd"}
|
package/esm/commands/power.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// cspell: ignore longpress
|
|
5
5
|
import { AdbCommandBase } from "./base.js";
|
|
6
6
|
export class AdbPower extends AdbCommandBase {
|
|
7
|
-
reboot(
|
|
8
|
-
return this.adb.createSocketAndWait(`reboot:${
|
|
7
|
+
reboot(mode = "") {
|
|
8
|
+
return this.adb.createSocketAndWait(`reboot:${mode}`);
|
|
9
9
|
}
|
|
10
10
|
bootloader() {
|
|
11
11
|
return this.reboot("bootloader");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,0BAA0B;AAC1B,0BAA0B;AAC1B,2BAA2B;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,QAAS,SAAQ,cAAc;
|
|
1
|
+
{"version":3,"file":"power.js","sourceRoot":"","sources":["../../src/commands/power.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,0BAA0B;AAC1B,0BAA0B;AAC1B,2BAA2B;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,QAAS,SAAQ,cAAc;IACxC,MAAM,CAAC,IAAI,GAAG,EAAE;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,WAAW,CAAC,SAAS,GAAG,KAAK;QACzB,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC;YAC1C,OAAO;YACP,UAAU;YACV,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO;SAC5C,CAAC,CAAC;IACP,CAAC;IAED;;;;OAIG;IACH,WAAW;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AutoDisposable } from "@yume-chan/event";
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
2
|
+
import { BufferedReadableStream } from "@yume-chan/stream-extra";
|
|
3
|
+
import type { Adb, AdbIncomingSocketHandler } from "../adb.js";
|
|
4
4
|
export interface AdbForwardListener {
|
|
5
5
|
deviceSerial: string;
|
|
6
6
|
localName: string;
|
|
@@ -9,33 +9,32 @@ export interface AdbForwardListener {
|
|
|
9
9
|
export declare class AdbReverseError extends Error {
|
|
10
10
|
constructor(message: string);
|
|
11
11
|
}
|
|
12
|
-
export declare class AdbReverseNotSupportedError extends
|
|
12
|
+
export declare class AdbReverseNotSupportedError extends AdbReverseError {
|
|
13
13
|
constructor();
|
|
14
14
|
}
|
|
15
15
|
export declare class AdbReverseCommand extends AutoDisposable {
|
|
16
|
-
|
|
17
|
-
protected deviceAddressToLocalAddress: Map<string, string>;
|
|
16
|
+
#private;
|
|
18
17
|
protected adb: Adb;
|
|
19
|
-
protected listening: boolean;
|
|
20
18
|
constructor(adb: Adb);
|
|
21
|
-
protected
|
|
22
|
-
|
|
23
|
-
private sendRequest;
|
|
19
|
+
protected createBufferedStream(service: string): Promise<BufferedReadableStream>;
|
|
20
|
+
protected sendRequest(service: string): Promise<BufferedReadableStream>;
|
|
24
21
|
list(): Promise<AdbForwardListener[]>;
|
|
25
22
|
/**
|
|
26
|
-
*
|
|
27
|
-
* The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
|
|
28
|
-
* @param localAddress
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param
|
|
23
|
+
* Add an already existing reverse tunnel. Depends on the transport type, this may not do anything.
|
|
24
|
+
* @param deviceAddress The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
|
|
25
|
+
* @param localAddress The address that listens on the local machine.
|
|
26
|
+
* @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
|
|
27
|
+
*/
|
|
28
|
+
addExternal(deviceAddress: string, localAddress: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* @param deviceAddress The address to be listened on device by ADB daemon. Or `tcp:0` to choose an available TCP port.
|
|
31
|
+
* @param handler A callback to handle incoming connections.
|
|
32
|
+
* @param localAddressThe The address that listens on the local machine. May be `undefined` to let the transport choose an appropriate one.
|
|
34
33
|
* @returns `tcp:{ACTUAL_LISTENING_PORT}`, If `deviceAddress` is `tcp:0`; otherwise, `deviceAddress`.
|
|
35
34
|
* @throws {AdbReverseNotSupportedError} If ADB reverse tunnel is not supported on this device when connected wirelessly.
|
|
36
35
|
* @throws {AdbReverseError} If ADB daemon returns an error.
|
|
37
36
|
*/
|
|
38
|
-
add(deviceAddress: string,
|
|
37
|
+
add(deviceAddress: string, handler: AdbIncomingSocketHandler, localAddress?: string): Promise<string>;
|
|
39
38
|
remove(deviceAddress: string): Promise<void>;
|
|
40
39
|
removeAll(): Promise<void>;
|
|
41
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAG/D,MAAM,WAAW,kBAAkB;IAC/B,YAAY,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,MAAM,CAAC;IAElB,UAAU,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI9B;AAED,qBAAa,2BAA4B,SAAQ,eAAe;;CAM/D;AAoBD,qBAAa,iBAAkB,SAAQ,cAAc;;IACjD,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;gBAIP,GAAG,EAAE,GAAG;cAMJ,oBAAoB,CAAC,OAAO,EAAE,MAAM;cAKpC,WAAW,CAAC,OAAO,EAAE,MAAM;IASrC,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgB3C;;;;;OAKG;IACG,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IA8B7D;;;;;;;OAOG;IACG,GAAG,CACL,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,wBAAwB,EACjC,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC;IAgBZ,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAY5C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAQnC"}
|