@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/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.11",
|
|
6
|
+
"tag": "@yume-chan/adb_v0.0.11",
|
|
7
|
+
"date": "Sun, 03 Apr 2022 10:54:15 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add power related API"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"comment": "Update compatibility matrix"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"comment": "Update license year"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"patch": [
|
|
21
|
+
{
|
|
22
|
+
"comment": "Update to use Web Streams API"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"comment": "Improve compatibility with Node.js 12 ESM format"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
4
30
|
{
|
|
5
31
|
"version": "0.0.10",
|
|
6
32
|
"tag": "@yume-chan/adb_v0.0.10",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @yume-chan/adb
|
|
2
2
|
|
|
3
|
-
This log was last generated on Sun,
|
|
3
|
+
This log was last generated on Sun, 03 Apr 2022 10:54:15 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.11
|
|
6
|
+
Sun, 03 Apr 2022 10:54:15 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Update to use Web Streams API
|
|
11
|
+
- Improve compatibility with Node.js 12 ESM format
|
|
12
|
+
|
|
13
|
+
### Updates
|
|
14
|
+
|
|
15
|
+
- Add power related API
|
|
16
|
+
- Update compatibility matrix
|
|
17
|
+
- Update license year
|
|
4
18
|
|
|
5
19
|
## 0.0.10
|
|
6
20
|
Sun, 09 Jan 2022 15:52:20 GMT
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -5,17 +5,18 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
|
|
|
5
5
|
**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.
|
|
6
6
|
|
|
7
7
|
- [Compatibility](#compatibility)
|
|
8
|
+
- [Basic usage](#basic-usage)
|
|
9
|
+
- [Use without bundlers](#use-without-bundlers)
|
|
8
10
|
- [Connection](#connection)
|
|
9
11
|
- [Backend](#backend)
|
|
10
12
|
- [`connect`](#connect)
|
|
11
|
-
- [`read`](#read)
|
|
12
|
-
- [`write`](#write)
|
|
13
13
|
- [Authentication](#authentication)
|
|
14
14
|
- [AdbCredentialStore](#adbcredentialstore)
|
|
15
15
|
- [`generateKey`](#generatekey)
|
|
16
16
|
- [`iterateKeys`](#iteratekeys)
|
|
17
17
|
- [Implementations](#implementations)
|
|
18
18
|
- [AdbAuthenticator](#adbauthenticator)
|
|
19
|
+
- [`authenticate`](#authenticate)
|
|
19
20
|
- [Stream multiplex](#stream-multiplex)
|
|
20
21
|
- [Backend](#backend-1)
|
|
21
22
|
- [Commands](#commands)
|
|
@@ -36,50 +37,49 @@ TypeScript implementation of Android Debug Bridge (ADB) protocol.
|
|
|
36
37
|
|
|
37
38
|
## Compatibility
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
Here is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Some features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
| --------------- | ------ | ---- | ------- | ----------------- | -------------- | ------- |
|
|
45
|
-
| **Basic usage** | 68 | 79 | 68 | No | 14<sup>1</sup> | 10.4 |
|
|
44
|
+
Each backend may have different requirements.
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
### Basic usage
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
|
|
49
|
+
| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |
|
|
50
|
+
| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |
|
|
51
|
+
| [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |
|
|
52
|
+
| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
This library doesn't tie to a specific transportation method.
|
|
54
|
+
<sup>1</sup> `uint64` and `string` used.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.
|
|
57
57
|
|
|
58
|
-
###
|
|
59
|
-
|
|
60
|
-
#### `connect`
|
|
58
|
+
### Use without bundlers
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |
|
|
61
|
+
| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |
|
|
62
|
+
| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
[MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
## Connection
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
read(length: number): ArrayBuffer | Promise<ArrayBuffer>
|
|
70
|
-
```
|
|
68
|
+
This library doesn't tie to a specific transportation method.
|
|
71
69
|
|
|
72
|
-
|
|
70
|
+
Instead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
### Backend
|
|
75
73
|
|
|
76
|
-
#### `
|
|
74
|
+
#### `connect`
|
|
77
75
|
|
|
78
76
|
```ts
|
|
79
|
-
|
|
77
|
+
connect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>
|
|
80
78
|
```
|
|
81
79
|
|
|
82
|
-
|
|
80
|
+
Connect to a device and create a pair of `AdbPacket` streams.
|
|
81
|
+
|
|
82
|
+
The 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.
|
|
83
83
|
|
|
84
84
|
## Authentication
|
|
85
85
|
|
|
@@ -87,22 +87,19 @@ For how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/web
|
|
|
87
87
|
|
|
88
88
|
In this library, authentication comes in two parts:
|
|
89
89
|
|
|
90
|
-
* `AdbCredentialStore`: because JavaScript has no unified method to generate, store and iterate crypto keys, an implementation of `AdbCredentialStore` is required for the two built-in authenticators.
|
|
91
|
-
* `AdbAuthenticator`: can be used to implement custom authentication modes.
|
|
92
|
-
|
|
93
|
-
Custom `AdbCredentialStore`s and `AdbAuthenticator`s can be specified in the `Adb#connect` method.
|
|
94
|
-
|
|
95
90
|
#### AdbCredentialStore
|
|
96
91
|
|
|
92
|
+
An interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)
|
|
93
|
+
|
|
97
94
|
##### `generateKey`
|
|
98
95
|
|
|
99
96
|
```ts
|
|
100
|
-
generateKey():
|
|
97
|
+
generateKey(): ValueOrPromise<Uint8Array>
|
|
101
98
|
```
|
|
102
99
|
|
|
103
100
|
Generate and store a RSA private key with modulus length `2048` and public exponent `65537`.
|
|
104
101
|
|
|
105
|
-
The returned `
|
|
102
|
+
The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
106
103
|
|
|
107
104
|
##### `iterateKeys`
|
|
108
105
|
|
|
@@ -116,7 +113,7 @@ Each call to `iterateKeys` must return a different iterator that iterate through
|
|
|
116
113
|
|
|
117
114
|
##### Implementations
|
|
118
115
|
|
|
119
|
-
The `@yume-chan/adb-
|
|
116
|
+
The `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.
|
|
120
117
|
|
|
121
118
|
#### AdbAuthenticator
|
|
122
119
|
|
|
@@ -124,6 +121,20 @@ An `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from se
|
|
|
124
121
|
|
|
125
122
|
This package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.
|
|
126
123
|
|
|
124
|
+
#### `authenticate`
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
static async authenticate(
|
|
128
|
+
connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,
|
|
129
|
+
credentialStore: AdbCredentialStore,
|
|
130
|
+
authenticators = AdbDefaultAuthenticators,
|
|
131
|
+
): Promise<Adb>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Call this method to authenticate the connection and create an `Adb` instance.
|
|
135
|
+
|
|
136
|
+
It'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.
|
|
137
|
+
|
|
127
138
|
## Stream multiplex
|
|
128
139
|
|
|
129
140
|
ADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.
|
|
@@ -143,16 +154,18 @@ The `Backend` is responsible for reading and writing data from underlying source
|
|
|
143
154
|
|
|
144
155
|
Spawns child process on server. ADB has two shell modes:
|
|
145
156
|
|
|
146
|
-
| | Legacy mode
|
|
147
|
-
| --------------------------- |
|
|
148
|
-
| Feature flag | -
|
|
149
|
-
| Implementation | `
|
|
150
|
-
| Splitting stdout and stderr | No
|
|
151
|
-
| Returning exit code | No
|
|
152
|
-
| Resizing window | No
|
|
157
|
+
| | Legacy mode | Shell Protocol |
|
|
158
|
+
| --------------------------- | --------------------------- | ---------------------------- |
|
|
159
|
+
| Feature flag | - | `shell_v2` |
|
|
160
|
+
| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |
|
|
161
|
+
| Splitting stdout and stderr | No | Yes |
|
|
162
|
+
| Returning exit code | No | Yes |
|
|
163
|
+
| Resizing window | No | Yes |
|
|
153
164
|
|
|
154
165
|
The `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.
|
|
155
166
|
|
|
167
|
+
For simple command invocation, usually the `AdbNoneSubprocessProtocol` is enough.
|
|
168
|
+
|
|
156
169
|
### usb
|
|
157
170
|
|
|
158
171
|
Disable ADB over WiFi.
|
package/esm/adb.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type AdbCredentialStore } from './auth.js';
|
|
2
|
+
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, type AdbFrameBuffer } from './commands/index.js';
|
|
3
|
+
import { AdbFeatures } from './features.js';
|
|
4
|
+
import { type AdbPacketCore, type AdbPacketInit } from './packet.js';
|
|
5
|
+
import { AdbSocket } from './socket/index.js';
|
|
6
|
+
import { WritableStream, type ReadableWritablePair } from "./stream/index.js";
|
|
7
|
+
export declare enum AdbPropKey {
|
|
8
|
+
Product = "ro.product.name",
|
|
9
|
+
Model = "ro.product.model",
|
|
10
|
+
Device = "ro.product.device",
|
|
11
|
+
Features = "features"
|
|
12
|
+
}
|
|
13
|
+
export declare const VERSION_OMIT_CHECKSUM = 16777217;
|
|
14
|
+
export declare class Adb {
|
|
15
|
+
/**
|
|
16
|
+
* It's possible to call `authenticate` multiple times on a single connection,
|
|
17
|
+
* every time the device receives a `CNXN` packet, it resets its internal state,
|
|
18
|
+
* and starts a new authentication process.
|
|
19
|
+
*/
|
|
20
|
+
static authenticate(connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>, credentialStore: AdbCredentialStore, authenticators?: import("./auth.js").AdbAuthenticator[]): Promise<Adb>;
|
|
21
|
+
private readonly packetDispatcher;
|
|
22
|
+
get disconnected(): Promise<void>;
|
|
23
|
+
private _protocolVersion;
|
|
24
|
+
get protocolVersion(): number | undefined;
|
|
25
|
+
private _product;
|
|
26
|
+
get product(): string | undefined;
|
|
27
|
+
private _model;
|
|
28
|
+
get model(): string | undefined;
|
|
29
|
+
private _device;
|
|
30
|
+
get device(): string | undefined;
|
|
31
|
+
private _features;
|
|
32
|
+
get features(): AdbFeatures[] | undefined;
|
|
33
|
+
readonly subprocess: AdbSubprocess;
|
|
34
|
+
readonly power: AdbPower;
|
|
35
|
+
readonly reverse: AdbReverseCommand;
|
|
36
|
+
readonly tcpip: AdbTcpIpCommand;
|
|
37
|
+
constructor(connection: ReadableWritablePair<AdbPacketCore, AdbPacketInit>, version: number, maxPayloadSize: number, banner: string);
|
|
38
|
+
private parseBanner;
|
|
39
|
+
getProp(key: string): Promise<string>;
|
|
40
|
+
rm(...filenames: string[]): Promise<string>;
|
|
41
|
+
install(): WritableStream<Uint8Array>;
|
|
42
|
+
sync(): Promise<AdbSync>;
|
|
43
|
+
framebuffer(): Promise<AdbFrameBuffer>;
|
|
44
|
+
createSocket(service: string): Promise<AdbSocket>;
|
|
45
|
+
createSocketAndWait(service: string): Promise<string>;
|
|
46
|
+
dispose(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=adb.d.ts.map
|
package/esm/adb.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adb.d.ts","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AACA,OAAO,EAAsD,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAmC,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjK,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAA4C,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC/G,OAAO,EAAuB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAyD,cAAc,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGrI,oBAAY,UAAU;IAClB,OAAO,oBAAoB;IAC3B,KAAK,qBAAqB;IAC1B,MAAM,sBAAsB;IAC5B,QAAQ,aAAa;CACxB;AAED,eAAO,MAAM,qBAAqB,WAAa,CAAC;AAEhD,qBAAa,GAAG;IACZ;;;;OAIG;WACiB,YAAY,CAC5B,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9D,eAAe,EAAE,kBAAkB,EACnC,cAAc,yCAA2B,GAC1C,OAAO,CAAC,GAAG,CAAC;IA4Ff,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAsB;IAEvD,IAAW,YAAY,kBAAiD;IAExE,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,IAAW,eAAe,uBAAoC;IAE9D,OAAO,CAAC,QAAQ,CAAqB;IACrC,IAAW,OAAO,uBAA4B;IAE9C,OAAO,CAAC,MAAM,CAAqB;IACnC,IAAW,KAAK,uBAA0B;IAE1C,OAAO,CAAC,OAAO,CAAqB;IACpC,IAAW,MAAM,uBAA2B;IAE5C,OAAO,CAAC,SAAS,CAA4B;IAC7C,IAAW,QAAQ,8BAA6B;IAEhD,SAAgB,UAAU,EAAE,aAAa,CAAC;IAC1C,SAAgB,KAAK,EAAE,QAAQ,CAAC;IAChC,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,SAAgB,KAAK,EAAE,eAAe,CAAC;gBAGnC,UAAU,EAAE,oBAAoB,CAAC,aAAa,EAAE,aAAa,CAAC,EAC9D,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM;IAoBlB,OAAO,CAAC,WAAW;IAmCN,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOrC,EAAE,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAOjD,OAAO;IAID,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAKxB,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC;IAItC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIjD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IASrD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAGxC"}
|
package/esm/adb.js
CHANGED
|
@@ -1,121 +1,134 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
1
|
import { PromiseResolver } from '@yume-chan/async';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { decodeUtf8 } from "./utils";
|
|
2
|
+
import { AdbAuthenticationHandler, AdbDefaultAuthenticators } from './auth.js';
|
|
3
|
+
import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install } from './commands/index.js';
|
|
4
|
+
import { AdbFeatures } from './features.js';
|
|
5
|
+
import { AdbCommand, calculateChecksum } from './packet.js';
|
|
6
|
+
import { AdbPacketDispatcher } from './socket/index.js';
|
|
7
|
+
import { AbortController, DecodeUtf8Stream, GatherStringStream, WritableStream } from "./stream/index.js";
|
|
8
|
+
import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
|
|
10
9
|
export var AdbPropKey;
|
|
11
10
|
(function (AdbPropKey) {
|
|
12
11
|
AdbPropKey["Product"] = "ro.product.name";
|
|
13
12
|
AdbPropKey["Model"] = "ro.product.model";
|
|
14
13
|
AdbPropKey["Device"] = "ro.product.device";
|
|
15
14
|
AdbPropKey["Features"] = "features";
|
|
16
|
-
})(AdbPropKey || (AdbPropKey = {}));
|
|
15
|
+
})(AdbPropKey = AdbPropKey || (AdbPropKey = {}));
|
|
16
|
+
export const VERSION_OMIT_CHECKSUM = 0x01000001;
|
|
17
17
|
export class Adb {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
/**
|
|
19
|
+
* It's possible to call `authenticate` multiple times on a single connection,
|
|
20
|
+
* every time the device receives a `CNXN` packet, it resets its internal state,
|
|
21
|
+
* and starts a new authentication process.
|
|
22
|
+
*/
|
|
23
|
+
static async authenticate(connection, credentialStore, authenticators = AdbDefaultAuthenticators) {
|
|
24
|
+
let version = 0x01000001;
|
|
25
|
+
let maxPayloadSize = 0x100000;
|
|
26
|
+
const features = [
|
|
27
|
+
'shell_v2',
|
|
28
|
+
'cmd',
|
|
29
|
+
AdbFeatures.StatV2,
|
|
30
|
+
'ls_v2',
|
|
31
|
+
'fixed_push_mkdir',
|
|
32
|
+
'apex',
|
|
33
|
+
'abb',
|
|
34
|
+
'fixed_push_symlink_timestamp',
|
|
35
|
+
'abb_exec',
|
|
36
|
+
'remount_shell',
|
|
37
|
+
'track_app',
|
|
38
|
+
'sendrecv_v2',
|
|
39
|
+
'sendrecv_v2_brotli',
|
|
40
|
+
'sendrecv_v2_lz4',
|
|
41
|
+
'sendrecv_v2_zstd',
|
|
42
|
+
'sendrecv_v2_dry_run_send',
|
|
43
|
+
].join(',');
|
|
44
|
+
const resolver = new PromiseResolver();
|
|
45
|
+
const authHandler = new AdbAuthenticationHandler(authenticators, credentialStore);
|
|
46
|
+
const abortController = new AbortController();
|
|
47
|
+
const pipe = connection.readable
|
|
48
|
+
.pipeTo(new WritableStream({
|
|
49
|
+
async write(packet) {
|
|
50
|
+
switch (packet.command) {
|
|
51
|
+
case AdbCommand.Connect:
|
|
52
|
+
version = Math.min(version, packet.arg0);
|
|
53
|
+
maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
|
|
54
|
+
resolver.resolve(decodeUtf8(packet.payload));
|
|
55
|
+
break;
|
|
56
|
+
case AdbCommand.Auth:
|
|
57
|
+
const response = await authHandler.handle(packet);
|
|
58
|
+
await sendPacket(response);
|
|
59
|
+
break;
|
|
60
|
+
case AdbCommand.Close:
|
|
61
|
+
// Last connection was interrupted
|
|
62
|
+
// Ignore this packet, device will recover
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
throw new Error('Device not in correct state. Reconnect your device and try again');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}), {
|
|
69
|
+
preventCancel: true,
|
|
70
|
+
signal: abortController.signal,
|
|
71
|
+
})
|
|
72
|
+
.catch((e) => { resolver.reject(e); });
|
|
73
|
+
const writer = connection.writable.getWriter();
|
|
74
|
+
async function sendPacket(init) {
|
|
75
|
+
// Always send checksum in auth steps
|
|
76
|
+
// Because we don't know if the device will ignore it yet.
|
|
77
|
+
await writer.write(calculateChecksum(init));
|
|
78
|
+
}
|
|
79
|
+
await sendPacket({
|
|
80
|
+
command: AdbCommand.Connect,
|
|
81
|
+
arg0: version,
|
|
82
|
+
arg1: maxPayloadSize,
|
|
83
|
+
// The terminating `;` is required in formal definition
|
|
84
|
+
// But ADB daemon (all versions) can still work without it
|
|
85
|
+
payload: encodeUtf8(`host::features=${features};`),
|
|
86
|
+
});
|
|
87
|
+
try {
|
|
88
|
+
const banner = await resolver.promise;
|
|
89
|
+
// Stop piping before creating Adb object
|
|
90
|
+
// Because AdbPacketDispatcher will try to lock the streams when initializing
|
|
91
|
+
abortController.abort();
|
|
92
|
+
await pipe;
|
|
93
|
+
writer.releaseLock();
|
|
94
|
+
return new Adb(connection, version, maxPayloadSize, banner);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
abortController.abort();
|
|
98
|
+
writer.releaseLock();
|
|
99
|
+
}
|
|
27
100
|
}
|
|
28
|
-
|
|
29
|
-
get
|
|
30
|
-
|
|
31
|
-
get name() { return this.backend.name; }
|
|
101
|
+
packetDispatcher;
|
|
102
|
+
get disconnected() { return this.packetDispatcher.disconnected; }
|
|
103
|
+
_protocolVersion;
|
|
32
104
|
get protocolVersion() { return this._protocolVersion; }
|
|
105
|
+
_product;
|
|
33
106
|
get product() { return this._product; }
|
|
107
|
+
_model;
|
|
34
108
|
get model() { return this._model; }
|
|
109
|
+
_device;
|
|
35
110
|
get device() { return this._device; }
|
|
111
|
+
_features;
|
|
36
112
|
get features() { return this._features; }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'fixed_push_symlink_timestamp',
|
|
57
|
-
'abb_exec',
|
|
58
|
-
'remount_shell',
|
|
59
|
-
'track_app',
|
|
60
|
-
'sendrecv_v2',
|
|
61
|
-
'sendrecv_v2_brotli',
|
|
62
|
-
'sendrecv_v2_lz4',
|
|
63
|
-
'sendrecv_v2_zstd',
|
|
64
|
-
'sendrecv_v2_dry_run_send',
|
|
65
|
-
].join(',');
|
|
66
|
-
const resolver = new PromiseResolver();
|
|
67
|
-
const authHandler = new AdbAuthenticationHandler(authenticators, credentialStore);
|
|
68
|
-
const disposableList = new DisposableList();
|
|
69
|
-
disposableList.add(this.packetDispatcher.onPacket((e) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
e.handled = true;
|
|
71
|
-
const { packet } = e;
|
|
72
|
-
try {
|
|
73
|
-
switch (packet.command) {
|
|
74
|
-
case AdbCommand.Connect:
|
|
75
|
-
this.packetDispatcher.maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
|
|
76
|
-
const finalVersion = Math.min(version, packet.arg0);
|
|
77
|
-
this._protocolVersion = finalVersion;
|
|
78
|
-
if (finalVersion >= versionNoChecksum) {
|
|
79
|
-
this.packetDispatcher.calculateChecksum = false;
|
|
80
|
-
// Android prior to 9.0.0 uses char* to parse service string
|
|
81
|
-
// thus requires an extra null character
|
|
82
|
-
this.packetDispatcher.appendNullToServiceString = false;
|
|
83
|
-
}
|
|
84
|
-
this.parseBanner(decodeUtf8(packet.payload));
|
|
85
|
-
resolver.resolve();
|
|
86
|
-
break;
|
|
87
|
-
case AdbCommand.Auth:
|
|
88
|
-
const authPacket = yield authHandler.handle(e.packet);
|
|
89
|
-
yield this.packetDispatcher.sendPacket(authPacket);
|
|
90
|
-
break;
|
|
91
|
-
case AdbCommand.Close:
|
|
92
|
-
// Last connection was interrupted
|
|
93
|
-
// Ignore this packet, device will recover
|
|
94
|
-
break;
|
|
95
|
-
default:
|
|
96
|
-
throw new Error('Device not in correct state. Reconnect your device and try again');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
resolver.reject(e);
|
|
101
|
-
}
|
|
102
|
-
})));
|
|
103
|
-
disposableList.add(this.packetDispatcher.onError(e => {
|
|
104
|
-
resolver.reject(e);
|
|
105
|
-
}));
|
|
106
|
-
// Android prior 9.0.0 requires the null character
|
|
107
|
-
// Newer versions can also handle the null character
|
|
108
|
-
// The terminating `;` is required in formal definition
|
|
109
|
-
// But ADB daemon can also work without it
|
|
110
|
-
yield this.packetDispatcher.sendPacket(AdbCommand.Connect, version, maxPayloadSize, `host::features=${features};\0`);
|
|
111
|
-
try {
|
|
112
|
-
yield resolver.promise;
|
|
113
|
-
this._connected = true;
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
disposableList.dispose();
|
|
117
|
-
}
|
|
118
|
-
});
|
|
113
|
+
subprocess;
|
|
114
|
+
power;
|
|
115
|
+
reverse;
|
|
116
|
+
tcpip;
|
|
117
|
+
constructor(connection, version, maxPayloadSize, banner) {
|
|
118
|
+
this.parseBanner(banner);
|
|
119
|
+
this.packetDispatcher = new AdbPacketDispatcher(connection);
|
|
120
|
+
this._protocolVersion = version;
|
|
121
|
+
if (version >= VERSION_OMIT_CHECKSUM) {
|
|
122
|
+
this.packetDispatcher.calculateChecksum = false;
|
|
123
|
+
// Android prior to 9.0.0 uses char* to parse service string
|
|
124
|
+
// thus requires an extra null character
|
|
125
|
+
this.packetDispatcher.appendNullToServiceString = false;
|
|
126
|
+
}
|
|
127
|
+
this.packetDispatcher.maxPayloadSize = maxPayloadSize;
|
|
128
|
+
this.subprocess = new AdbSubprocess(this);
|
|
129
|
+
this.power = new AdbPower(this);
|
|
130
|
+
this.reverse = new AdbReverseCommand(this.packetDispatcher);
|
|
131
|
+
this.tcpip = new AdbTcpIpCommand(this);
|
|
119
132
|
}
|
|
120
133
|
parseBanner(banner) {
|
|
121
134
|
this._features = [];
|
|
@@ -148,55 +161,37 @@ export class Adb {
|
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
|
-
getProp(key) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return output.trim();
|
|
155
|
-
});
|
|
164
|
+
async getProp(key) {
|
|
165
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy(['getprop', key]);
|
|
166
|
+
return stdout.trim();
|
|
156
167
|
}
|
|
157
|
-
rm(...filenames) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
168
|
+
async rm(...filenames) {
|
|
169
|
+
const stdout = await this.subprocess.spawnAndWaitLegacy(['rm', '-rf', ...filenames.map(arg => escapeArg(arg))]);
|
|
170
|
+
return stdout;
|
|
161
171
|
}
|
|
162
|
-
install(
|
|
163
|
-
return
|
|
164
|
-
return yield install(this, apk, onProgress);
|
|
165
|
-
});
|
|
172
|
+
install() {
|
|
173
|
+
return install(this);
|
|
166
174
|
}
|
|
167
|
-
sync() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return new AdbSync(this, socket);
|
|
171
|
-
});
|
|
175
|
+
async sync() {
|
|
176
|
+
const socket = await this.createSocket('sync:');
|
|
177
|
+
return new AdbSync(this, socket);
|
|
172
178
|
}
|
|
173
|
-
framebuffer() {
|
|
174
|
-
return
|
|
175
|
-
return framebuffer(this);
|
|
176
|
-
});
|
|
179
|
+
async framebuffer() {
|
|
180
|
+
return framebuffer(this);
|
|
177
181
|
}
|
|
178
|
-
createSocket(service) {
|
|
179
|
-
return
|
|
180
|
-
return this.packetDispatcher.createSocket(service);
|
|
181
|
-
});
|
|
182
|
+
async createSocket(service) {
|
|
183
|
+
return this.packetDispatcher.createSocket(service);
|
|
182
184
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
socket.onClose(() => resolver.resolve(result));
|
|
192
|
-
return resolver.promise;
|
|
193
|
-
});
|
|
185
|
+
async createSocketAndWait(service) {
|
|
186
|
+
const socket = await this.createSocket(service);
|
|
187
|
+
const gatherStream = new GatherStringStream();
|
|
188
|
+
await socket.readable
|
|
189
|
+
.pipeThrough(new DecodeUtf8Stream())
|
|
190
|
+
.pipeTo(gatherStream.writable);
|
|
191
|
+
return gatherStream.result;
|
|
194
192
|
}
|
|
195
|
-
dispose() {
|
|
196
|
-
|
|
197
|
-
this.packetDispatcher.dispose();
|
|
198
|
-
yield this.backend.dispose();
|
|
199
|
-
});
|
|
193
|
+
async dispose() {
|
|
194
|
+
this.packetDispatcher.dispose();
|
|
200
195
|
}
|
|
201
196
|
}
|
|
202
197
|
//# sourceMappingURL=adb.js.map
|