@yume-chan/adb 0.0.10 → 0.0.11
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 +26 -0
- package/CHANGELOG.md +15 -1
- package/LICENSE +1 -1
- package/README.md +56 -43
- package/esm/adb.d.ts +48 -0
- package/esm/adb.d.ts.map +1 -0
- package/esm/adb.js +141 -146
- package/esm/adb.js.map +1 -1
- package/{dts → esm}/auth.d.ts +8 -8
- package/esm/auth.d.ts.map +1 -0
- package/esm/auth.js +68 -108
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +9 -0
- package/esm/backend.d.ts.map +1 -0
- package/{dts → esm}/commands/base.d.ts +1 -1
- package/esm/commands/base.d.ts.map +1 -0
- package/esm/commands/base.js +1 -0
- package/esm/commands/base.js.map +1 -1
- package/{dts → esm}/commands/framebuffer.d.ts +3 -3
- package/esm/commands/framebuffer.d.ts.map +1 -0
- package/esm/commands/framebuffer.js +15 -18
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +9 -0
- package/esm/commands/index.d.ts.map +1 -0
- package/esm/commands/index.js +8 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +4 -0
- package/esm/commands/install.d.ts.map +1 -0
- package/esm/commands/install.js +21 -13
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +23 -0
- package/esm/commands/power.d.ts.map +1 -0
- package/esm/commands/power.js +45 -0
- package/esm/commands/power.js.map +1 -0
- package/{dts → esm}/commands/reverse.d.ts +3 -3
- package/esm/commands/reverse.d.ts.map +1 -0
- package/esm/commands/reverse.js +49 -60
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +57 -0
- package/esm/commands/subprocess/index.d.ts.map +1 -0
- package/esm/commands/subprocess/index.js +83 -0
- package/esm/commands/subprocess/index.js.map +1 -0
- package/esm/commands/subprocess/legacy.d.ts +28 -0
- package/esm/commands/subprocess/legacy.d.ts.map +1 -0
- package/esm/commands/subprocess/legacy.js +44 -0
- package/esm/commands/subprocess/legacy.js.map +1 -0
- package/esm/commands/subprocess/protocol.d.ts +38 -0
- package/esm/commands/subprocess/protocol.d.ts.map +1 -0
- package/esm/commands/subprocess/protocol.js +155 -0
- package/esm/commands/subprocess/protocol.js.map +1 -0
- package/esm/commands/subprocess/types.d.ts +47 -0
- package/esm/commands/subprocess/types.d.ts.map +1 -0
- package/esm/commands/{shell → subprocess}/types.js +0 -0
- package/esm/commands/{shell → subprocess}/types.js.map +1 -1
- package/{dts/commands/shell → esm/commands/subprocess}/utils.d.ts +0 -0
- package/esm/commands/subprocess/utils.d.ts.map +1 -0
- package/esm/commands/{shell → subprocess}/utils.js +0 -0
- package/esm/commands/subprocess/utils.js.map +1 -0
- package/esm/commands/sync/index.d.ts +8 -0
- package/esm/commands/sync/index.d.ts.map +1 -0
- package/esm/commands/sync/index.js +7 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/{dts → esm}/commands/sync/list.d.ts +4 -4
- package/esm/commands/sync/list.d.ts.map +1 -0
- package/esm/commands/sync/list.js +16 -19
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +11 -0
- package/esm/commands/sync/pull.d.ts.map +1 -0
- package/esm/commands/sync/pull.js +17 -11
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +8 -0
- package/esm/commands/sync/push.d.ts.map +1 -0
- package/esm/commands/sync/push.js +19 -37
- package/esm/commands/sync/push.js.map +1 -1
- package/{dts → esm}/commands/sync/request.d.ts +3 -3
- package/esm/commands/sync/request.d.ts.map +1 -0
- package/esm/commands/sync/request.js +24 -27
- package/esm/commands/sync/request.js.map +1 -1
- package/{dts → esm}/commands/sync/response.d.ts +2 -2
- package/esm/commands/sync/response.d.ts.map +1 -0
- package/esm/commands/sync/response.js +16 -20
- package/esm/commands/sync/response.js.map +1 -1
- package/{dts → esm}/commands/sync/stat.d.ts +4 -4
- package/esm/commands/sync/stat.d.ts.map +1 -0
- package/esm/commands/sync/stat.js +22 -27
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +83 -0
- package/esm/commands/sync/sync.d.ts.map +1 -0
- package/esm/commands/sync/sync.js +92 -89
- package/esm/commands/sync/sync.js.map +1 -1
- package/{dts → esm}/commands/tcpip.d.ts +1 -1
- package/{dts → esm}/commands/tcpip.d.ts.map +1 -1
- package/esm/commands/tcpip.js +14 -19
- package/esm/commands/tcpip.js.map +1 -1
- package/{dts → esm}/crypto.d.ts +7 -7
- package/esm/crypto.d.ts.map +1 -0
- package/esm/crypto.js +26 -29
- package/esm/crypto.js.map +1 -1
- package/{dts → esm}/features.d.ts +0 -0
- package/{dts → esm}/features.d.ts.map +0 -0
- package/esm/features.js +1 -1
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +11 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +10 -10
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +28 -0
- package/esm/packet.d.ts.map +1 -0
- package/esm/packet.js +26 -51
- package/esm/packet.js.map +1 -1
- package/esm/socket/controller.d.ts +37 -0
- package/esm/socket/controller.d.ts.map +1 -0
- package/esm/socket/controller.js +52 -66
- package/esm/socket/controller.js.map +1 -1
- package/{dts → esm}/socket/dispatcher.d.ts +10 -23
- package/esm/socket/dispatcher.d.ts.map +1 -0
- package/esm/socket/dispatcher.js +148 -164
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +3 -0
- package/esm/socket/index.d.ts.map +1 -0
- package/esm/socket/index.js +2 -6
- package/esm/socket/index.js.map +1 -1
- package/esm/socket/socket.d.ts +34 -0
- package/esm/socket/socket.d.ts.map +1 -0
- package/esm/socket/socket.js +69 -14
- package/esm/socket/socket.js.map +1 -1
- package/esm/stream/buffered.d.ts +35 -0
- package/esm/stream/buffered.d.ts.map +1 -0
- package/esm/stream/buffered.js +123 -0
- package/esm/stream/buffered.js.map +1 -0
- package/esm/stream/detect.bak.d.ts +240 -0
- package/esm/stream/detect.bak.d.ts.map +1 -0
- package/esm/stream/detect.bak.js +60 -0
- package/esm/stream/detect.bak.js.map +1 -0
- package/esm/stream/detect.d.ts +18 -0
- package/esm/stream/detect.d.ts.map +1 -0
- package/esm/stream/detect.js +6 -0
- package/esm/stream/detect.js.map +1 -0
- package/esm/stream/detect.native.d.ts +240 -0
- package/esm/stream/detect.native.d.ts.map +1 -0
- package/esm/stream/detect.native.js +60 -0
- package/esm/stream/detect.native.js.map +1 -0
- package/esm/stream/detect.polyfill.d.ts +18 -0
- package/esm/stream/detect.polyfill.d.ts.map +1 -0
- package/esm/stream/detect.polyfill.js +6 -0
- package/esm/stream/detect.polyfill.js.map +1 -0
- package/esm/stream/index.d.ts +4 -0
- package/esm/stream/index.d.ts.map +1 -0
- package/esm/stream/index.js +3 -2
- package/esm/stream/index.js.map +1 -1
- package/esm/stream/transform.d.ts +98 -0
- package/esm/stream/transform.d.ts.map +1 -0
- package/esm/stream/transform.js +352 -0
- package/esm/stream/transform.js.map +1 -0
- package/{dts → esm}/utils/auto-reset-event.d.ts +1 -1
- package/esm/utils/auto-reset-event.d.ts.map +1 -0
- package/esm/utils/auto-reset-event.js +2 -1
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +5 -0
- package/esm/utils/base64.d.ts.map +1 -0
- package/esm/utils/base64.js +116 -80
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/encoding.d.ts +3 -0
- package/{dts → esm}/utils/encoding.d.ts.map +1 -1
- package/esm/utils/encoding.js +1 -1
- package/esm/utils/encoding.js.map +1 -1
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +3 -5
- package/esm/utils/index.js.map +1 -1
- package/package.json +50 -44
- package/src/adb.ts +147 -143
- package/src/auth.ts +23 -19
- package/src/backend.ts +3 -12
- package/src/commands/base.ts +1 -1
- package/src/commands/framebuffer.ts +4 -4
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +26 -15
- package/src/commands/power.ts +54 -0
- package/src/commands/reverse.ts +10 -8
- package/src/commands/subprocess/index.ts +124 -0
- package/src/commands/subprocess/legacy.ts +58 -0
- package/src/commands/subprocess/protocol.ts +185 -0
- package/src/commands/subprocess/types.ts +55 -0
- package/src/commands/{shell → subprocess}/utils.ts +0 -0
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +7 -6
- package/src/commands/sync/pull.ts +27 -18
- package/src/commands/sync/push.ts +25 -30
- package/src/commands/sync/request.ts +7 -7
- package/src/commands/sync/response.ts +4 -4
- package/src/commands/sync/stat.ts +8 -6
- package/src/commands/sync/sync.ts +64 -32
- package/src/commands/tcpip.ts +3 -3
- package/src/crypto.ts +38 -43
- package/src/index.ts +11 -10
- package/src/packet.ts +37 -52
- package/src/socket/dispatcher.ts +90 -103
- package/src/socket/index.ts +2 -6
- package/src/socket/socket.ts +117 -16
- package/src/stream/buffered.ts +147 -0
- package/src/stream/detect.native.ts +362 -0
- package/src/stream/detect.polyfill.ts +25 -0
- package/src/stream/detect.ts +25 -0
- package/src/stream/index.ts +3 -2
- package/src/stream/transform.ts +427 -0
- package/src/utils/auto-reset-event.ts +1 -1
- package/src/utils/base64.ts +161 -129
- package/src/utils/encoding.ts +3 -3
- package/src/utils/index.ts +3 -5
- package/tsconfig.build.json +3 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.test.json +10 -0
- package/dts/adb.d.ts +0 -46
- package/dts/adb.d.ts.map +0 -1
- package/dts/auth.d.ts.map +0 -1
- package/dts/backend.d.ts +0 -13
- package/dts/backend.d.ts.map +0 -1
- package/dts/commands/base.d.ts.map +0 -1
- package/dts/commands/demo-mode.d.ts +0 -41
- package/dts/commands/demo-mode.d.ts.map +0 -1
- package/dts/commands/framebuffer.d.ts.map +0 -1
- package/dts/commands/index.d.ts +0 -9
- package/dts/commands/index.d.ts.map +0 -1
- package/dts/commands/install.d.ts +0 -3
- package/dts/commands/install.d.ts.map +0 -1
- package/dts/commands/reverse.d.ts.map +0 -1
- package/dts/commands/shell/index.d.ts +0 -46
- package/dts/commands/shell/index.d.ts.map +0 -1
- package/dts/commands/shell/legacy.d.ts +0 -38
- package/dts/commands/shell/legacy.d.ts.map +0 -1
- package/dts/commands/shell/protocol.d.ts +0 -45
- package/dts/commands/shell/protocol.d.ts.map +0 -1
- package/dts/commands/shell/types.d.ts +0 -47
- package/dts/commands/shell/types.d.ts.map +0 -1
- package/dts/commands/shell/utils.d.ts.map +0 -1
- package/dts/commands/sync/index.d.ts +0 -8
- package/dts/commands/sync/index.d.ts.map +0 -1
- package/dts/commands/sync/list.d.ts.map +0 -1
- package/dts/commands/sync/pull.d.ts +0 -11
- package/dts/commands/sync/pull.d.ts.map +0 -1
- package/dts/commands/sync/push.d.ts +0 -8
- package/dts/commands/sync/push.d.ts.map +0 -1
- package/dts/commands/sync/request.d.ts.map +0 -1
- package/dts/commands/sync/response.d.ts.map +0 -1
- package/dts/commands/sync/stat.d.ts.map +0 -1
- package/dts/commands/sync/sync.d.ts +0 -68
- package/dts/commands/sync/sync.d.ts.map +0 -1
- package/dts/crypto.d.ts.map +0 -1
- package/dts/index.d.ts +0 -11
- package/dts/index.d.ts.map +0 -1
- package/dts/packet.d.ts +0 -27
- package/dts/packet.d.ts.map +0 -1
- package/dts/socket/close-event-emitter.d.ts +0 -8
- package/dts/socket/close-event-emitter.d.ts.map +0 -1
- package/dts/socket/controller.d.ts +0 -43
- package/dts/socket/controller.d.ts.map +0 -1
- package/dts/socket/data-event-emitter.d.ts +0 -10
- package/dts/socket/data-event-emitter.d.ts.map +0 -1
- package/dts/socket/dispatcher.d.ts.map +0 -1
- package/dts/socket/index.d.ts +0 -7
- package/dts/socket/index.d.ts.map +0 -1
- package/dts/socket/logger.d.ts +0 -9
- package/dts/socket/logger.d.ts.map +0 -1
- package/dts/socket/socket.d.ts +0 -22
- package/dts/socket/socket.d.ts.map +0 -1
- package/dts/stream/buffered-stream.d.ts +0 -28
- package/dts/stream/buffered-stream.d.ts.map +0 -1
- package/dts/stream/index.d.ts +0 -3
- package/dts/stream/index.d.ts.map +0 -1
- package/dts/stream/stream.d.ts +0 -15
- package/dts/stream/stream.d.ts.map +0 -1
- package/dts/utils/auto-reset-event.d.ts.map +0 -1
- package/dts/utils/base64.d.ts +0 -7
- package/dts/utils/base64.d.ts.map +0 -1
- package/dts/utils/chunk.d.ts +0 -3
- package/dts/utils/chunk.d.ts.map +0 -1
- package/dts/utils/encoding.d.ts +0 -3
- package/dts/utils/event-queue.d.ts +0 -35
- package/dts/utils/event-queue.d.ts.map +0 -1
- package/dts/utils/index.d.ts +0 -6
- package/dts/utils/index.d.ts.map +0 -1
- package/esm/commands/demo-mode.js +0 -170
- package/esm/commands/demo-mode.js.map +0 -1
- package/esm/commands/shell/index.js +0 -62
- package/esm/commands/shell/index.js.map +0 -1
- package/esm/commands/shell/legacy.js +0 -49
- package/esm/commands/shell/legacy.js.map +0 -1
- package/esm/commands/shell/protocol.js +0 -106
- package/esm/commands/shell/protocol.js.map +0 -1
- package/esm/commands/shell/utils.js.map +0 -1
- package/esm/socket/close-event-emitter.js +0 -28
- package/esm/socket/close-event-emitter.js.map +0 -1
- package/esm/socket/data-event-emitter.js +0 -25
- package/esm/socket/data-event-emitter.js.map +0 -1
- package/esm/socket/logger.js +0 -2
- package/esm/socket/logger.js.map +0 -1
- package/esm/stream/buffered-stream.js +0 -67
- package/esm/stream/buffered-stream.js.map +0 -1
- package/esm/stream/stream.js +0 -41
- package/esm/stream/stream.js.map +0 -1
- package/esm/utils/chunk.js +0 -70
- package/esm/utils/chunk.js.map +0 -1
- package/esm/utils/event-queue.js +0 -104
- package/esm/utils/event-queue.js.map +0 -1
- package/src/commands/demo-mode.ts +0 -160
- package/src/commands/shell/index.ts +0 -87
- package/src/commands/shell/legacy.ts +0 -59
- package/src/commands/shell/protocol.ts +0 -121
- package/src/commands/shell/types.ts +0 -55
- package/src/socket/close-event-emitter.ts +0 -28
- package/src/socket/controller.ts +0 -105
- package/src/socket/data-event-emitter.ts +0 -27
- package/src/socket/logger.ts +0 -12
- package/src/stream/buffered-stream.ts +0 -92
- package/src/stream/stream.ts +0 -50
- package/src/utils/chunk.ts +0 -70
- package/src/utils/event-queue.ts +0 -145
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { AdbSocketStream } from './stream';
|
|
3
|
-
export class BufferedStream {
|
|
4
|
-
constructor(stream) {
|
|
5
|
-
this.stream = stream;
|
|
6
|
-
}
|
|
7
|
-
read(length) {
|
|
8
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
let array;
|
|
10
|
-
let index;
|
|
11
|
-
if (this.buffer) {
|
|
12
|
-
const buffer = this.buffer;
|
|
13
|
-
if (buffer.byteLength > length) {
|
|
14
|
-
this.buffer = buffer.subarray(length);
|
|
15
|
-
return buffer.slice(0, length).buffer;
|
|
16
|
-
}
|
|
17
|
-
array = new Uint8Array(length);
|
|
18
|
-
array.set(buffer);
|
|
19
|
-
index = buffer.byteLength;
|
|
20
|
-
this.buffer = undefined;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const buffer = yield this.stream.read(length);
|
|
24
|
-
if (buffer.byteLength === length) {
|
|
25
|
-
return buffer;
|
|
26
|
-
}
|
|
27
|
-
if (buffer.byteLength > length) {
|
|
28
|
-
this.buffer = new Uint8Array(buffer, length);
|
|
29
|
-
return buffer.slice(0, length);
|
|
30
|
-
}
|
|
31
|
-
array = new Uint8Array(length);
|
|
32
|
-
array.set(new Uint8Array(buffer), 0);
|
|
33
|
-
index = buffer.byteLength;
|
|
34
|
-
}
|
|
35
|
-
while (index < length) {
|
|
36
|
-
const left = length - index;
|
|
37
|
-
const buffer = yield this.stream.read(left);
|
|
38
|
-
if (buffer.byteLength > left) {
|
|
39
|
-
array.set(new Uint8Array(buffer, 0, left), index);
|
|
40
|
-
this.buffer = new Uint8Array(buffer, left);
|
|
41
|
-
return array.buffer;
|
|
42
|
-
}
|
|
43
|
-
array.set(new Uint8Array(buffer), index);
|
|
44
|
-
index += buffer.byteLength;
|
|
45
|
-
}
|
|
46
|
-
return array.buffer;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
close() {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
(_b = (_a = this.stream).close) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
export class AdbBufferedStream extends BufferedStream {
|
|
55
|
-
get backend() { return this.stream.backend; }
|
|
56
|
-
get localId() { return this.stream.localId; }
|
|
57
|
-
get remoteId() { return this.stream.remoteId; }
|
|
58
|
-
get localCreated() { return this.stream.localCreated; }
|
|
59
|
-
get serviceString() { return this.stream.serviceString; }
|
|
60
|
-
constructor(socket) {
|
|
61
|
-
super(new AdbSocketStream(socket));
|
|
62
|
-
}
|
|
63
|
-
write(data) {
|
|
64
|
-
return this.stream.write(data);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=buffered-stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buffered-stream.js","sourceRoot":"","sources":["../../src/stream/buffered-stream.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAY3C,MAAM,OAAO,cAAc;IAKvB,YAAmB,MAAS;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAEY,IAAI,CAAC,MAAc;;YAC5B,IAAI,KAAiB,CAAC;YACtB,IAAI,KAAa,CAAC;YAClB,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;gBAC3B,IAAI,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE;oBAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,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,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;oBAC3C,OAAO,KAAK,CAAC,MAAM,CAAC;iBACvB;gBAED,KAAK,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;gBACzC,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC;aAC9B;YAED,OAAO,KAAK,CAAC,MAAM,CAAC;QACxB,CAAC;KAAA;IAEM,KAAK;;QACR,MAAA,MAAA,IAAI,CAAC,MAAM,EAAC,KAAK,kDAAI,CAAC;IAC1B,CAAC;CACJ;AAED,MAAM,OAAO,iBACT,SAAQ,cAA+B;IAEvC,IAAW,OAAO,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,IAAW,OAAO,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACpD,IAAW,QAAQ,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9D,IAAW,aAAa,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAEhE,YAAmB,MAAiB;QAChC,KAAK,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,IAAiB;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACJ"}
|
package/esm/stream/stream.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { once } from '@yume-chan/event';
|
|
3
|
-
import { EventQueue } from '../utils';
|
|
4
|
-
export class AdbSocketStream {
|
|
5
|
-
constructor(socket) {
|
|
6
|
-
this.socket = socket;
|
|
7
|
-
this.queue = new EventQueue({
|
|
8
|
-
highWaterMark: 16 * 1024,
|
|
9
|
-
});
|
|
10
|
-
this.socket.onData((buffer) => {
|
|
11
|
-
if (!this.queue.enqueue(buffer, buffer.byteLength)) {
|
|
12
|
-
return once(this.queue.onDrain);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
this.socket.onClose(() => {
|
|
16
|
-
this.queue.end();
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
get backend() { return this.socket.backend; }
|
|
20
|
-
get localId() { return this.socket.localId; }
|
|
21
|
-
get remoteId() { return this.socket.remoteId; }
|
|
22
|
-
get localCreated() { return this.socket.localCreated; }
|
|
23
|
-
get serviceString() { return this.socket.serviceString; }
|
|
24
|
-
read() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
return yield this.queue.dequeue();
|
|
28
|
-
}
|
|
29
|
-
catch (_a) {
|
|
30
|
-
throw new Error('Can not read after AdbSocketStream has been closed');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
write(data) {
|
|
35
|
-
return this.socket.write(data);
|
|
36
|
-
}
|
|
37
|
-
close() {
|
|
38
|
-
this.socket.close();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=stream.js.map
|
package/esm/stream/stream.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream/stream.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,OAAO,eAAe;IAWxB,YAAmB,MAAiB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAc;YACrC,aAAa,EAAE,EAAE,GAAG,IAAI;SAC3B,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asyncGenerator, __asyncValues, __await } from "tslib";
|
|
2
|
-
export function* chunkArrayLike(value, size) {
|
|
3
|
-
if ('length' in value) {
|
|
4
|
-
value = new Uint8Array(value).buffer;
|
|
5
|
-
}
|
|
6
|
-
if (value.byteLength <= size) {
|
|
7
|
-
return yield value;
|
|
8
|
-
}
|
|
9
|
-
for (let i = 0; i < value.byteLength; i += size) {
|
|
10
|
-
yield value.slice(i, i + size);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function chunkAsyncIterable(value, size) {
|
|
14
|
-
return __asyncGenerator(this, arguments, function* chunkAsyncIterable_1() {
|
|
15
|
-
var e_1, _a;
|
|
16
|
-
let result = new Uint8Array(size);
|
|
17
|
-
let index = 0;
|
|
18
|
-
try {
|
|
19
|
-
for (var value_1 = __asyncValues(value), value_1_1; value_1_1 = yield __await(value_1.next()), !value_1_1.done;) {
|
|
20
|
-
let buffer = value_1_1.value;
|
|
21
|
-
// `result` has some data, `result + buffer` is enough
|
|
22
|
-
if (index !== 0 && index + buffer.byteLength >= size) {
|
|
23
|
-
const remainder = size - index;
|
|
24
|
-
result.set(new Uint8Array(buffer, 0, remainder), index);
|
|
25
|
-
yield yield __await(result.buffer);
|
|
26
|
-
result = new Uint8Array(size);
|
|
27
|
-
index = 0;
|
|
28
|
-
if (buffer.byteLength > remainder) {
|
|
29
|
-
// `buffer` still has some data
|
|
30
|
-
buffer = buffer.slice(remainder);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// `result` is empty, `buffer` alone is enough
|
|
37
|
-
if (buffer.byteLength >= size) {
|
|
38
|
-
let remainder = false;
|
|
39
|
-
for (const chunk of chunkArrayLike(buffer, size)) {
|
|
40
|
-
if (chunk.byteLength === size) {
|
|
41
|
-
yield yield __await(chunk);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
// `buffer` still has some data
|
|
45
|
-
remainder = true;
|
|
46
|
-
buffer = chunk;
|
|
47
|
-
}
|
|
48
|
-
if (!remainder) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// `result` has some data but `result + buffer` is still not enough
|
|
53
|
-
// or after previous steps `buffer` still has some data
|
|
54
|
-
result.set(new Uint8Array(buffer), index);
|
|
55
|
-
index += buffer.byteLength;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
-
finally {
|
|
60
|
-
try {
|
|
61
|
-
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) yield __await(_a.call(value_1));
|
|
62
|
-
}
|
|
63
|
-
finally { if (e_1) throw e_1.error; }
|
|
64
|
-
}
|
|
65
|
-
if (index !== 0) {
|
|
66
|
-
yield yield __await(result.buffer.slice(0, index));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=chunk.js.map
|
package/esm/utils/chunk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/utils/chunk.ts"],"names":[],"mappings":";AAAA,MAAM,SAAS,CAAC,CAAC,cAAc,CAC3B,KAA0C,EAC1C,IAAY;IAEZ,IAAI,QAAQ,IAAI,KAAK,EAAE;QACnB,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;KACxC;IAED,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE;QAC1B,OAAO,MAAM,KAAK,CAAC;KACtB;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,IAAI,EAAE;QAC7C,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;KAClC;AACL,CAAC;AAED,MAAM,UAAiB,kBAAkB,CACrC,KAAiC,EACjC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G,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;gBAC1C,KAAK,IAAI,MAAM,CAAC,UAAU,CAAC;aAC9B;;;;;;;;;QAED,IAAI,KAAK,KAAK,CAAC,EAAE;YACb,oBAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA,CAAC;SACvC;IACL,CAAC;CAAA"}
|
package/esm/utils/event-queue.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { PromiseResolver } from '@yume-chan/async';
|
|
2
|
-
import { EventEmitter } from '@yume-chan/event';
|
|
3
|
-
export const EventQueueDefaultOptions = {
|
|
4
|
-
maxWaitCount: Infinity,
|
|
5
|
-
highWaterMark: 10,
|
|
6
|
-
lowWaterMark: 0,
|
|
7
|
-
};
|
|
8
|
-
class LinkedList {
|
|
9
|
-
constructor() {
|
|
10
|
-
this._length = 0;
|
|
11
|
-
}
|
|
12
|
-
get length() { return this._length; }
|
|
13
|
-
push(value) {
|
|
14
|
-
const item = { value };
|
|
15
|
-
if (this._length === 0) {
|
|
16
|
-
this.head = item;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
this.tail.next = item;
|
|
20
|
-
}
|
|
21
|
-
this._length += 1;
|
|
22
|
-
this.tail = item;
|
|
23
|
-
}
|
|
24
|
-
shift() {
|
|
25
|
-
if (this._length === 0) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const { next, value } = this.head;
|
|
29
|
-
if (!next) {
|
|
30
|
-
this.tail = undefined;
|
|
31
|
-
}
|
|
32
|
-
this.head = next;
|
|
33
|
-
this._length -= 1;
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Basically an object-mode ReadableStream with Promise-based API
|
|
39
|
-
*
|
|
40
|
-
* It's called `EventQueue` because it usually converts events ("push system") to "pull system"
|
|
41
|
-
*
|
|
42
|
-
* https://github.com/nodejs/node/blob/master/lib/internal/streams/readable.js
|
|
43
|
-
*/
|
|
44
|
-
export class EventQueue {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
// Use linked lists for faster shift operation.
|
|
47
|
-
/** Already buffered data ready to be served to consumers */
|
|
48
|
-
this.buffers = new LinkedList();
|
|
49
|
-
/** Waiting consumers because lack of data */
|
|
50
|
-
this.awaiters = new LinkedList();
|
|
51
|
-
this.ended = false;
|
|
52
|
-
this._length = 0;
|
|
53
|
-
this._needDrain = false;
|
|
54
|
-
this.drainEvent = new EventEmitter();
|
|
55
|
-
this.onDrain = this.drainEvent.event;
|
|
56
|
-
this.options = Object.assign(Object.assign({}, EventQueueDefaultOptions), options);
|
|
57
|
-
}
|
|
58
|
-
get length() { return this._length; }
|
|
59
|
-
get needDrain() { return this._needDrain; }
|
|
60
|
-
enqueue(value, length = 1) {
|
|
61
|
-
if (this.ended) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
if (this.awaiters.length) {
|
|
65
|
-
this.awaiters.shift().resolve(value);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
this.buffers.push([value, length]);
|
|
69
|
-
this._length += length;
|
|
70
|
-
if (this._length < this.options.highWaterMark) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
this._needDrain = true;
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
dequeue() {
|
|
77
|
-
if (this.buffers.length) {
|
|
78
|
-
const [value, size] = this.buffers.shift();
|
|
79
|
-
this._length -= size;
|
|
80
|
-
if (this._needDrain &&
|
|
81
|
-
this._length <= this.options.lowWaterMark) {
|
|
82
|
-
this.drainEvent.fire();
|
|
83
|
-
}
|
|
84
|
-
return Promise.resolve(value);
|
|
85
|
-
}
|
|
86
|
-
if (this.ended) {
|
|
87
|
-
return Promise.reject(new Error('The EventQueue has already ended'));
|
|
88
|
-
}
|
|
89
|
-
if (this.awaiters.length === this.options.maxWaitCount - 1) {
|
|
90
|
-
throw new Error('Max wait count exceeded');
|
|
91
|
-
}
|
|
92
|
-
const resolver = new PromiseResolver();
|
|
93
|
-
this.awaiters.push(resolver);
|
|
94
|
-
return resolver.promise;
|
|
95
|
-
}
|
|
96
|
-
end() {
|
|
97
|
-
this.ended = true;
|
|
98
|
-
let item;
|
|
99
|
-
while (item = this.awaiters.shift()) {
|
|
100
|
-
item.reject(new Error('The EventQueue has already ended'));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=event-queue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue.js","sourceRoot":"","sources":["../../src/utils/event-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IACvD,YAAY,EAAE,QAAQ;IACtB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,CAAC;CAClB,CAAC;AAQF,MAAM,UAAU;IAAhB;QAKY,YAAO,GAAG,CAAC,CAAC;IA8BxB,CAAC;IA7BG,IAAW,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAErC,IAAI,CAAC,KAAQ;QAChB,MAAM,IAAI,GAAsB,EAAE,KAAK,EAAE,CAAC;QAE1C,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SACpB;aAAM;YACH,IAAI,CAAC,IAAK,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEM,KAAK;QACR,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,EAAE;YACpB,OAAO;SACV;QAED,MAAM,E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,KAAK,CAAC,kCAAkC,CAAC,CAAC,CAAC;SAC9D;IACL,CAAC;CACJ"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { AdbCommandBase } from './base';
|
|
2
|
-
|
|
3
|
-
export enum AdbDemoModeSignalStrength {
|
|
4
|
-
Hidden = 'null',
|
|
5
|
-
Level0 = '0',
|
|
6
|
-
Level1 = '1',
|
|
7
|
-
Level2 = '2',
|
|
8
|
-
Level3 = '3',
|
|
9
|
-
Level4 = '4',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java;l=1073
|
|
13
|
-
export const AdbDemoModeMobileDataTypes = ['1x', '3g', '4g', '4g+', '5g', '5ge', '5g+',
|
|
14
|
-
'e', 'g', 'h', 'h+', 'lte', 'lte+', 'dis', 'not', 'null'] as const;
|
|
15
|
-
|
|
16
|
-
export type AdbDemoModeMobileDataType = (typeof AdbDemoModeMobileDataTypes)[number];
|
|
17
|
-
|
|
18
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3136
|
|
19
|
-
export const AdbDemoModeStatusBarModes = ['opaque', 'translucent', 'semi-transparent', 'transparent', 'warning'] as const;
|
|
20
|
-
|
|
21
|
-
export type AdbDemoModeStatusBarMode = (typeof AdbDemoModeStatusBarModes)[number];
|
|
22
|
-
|
|
23
|
-
export class AdbDemoMode extends AdbCommandBase {
|
|
24
|
-
public static readonly AllowedSettingKey = 'sysui_demo_allowed';
|
|
25
|
-
|
|
26
|
-
// Demo Mode actually doesn't have a setting indicates its enablement
|
|
27
|
-
// However Developer Mode menu uses this key
|
|
28
|
-
// So we can only try our best to guess if it's enabled
|
|
29
|
-
public static readonly EnabledSettingKey = 'sysui_tuner_demo_on';
|
|
30
|
-
|
|
31
|
-
public async getAllowed(): Promise<boolean> {
|
|
32
|
-
const result = await this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.AllowedSettingKey);
|
|
33
|
-
return result.trim() === '1';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public async setAllowed(value: boolean): Promise<void> {
|
|
37
|
-
if (value) {
|
|
38
|
-
await this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.AllowedSettingKey, '1');
|
|
39
|
-
} else {
|
|
40
|
-
await this.setEnabled(false);
|
|
41
|
-
await this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.AllowedSettingKey);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public async getEnabled(): Promise<boolean> {
|
|
46
|
-
const result = await this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.EnabledSettingKey);
|
|
47
|
-
return result.trim() === '1';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public async setEnabled(value: boolean): Promise<void> {
|
|
51
|
-
if (value) {
|
|
52
|
-
await this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.EnabledSettingKey, '1');
|
|
53
|
-
} else {
|
|
54
|
-
await this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.EnabledSettingKey);
|
|
55
|
-
await this.broadcast('exit');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public async broadcast(command: string, extra?: Record<string, string>): Promise<void> {
|
|
60
|
-
await this.adb.childProcess.exec(
|
|
61
|
-
'am',
|
|
62
|
-
'broadcast',
|
|
63
|
-
'-a',
|
|
64
|
-
'com.android.systemui.demo',
|
|
65
|
-
'-e',
|
|
66
|
-
'command',
|
|
67
|
-
command,
|
|
68
|
-
...(extra ? Object.entries(extra).flatMap(([key, value]) => ['-e', key, value]) : []),
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
public async setBatteryLevel(level: number): Promise<void> {
|
|
73
|
-
await this.broadcast('battery', { level: level.toString() });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public async setBatteryCharging(value: boolean): Promise<void> {
|
|
77
|
-
await this.broadcast('battery', { plugged: value.toString() });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public async setPowerSaveMode(value: boolean): Promise<void> {
|
|
81
|
-
await this.broadcast('battery', { powersave: value.toString() });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public async setAirplaneMode(show: boolean): Promise<void> {
|
|
85
|
-
await this.broadcast('network', { airplane: show ? 'show' : 'hide' });
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public async setWifiSignalStrength(value: AdbDemoModeSignalStrength): Promise<void> {
|
|
89
|
-
await this.broadcast('network', { wifi: 'show', level: value });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
public async setMobileDataType(value: AdbDemoModeMobileDataType): Promise<void> {
|
|
93
|
-
for (let i = 0; i < 2; i += 1) {
|
|
94
|
-
await this.broadcast('network', {
|
|
95
|
-
mobile: 'show',
|
|
96
|
-
sims: '1',
|
|
97
|
-
nosim: 'hide',
|
|
98
|
-
slot: '0',
|
|
99
|
-
datatype: value,
|
|
100
|
-
fully: 'true',
|
|
101
|
-
roam: 'false',
|
|
102
|
-
level: '4',
|
|
103
|
-
inflate: 'false',
|
|
104
|
-
activity: 'in',
|
|
105
|
-
carriernetworkchange: 'hide',
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public async setMobileSignalStrength(value: AdbDemoModeSignalStrength): Promise<void> {
|
|
111
|
-
await this.broadcast('network', { mobile: 'show', level: value });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public async setNoSimCardIcon(show: boolean): Promise<void> {
|
|
115
|
-
await this.broadcast('network', { nosim: show ? 'show' : 'hide' });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public async setStatusBarMode(mode: AdbDemoModeStatusBarMode): Promise<void> {
|
|
119
|
-
await this.broadcast('bars', { mode });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public async setVibrateModeEnabled(value: boolean): Promise<void> {
|
|
123
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=103
|
|
124
|
-
await this.broadcast('status', { volume: value ? 'vibrate' : 'hide' });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public async setBluetoothConnected(value: boolean): Promise<void> {
|
|
128
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=114
|
|
129
|
-
await this.broadcast('status', { bluetooth: value ? 'connected' : 'hide' });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public async setLocatingIcon(show: boolean): Promise<void> {
|
|
133
|
-
await this.broadcast('status', { location: show ? 'show' : 'hide' });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public async setAlarmIcon(show: boolean): Promise<void> {
|
|
137
|
-
await this.broadcast('status', { alarm: show ? 'show' : 'hide' });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public async setSyncingIcon(show: boolean): Promise<void> {
|
|
141
|
-
await this.broadcast('status', { sync: show ? 'show' : 'hide' });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
public async setMuteIcon(show: boolean): Promise<void> {
|
|
145
|
-
await this.broadcast('status', { mute: show ? 'show' : 'hide' });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public async setSpeakerPhoneIcon(show: boolean): Promise<void> {
|
|
149
|
-
await this.broadcast('status', { speakerphone: show ? 'show' : 'hide' });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
public async setNotificationsVisibility(show: boolean): Promise<void> {
|
|
153
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3131
|
|
154
|
-
await this.broadcast('notifications', { visible: show.toString() });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public async setTime(hour: number, minute: number): Promise<void> {
|
|
158
|
-
await this.broadcast('clock', { hhmm: `${hour.toString().padStart(2, '0')}${minute.toString().padStart(2, '0')}` });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { Adb } from '../../adb';
|
|
2
|
-
import { AdbLegacyShell } from './legacy';
|
|
3
|
-
import { AdbShellProtocol } from './protocol';
|
|
4
|
-
import type { AdbShell, AdbShellConstructor } from './types';
|
|
5
|
-
|
|
6
|
-
export * from './legacy';
|
|
7
|
-
export * from './protocol';
|
|
8
|
-
export * from './types';
|
|
9
|
-
export * from './utils';
|
|
10
|
-
|
|
11
|
-
export interface AdbChildProcessOptions {
|
|
12
|
-
/**
|
|
13
|
-
* A list of `AdbShellConstructor`s to be used.
|
|
14
|
-
*
|
|
15
|
-
* Different `AdbShell` has different capabilities, thus requires specific adaptations.
|
|
16
|
-
* Check each `AdbShell`'s documentation for details.
|
|
17
|
-
*
|
|
18
|
-
* The first one whose `isSupported` returns `true` will be used.
|
|
19
|
-
* If no `AdbShell` is supported, an error will be thrown.
|
|
20
|
-
*
|
|
21
|
-
* The default value is `[AdbShellProtocol, AdbLegacyShell]`.
|
|
22
|
-
*/
|
|
23
|
-
shells: AdbShellConstructor[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const DefaultOptions: AdbChildProcessOptions = {
|
|
27
|
-
shells: [AdbShellProtocol, AdbLegacyShell],
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export class AdbChildProcess {
|
|
31
|
-
public readonly adb: Adb;
|
|
32
|
-
|
|
33
|
-
public constructor(adb: Adb) {
|
|
34
|
-
this.adb = adb;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private async createShell(command: string, options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
38
|
-
let { shells } = { ...DefaultOptions, ...options };
|
|
39
|
-
|
|
40
|
-
let shell: AdbShellConstructor | undefined;
|
|
41
|
-
for (const item of shells) {
|
|
42
|
-
if (await item.isSupported(this.adb)) {
|
|
43
|
-
shell = item;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (!shell) {
|
|
49
|
-
throw new Error('No specified shell is supported by the device');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return await shell.spawn(this.adb, command);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Spawns the default shell in interactive mode.
|
|
57
|
-
* @param options The options for creating the `AdbShell`
|
|
58
|
-
* @returns A new `AdbShell` instance connecting to the spawned shell process.
|
|
59
|
-
*/
|
|
60
|
-
public shell(options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
61
|
-
return this.createShell('', options);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Spawns a new process using the given `command`.
|
|
66
|
-
* @param command The command to run, or an array of strings containing both command and args.
|
|
67
|
-
* @param options The options for creating the `AdbShell`
|
|
68
|
-
* @returns A new `AdbShell` instance connecting to the spawned process.
|
|
69
|
-
*/
|
|
70
|
-
public spawn(command: string | string[], options?: Partial<AdbChildProcessOptions>): Promise<AdbShell> {
|
|
71
|
-
if (Array.isArray(command)) {
|
|
72
|
-
command = command.join(' ');
|
|
73
|
-
}
|
|
74
|
-
return this.createShell(command, options);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Spawns a new process, waits until it exits, and returns the entire output.
|
|
79
|
-
* @param command The command to run
|
|
80
|
-
* @param args List of command arguments
|
|
81
|
-
* @returns The entire output of the command
|
|
82
|
-
*/
|
|
83
|
-
public exec(command: string, ...args: string[]): Promise<string> {
|
|
84
|
-
// `exec` only needs the entire output, use Legacy Shell is simpler.
|
|
85
|
-
return this.adb.createSocketAndReadAll(`shell:${command} ${args.join(' ')}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "@yume-chan/event";
|
|
2
|
-
import type { Adb } from "../../adb";
|
|
3
|
-
import type { AdbSocket } from "../../socket";
|
|
4
|
-
import type { AdbShell } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The legacy shell
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* * `onStderr`: No
|
|
11
|
-
* * `onExit` exit code: No
|
|
12
|
-
* * `resize`: No
|
|
13
|
-
*/
|
|
14
|
-
export class AdbLegacyShell implements AdbShell {
|
|
15
|
-
public static isSupported() { return true; }
|
|
16
|
-
|
|
17
|
-
public static async spawn(adb: Adb, command: string) {
|
|
18
|
-
return new AdbLegacyShell(await adb.createSocket(`shell:${command}`));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
private readonly socket: AdbSocket;
|
|
22
|
-
|
|
23
|
-
private readonly stdoutEvent = new EventEmitter<ArrayBuffer>();
|
|
24
|
-
public get onStdout() { return this.stdoutEvent.event; }
|
|
25
|
-
|
|
26
|
-
private readonly stderrEvent = new EventEmitter<ArrayBuffer>();
|
|
27
|
-
public get onStderr() { return this.stderrEvent.event; }
|
|
28
|
-
|
|
29
|
-
private readonly exitEvent = new EventEmitter<number>();
|
|
30
|
-
public get onExit() { return this.exitEvent.event; }
|
|
31
|
-
|
|
32
|
-
public constructor(socket: AdbSocket) {
|
|
33
|
-
this.socket = socket;
|
|
34
|
-
this.socket.onData(this.handleData, this);
|
|
35
|
-
this.socket.onClose(this.handleExit, this);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private handleData(data: ArrayBuffer) {
|
|
39
|
-
// Legacy shell doesn't support splitting output streams.
|
|
40
|
-
this.stdoutEvent.fire(data);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private handleExit() {
|
|
44
|
-
// Legacy shell doesn't support returning exit code.
|
|
45
|
-
this.exitEvent.fire(0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public async write(data: ArrayBuffer) {
|
|
49
|
-
this.socket.write(data);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public resize() {
|
|
53
|
-
// Not supported
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public kill() {
|
|
57
|
-
return this.socket.close();
|
|
58
|
-
}
|
|
59
|
-
}
|