@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
package/esm/utils/base64.js
CHANGED
|
@@ -5,7 +5,6 @@ const paddingChar = '='.charCodeAt(0);
|
|
|
5
5
|
function addRange(start, end) {
|
|
6
6
|
const charCodeStart = start.charCodeAt(0);
|
|
7
7
|
const charCodeEnd = end.charCodeAt(0);
|
|
8
|
-
const length = charCodeEnd - charCodeStart + 1;
|
|
9
8
|
for (let charCode = charCodeStart; charCode <= charCodeEnd; charCode += 1) {
|
|
10
9
|
charToIndex[String.fromCharCode(charCode)] = indexToChar.length;
|
|
11
10
|
indexToChar.push(charCode);
|
|
@@ -21,84 +20,122 @@ export function calculateBase64EncodedLength(inputLength) {
|
|
|
21
20
|
const paddingLength = remainder !== 0 ? 3 - remainder : 0;
|
|
22
21
|
return [(inputLength + paddingLength) / 3 * 4, paddingLength];
|
|
23
22
|
}
|
|
24
|
-
export function encodeBase64(input,
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// TypeScript doesn't correctly narrow `input` to `Uint8Array` when assigning.
|
|
31
|
-
// Manually eliminate `ArrayBuffer` from `input` with a type guard.
|
|
32
|
-
if (input instanceof ArrayBuffer) {
|
|
33
|
-
return input;
|
|
34
|
-
}
|
|
35
|
-
let inputOffset;
|
|
36
|
-
let inputLength;
|
|
37
|
-
let output;
|
|
38
|
-
let outputOffset;
|
|
39
|
-
let outputArgumentIndex;
|
|
40
|
-
if (typeof arg1 === 'number') {
|
|
41
|
-
// overload 1, 3, 4
|
|
42
|
-
inputOffset = arg1;
|
|
43
|
-
if (typeof arg2 === 'number') {
|
|
44
|
-
// overload 1, 4
|
|
45
|
-
inputLength = arg2;
|
|
46
|
-
outputArgumentIndex = 3;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
// overload 3
|
|
50
|
-
inputLength = input.byteLength - inputOffset;
|
|
51
|
-
outputArgumentIndex = 2;
|
|
52
|
-
}
|
|
23
|
+
export function encodeBase64(input, output) {
|
|
24
|
+
const [outputLength, paddingLength] = calculateBase64EncodedLength(input.length);
|
|
25
|
+
if (!output) {
|
|
26
|
+
output = new Uint8Array(outputLength);
|
|
27
|
+
encodeForward(input, output, paddingLength);
|
|
28
|
+
return output;
|
|
53
29
|
}
|
|
54
30
|
else {
|
|
55
|
-
|
|
56
|
-
inputOffset = 0;
|
|
57
|
-
inputLength = input.byteLength;
|
|
58
|
-
outputArgumentIndex = 1;
|
|
59
|
-
}
|
|
60
|
-
const [outputLength, paddingLength] = calculateBase64EncodedLength(inputLength);
|
|
61
|
-
let maybeOutput = arguments[outputArgumentIndex];
|
|
62
|
-
let outputType;
|
|
63
|
-
if (maybeOutput) {
|
|
64
|
-
outputOffset = (_a = arguments[outputArgumentIndex + 1]) !== null && _a !== void 0 ? _a : 0;
|
|
65
|
-
if (maybeOutput.byteLength - outputOffset < outputLength) {
|
|
31
|
+
if (output.length < outputLength) {
|
|
66
32
|
throw new Error('output buffer is too small');
|
|
67
33
|
}
|
|
68
|
-
|
|
69
|
-
|
|
34
|
+
output = output.subarray(0, outputLength);
|
|
35
|
+
// When input and output are on same ArrayBuffer,
|
|
36
|
+
// we check if it's possible to encode in-place.
|
|
37
|
+
if (input.buffer !== output.buffer) {
|
|
38
|
+
encodeForward(input, output, paddingLength);
|
|
39
|
+
}
|
|
40
|
+
else if (output.byteOffset + output.length - (paddingLength + 1) <= input.byteOffset + input.length) {
|
|
41
|
+
// Output ends before input ends
|
|
42
|
+
// So output won't catch up with input.
|
|
43
|
+
// Depends on padding length,
|
|
44
|
+
// it's possible to write 1-3 bytes after input ends.
|
|
45
|
+
// spell: disable-next-line
|
|
46
|
+
// | aaaaaabb | | | |
|
|
47
|
+
// | aaaaaa | bb0000 | = | = |
|
|
48
|
+
//
|
|
49
|
+
// spell: disable-next-line
|
|
50
|
+
// | aaaaaabb | bbbbcccc | | |
|
|
51
|
+
// | aaaaaa | bbbbbb | cccc00 | = |
|
|
52
|
+
//
|
|
53
|
+
// spell: disable-next-line
|
|
54
|
+
// | aaaaaabb | bbbbcccc | ccdddddd | |
|
|
55
|
+
// | aaaaaa | bbbbbb | cccccc | dddddd |
|
|
56
|
+
// Must encode forwards.
|
|
57
|
+
encodeForward(input, output, paddingLength);
|
|
58
|
+
}
|
|
59
|
+
else if (output.byteOffset >= input.byteOffset - 1) {
|
|
60
|
+
// Output starts after input starts
|
|
61
|
+
// So in backwards, output can't catch up with input.
|
|
62
|
+
// Because first 3 bytes becomes 4 bytes,
|
|
63
|
+
// it's possible to write 1 byte before input starts.
|
|
64
|
+
// spell: disable-next-line
|
|
65
|
+
// | | aaaaaabb | bbbbcccc | ccdddddd |
|
|
66
|
+
// | aaaaaa | bbbbbb | cccccc | dddddd |
|
|
67
|
+
// Must encode backwards.
|
|
68
|
+
encodeBackward(input, output, paddingLength);
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
|
-
|
|
71
|
+
// Input is in the middle of output,
|
|
72
|
+
// not possible to read neither first or last three bytes,
|
|
73
|
+
throw new Error('input and output cannot overlap');
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
return outputLength;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
}
|
|
78
|
+
function encodeForward(input, output, paddingLength) {
|
|
79
|
+
let inputIndex = 0;
|
|
80
|
+
let outputIndex = 0;
|
|
81
|
+
while (inputIndex < input.length - 2) {
|
|
82
|
+
/* cspell: disable-next-line */
|
|
83
|
+
// aaaaaabb
|
|
84
|
+
const x = input[inputIndex];
|
|
85
|
+
inputIndex += 1;
|
|
86
|
+
/* cspell: disable-next-line */
|
|
87
|
+
// bbbbcccc
|
|
88
|
+
const y = input[inputIndex];
|
|
89
|
+
inputIndex += 1;
|
|
90
|
+
/* cspell: disable-next-line */
|
|
91
|
+
// ccdddddd
|
|
92
|
+
const z = input[inputIndex];
|
|
93
|
+
inputIndex += 1;
|
|
94
|
+
output[outputIndex] = indexToChar[x >> 2];
|
|
95
|
+
outputIndex += 1;
|
|
96
|
+
output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
|
|
97
|
+
outputIndex += 1;
|
|
98
|
+
output[outputIndex] = indexToChar[((y & 0b1111) << 2) | (z >> 6)];
|
|
99
|
+
outputIndex += 1;
|
|
100
|
+
output[outputIndex] = indexToChar[z & 0b111111];
|
|
101
|
+
outputIndex += 1;
|
|
81
102
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
103
|
+
if (paddingLength === 2) {
|
|
104
|
+
/* cspell: disable-next-line */
|
|
105
|
+
// aaaaaabb
|
|
106
|
+
const x = input[inputIndex];
|
|
107
|
+
inputIndex += 1;
|
|
108
|
+
output[outputIndex] = indexToChar[x >> 2];
|
|
109
|
+
outputIndex += 1;
|
|
110
|
+
output[outputIndex] = indexToChar[((x & 0b11) << 4)];
|
|
111
|
+
outputIndex += 1;
|
|
112
|
+
output[outputIndex] = paddingChar;
|
|
113
|
+
outputIndex += 1;
|
|
114
|
+
output[outputIndex] = paddingChar;
|
|
87
115
|
}
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
116
|
+
else if (paddingLength === 1) {
|
|
117
|
+
/* cspell: disable-next-line */
|
|
118
|
+
// aaaaaabb
|
|
119
|
+
const x = input[inputIndex];
|
|
120
|
+
inputIndex += 1;
|
|
121
|
+
/* cspell: disable-next-line */
|
|
122
|
+
// bbbbcccc
|
|
123
|
+
const y = input[inputIndex];
|
|
124
|
+
inputIndex += 1;
|
|
125
|
+
output[outputIndex] = indexToChar[x >> 2];
|
|
126
|
+
outputIndex += 1;
|
|
127
|
+
output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
|
|
128
|
+
outputIndex += 1;
|
|
129
|
+
output[outputIndex] = indexToChar[((y & 0b1111) << 2)];
|
|
130
|
+
outputIndex += 1;
|
|
131
|
+
output[outputIndex] = paddingChar;
|
|
97
132
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
let
|
|
133
|
+
}
|
|
134
|
+
function encodeBackward(input, output, paddingLength) {
|
|
135
|
+
let inputIndex = input.length - 1;
|
|
136
|
+
let outputIndex = output.length - 1;
|
|
101
137
|
if (paddingLength === 2) {
|
|
138
|
+
/* cspell: disable-next-line */
|
|
102
139
|
// aaaaaabb
|
|
103
140
|
const x = input[inputIndex];
|
|
104
141
|
inputIndex -= 1;
|
|
@@ -112,9 +149,11 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
|
|
|
112
149
|
outputIndex -= 1;
|
|
113
150
|
}
|
|
114
151
|
else if (paddingLength === 1) {
|
|
152
|
+
/* cspell: disable-next-line */
|
|
115
153
|
// bbbbcccc
|
|
116
154
|
const y = input[inputIndex];
|
|
117
155
|
inputIndex -= 1;
|
|
156
|
+
/* cspell: disable-next-line */
|
|
118
157
|
// aaaaaabb
|
|
119
158
|
const x = input[inputIndex];
|
|
120
159
|
inputIndex -= 1;
|
|
@@ -127,13 +166,16 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
|
|
|
127
166
|
output[outputIndex] = indexToChar[x >> 2];
|
|
128
167
|
outputIndex -= 1;
|
|
129
168
|
}
|
|
130
|
-
while (inputIndex >=
|
|
169
|
+
while (inputIndex >= 0) {
|
|
170
|
+
/* cspell: disable-next-line */
|
|
131
171
|
// ccdddddd
|
|
132
172
|
const z = input[inputIndex];
|
|
133
173
|
inputIndex -= 1;
|
|
174
|
+
/* cspell: disable-next-line */
|
|
134
175
|
// bbbbcccc
|
|
135
176
|
const y = input[inputIndex];
|
|
136
177
|
inputIndex -= 1;
|
|
178
|
+
/* cspell: disable-next-line */
|
|
137
179
|
// aaaaaabb
|
|
138
180
|
const x = input[inputIndex];
|
|
139
181
|
inputIndex -= 1;
|
|
@@ -146,12 +188,6 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
|
|
|
146
188
|
output[outputIndex] = indexToChar[x >> 2];
|
|
147
189
|
outputIndex -= 1;
|
|
148
190
|
}
|
|
149
|
-
if (outputType === 'ArrayBuffer') {
|
|
150
|
-
return output.buffer;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
return outputLength;
|
|
154
|
-
}
|
|
155
191
|
}
|
|
156
192
|
export function decodeBase64(input) {
|
|
157
193
|
let padding;
|
|
@@ -176,9 +212,9 @@ export function decodeBase64(input) {
|
|
|
176
212
|
sIndex += 1;
|
|
177
213
|
const d = charToIndex[input[sIndex]];
|
|
178
214
|
sIndex += 1;
|
|
179
|
-
result[dIndex] = (a << 2) | ((b &
|
|
215
|
+
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
180
216
|
dIndex += 1;
|
|
181
|
-
result[dIndex] = ((b & 0b1111) << 4) | ((c &
|
|
217
|
+
result[dIndex] = ((b & 0b1111) << 4) | ((c & 0b11_1100) >> 2);
|
|
182
218
|
dIndex += 1;
|
|
183
219
|
result[dIndex] = ((c & 0b11) << 6) | d;
|
|
184
220
|
dIndex += 1;
|
|
@@ -189,16 +225,16 @@ export function decodeBase64(input) {
|
|
|
189
225
|
const b = charToIndex[input[sIndex]];
|
|
190
226
|
sIndex += 1;
|
|
191
227
|
const c = charToIndex[input[sIndex]];
|
|
192
|
-
result[dIndex] = (a << 2) | ((b &
|
|
228
|
+
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
193
229
|
dIndex += 1;
|
|
194
|
-
result[dIndex] = ((b & 0b1111) << 4) | ((c &
|
|
230
|
+
result[dIndex] = ((b & 0b1111) << 4) | ((c & 0b11_1100) >> 2);
|
|
195
231
|
}
|
|
196
232
|
else if (padding === 2) {
|
|
197
233
|
const a = charToIndex[input[sIndex]];
|
|
198
234
|
sIndex += 1;
|
|
199
235
|
const b = charToIndex[input[sIndex]];
|
|
200
|
-
result[dIndex] = (a << 2) | ((b &
|
|
236
|
+
result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
|
|
201
237
|
}
|
|
202
|
-
return result
|
|
238
|
+
return result;
|
|
203
239
|
}
|
|
204
240
|
//# sourceMappingURL=base64.js.map
|
package/esm/utils/base64.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,WAAW,GAA2B,EAAE,CAAC;AAC/C,MAAM,WAAW,GAAa,EAAE,CAAC;AACjC,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAEtC,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,WAAW,GAA2B,EAAE,CAAC;AAC/C,MAAM,WAAW,GAAa,EAAE,CAAC;AACjC,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAEtC,SAAS,QAAQ,CAAC,KAAa,EAAE,GAAW;IACxC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAEtC,KAAK,IAAI,QAAQ,GAAG,aAAa,EAAE,QAA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":"AAMA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,MAAM,CAExE"}
|
package/esm/utils/encoding.js
CHANGED
|
@@ -3,7 +3,7 @@ const Utf8Encoder = new TextEncoder();
|
|
|
3
3
|
// @ts-expect-error @types/node missing `TextDecoder`
|
|
4
4
|
const Utf8Decoder = new TextDecoder();
|
|
5
5
|
export function encodeUtf8(input) {
|
|
6
|
-
return Utf8Encoder.encode(input)
|
|
6
|
+
return Utf8Encoder.encode(input);
|
|
7
7
|
}
|
|
8
8
|
export function decodeUtf8(buffer) {
|
|
9
9
|
return Utf8Decoder.decode(buffer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AACA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AACA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/esm/utils/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from './auto-reset-event';
|
|
2
|
-
export * from './base64';
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './encoding';
|
|
5
|
-
export * from './event-queue';
|
|
1
|
+
export * from './auto-reset-event.js';
|
|
2
|
+
export * from './base64.js';
|
|
3
|
+
export * from './encoding.js';
|
|
6
4
|
//# sourceMappingURL=index.js.map
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,44 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@yume-chan/adb",
|
|
3
|
+
"version": "0.0.11",
|
|
4
|
+
"description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"adb",
|
|
7
|
+
"android-phone"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "Simon Chan",
|
|
12
|
+
"email": "cnsimonchan@live.com",
|
|
13
|
+
"url": "https://chensi.moe/blog"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/yume-chan/ya-webadb/tree/master/libraries/adb#readme",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/yume-chan/ya-webadb.git",
|
|
19
|
+
"directory": "libraries/adb"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/yume-chan/ya-webadb/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "esm/index.js",
|
|
26
|
+
"types": "esm/index.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@yume-chan/async": "^2.1.4",
|
|
29
|
+
"@yume-chan/dataview-bigint-polyfill": "0.0.10",
|
|
30
|
+
"@yume-chan/event": "^0.0.10",
|
|
31
|
+
"@yume-chan/struct": "^0.0.10",
|
|
32
|
+
"tslib": "^2.3.1",
|
|
33
|
+
"web-streams-polyfill": "^3.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^17.0.17",
|
|
37
|
+
"@types/jest": "^27.4.1",
|
|
38
|
+
"@yume-chan/ts-package-builder": "^1.0.0",
|
|
39
|
+
"cross-env": "^7.0.3",
|
|
40
|
+
"jest": "^27.5.1",
|
|
41
|
+
"ts-jest": "^27.1.3",
|
|
42
|
+
"typescript": "next"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -b tsconfig.build.json",
|
|
46
|
+
"build:watch": "tsc -b tsconfig.build.json",
|
|
47
|
+
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
48
|
+
},
|
|
49
|
+
"readme": "# @yume-chan/adb\r\n\r\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n- [Compatibility](#compatibility)\r\n - [Basic usage](#basic-usage)\r\n - [Use without bundlers](#use-without-bundlers)\r\n- [Connection](#connection)\r\n - [Backend](#backend)\r\n - [`connect`](#connect)\r\n- [Authentication](#authentication)\r\n - [AdbCredentialStore](#adbcredentialstore)\r\n - [`generateKey`](#generatekey)\r\n - [`iterateKeys`](#iteratekeys)\r\n - [Implementations](#implementations)\r\n - [AdbAuthenticator](#adbauthenticator)\r\n - [`authenticate`](#authenticate)\r\n- [Stream multiplex](#stream-multiplex)\r\n - [Backend](#backend-1)\r\n- [Commands](#commands)\r\n - [childProcess](#childprocess)\r\n - [usb](#usb)\r\n - [tcpip](#tcpip)\r\n - [sync](#sync)\r\n - [LIST](#list)\r\n - [LIS2](#lis2)\r\n - [STAT](#stat)\r\n - [LST2](#lst2)\r\n - [STA2](#sta2)\r\n - [RECV](#recv)\r\n - [RCV2](#rcv2)\r\n - [SEND](#send)\r\n - [SND2](#snd2)\r\n- [Useful links](#useful-links)\r\n\r\n## Compatibility\r\n\r\nHere is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.\r\n\r\nSome features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.\r\n\r\nEach backend may have different requirements.\r\n\r\n### Basic usage\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |\r\n| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |\r\n| [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |\r\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\r\n\r\n<sup>1</sup> `uint64` and `string` used.\r\n\r\n<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.\r\n\r\n### Use without bundlers\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |\r\n| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |\r\n\r\n[MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API\r\n\r\n## Connection\r\n\r\nThis library doesn't tie to a specific transportation method.\r\n\r\nInstead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).\r\n\r\n### Backend\r\n\r\n#### `connect`\r\n\r\n```ts\r\nconnect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>\r\n```\r\n\r\nConnect to a device and create a pair of `AdbPacket` streams.\r\n\r\nThe backend is responsible for serializing and deserializing the packets, because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.\r\n\r\n## Authentication\r\n\r\nFor how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.\r\n\r\nIn this library, authentication comes in two parts:\r\n\r\n#### AdbCredentialStore\r\n\r\nAn interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)\r\n\r\n##### `generateKey`\r\n\r\n```ts\r\ngenerateKey(): ValueOrPromise<Uint8Array>\r\n```\r\n\r\nGenerate and store a RSA private key with modulus length `2048` and public exponent `65537`.\r\n\r\nThe returned `Uint8Array` is the private key in PKCS #8 format.\r\n\r\n##### `iterateKeys`\r\n\r\n```ts\r\niterateKeys(): Iterator<ArrayBuffer> | AsyncIterator<ArrayBuffer>\r\n```\r\n\r\nSynchronously or asynchronously iterate through all stored RSA private keys.\r\n\r\nEach call to `iterateKeys` must return a different iterator that iterate through all stored keys.\r\n\r\n##### Implementations\r\n\r\nThe `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.\r\n\r\n#### AdbAuthenticator\r\n\r\nAn `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.\r\n\r\nThis package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.\r\n\r\n#### `authenticate`\r\n\r\n```ts\r\nstatic async authenticate(\r\n connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,\r\n credentialStore: AdbCredentialStore,\r\n authenticators = AdbDefaultAuthenticators,\r\n): Promise<Adb>\r\n```\r\n\r\nCall this method to authenticate the connection and create an `Adb` instance.\r\n\r\nIt's possible to call `authenticate` multiple times on a single connection, every time the device receives a `CNXN` packet, it resets its internal state, and starts a new authentication process.\r\n\r\n## Stream multiplex\r\n\r\nADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.\r\n\r\n1. Client sends an `OPEN` packet to create a stream.\r\n2. Server responds with `OKAY` or `FAIL`.\r\n3. Client and server read/write on the stream.\r\n4. Client/server sends a `CLSE` to close the stream.\r\n\r\nThe `Backend` is responsible for reading and writing data from underlying source.\r\n\r\n### Backend\r\n\r\n## Commands\r\n\r\n### childProcess\r\n\r\nSpawns child process on server. ADB has two shell modes:\r\n\r\n| | Legacy mode | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Splitting stdout and stderr | No | Yes |\r\n| Returning exit code | No | Yes |\r\n| Resizing window | No | Yes |\r\n\r\nThe `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.\r\n\r\nFor simple command invocation, usually the `AdbNoneSubprocessProtocol` is enough.\r\n\r\n### usb\r\n\r\nDisable ADB over WiFi.\r\n\r\n### tcpip\r\n\r\nEnable ADB over WiFi.\r\n\r\n### sync\r\n\r\nClient and server will communicate with another protocol on the opened stream.\r\n\r\n#### LIST\r\n\r\nRequest server to list the content of a folder.\r\n\r\n#### LIS2\r\n\r\nVersion 2 of the LIST command, contains more information.\r\n\r\nSupported on devices with `ls_v2` feature.\r\n\r\n#### STAT\r\n\r\nRequest server to return the information of a file.\r\n\r\nIf path is a symbolic link, the returned information is about the link itself.\r\n\r\nSo it's actually the [`lstat`](https://linux.die.net/man/2/lstat) system call.\r\n\r\n#### LST2\r\n\r\nVersion 2 of the STAT command, contains more information.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### STA2\r\n\r\nBasically identical to LST2, but if path is a symbolic link, the information is about the file it refers to.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### RECV\r\n\r\nRequest server to send the content of a file.\r\n\r\n#### RCV2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the RECV command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n#### SEND\r\n\r\n*(Not Implemented)*\r\n\r\nSend a file onto server's file system.\r\n\r\n#### SND2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the SEND command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n## Useful links\r\n\r\n* [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)\r\n* [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)\r\n"
|
|
50
|
+
}
|