@yume-chan/adb 0.0.17 → 0.0.19
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 +27 -0
- package/CHANGELOG.md +16 -1
- package/LICENSE +1 -1
- package/esm/adb.d.ts +63 -60
- package/esm/adb.d.ts.map +1 -1
- package/esm/adb.js +257 -229
- package/esm/adb.js.map +1 -1
- package/esm/auth.d.ts +51 -51
- package/esm/auth.d.ts.map +1 -1
- package/esm/auth.js +95 -96
- package/esm/auth.js.map +1 -1
- package/esm/backend.d.ts +8 -8
- package/esm/backend.d.ts.map +1 -1
- package/esm/backend.js +1 -1
- package/esm/commands/base.d.ts +6 -6
- package/esm/commands/base.js +8 -8
- package/esm/commands/framebuffer.d.ts +53 -53
- package/esm/commands/framebuffer.d.ts.map +1 -1
- package/esm/commands/framebuffer.js +46 -47
- package/esm/commands/framebuffer.js.map +1 -1
- package/esm/commands/index.d.ts +7 -8
- package/esm/commands/index.d.ts.map +1 -1
- package/esm/commands/index.js +7 -8
- package/esm/commands/index.js.map +1 -1
- package/esm/commands/install.d.ts +9 -3
- package/esm/commands/install.d.ts.map +1 -1
- package/esm/commands/install.js +27 -21
- package/esm/commands/install.js.map +1 -1
- package/esm/commands/power.d.ts +22 -22
- package/esm/commands/power.d.ts.map +1 -1
- package/esm/commands/power.js +48 -44
- package/esm/commands/power.js.map +1 -1
- package/esm/commands/reverse.d.ts +41 -28
- package/esm/commands/reverse.d.ts.map +1 -1
- package/esm/commands/reverse.js +125 -98
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/subprocess/command.d.ts +57 -51
- package/esm/commands/subprocess/command.d.ts.map +1 -1
- package/esm/commands/subprocess/command.js +86 -82
- package/esm/commands/subprocess/command.js.map +1 -1
- package/esm/commands/subprocess/index.d.ts +3 -3
- package/esm/commands/subprocess/index.js +3 -3
- package/esm/commands/subprocess/protocols/index.d.ts +3 -3
- package/esm/commands/subprocess/protocols/index.js +3 -3
- package/esm/commands/subprocess/protocols/none.d.ts +35 -35
- package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/none.js +65 -55
- package/esm/commands/subprocess/protocols/none.js.map +1 -1
- package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
- package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/shell.js +166 -154
- package/esm/commands/subprocess/protocols/shell.js.map +1 -1
- package/esm/commands/subprocess/protocols/types.d.ts +49 -49
- package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
- package/esm/commands/subprocess/protocols/types.js +1 -1
- package/esm/commands/subprocess/utils.d.ts +1 -1
- package/esm/commands/subprocess/utils.js +18 -18
- package/esm/commands/sync/index.d.ts +8 -7
- package/esm/commands/sync/index.d.ts.map +1 -1
- package/esm/commands/sync/index.js +8 -7
- package/esm/commands/sync/index.js.map +1 -1
- package/esm/commands/sync/list.d.ts +42 -40
- package/esm/commands/sync/list.d.ts.map +1 -1
- package/esm/commands/sync/list.js +67 -35
- package/esm/commands/sync/list.js.map +1 -1
- package/esm/commands/sync/pull.d.ts +13 -11
- package/esm/commands/sync/pull.d.ts.map +1 -1
- package/esm/commands/sync/pull.js +35 -36
- package/esm/commands/sync/pull.js.map +1 -1
- package/esm/commands/sync/push.d.ts +46 -7
- package/esm/commands/sync/push.d.ts.map +1 -1
- package/esm/commands/sync/push.js +89 -23
- package/esm/commands/sync/push.js.map +1 -1
- package/esm/commands/sync/request.d.ts +26 -23
- package/esm/commands/sync/request.d.ts.map +1 -1
- package/esm/commands/sync/request.js +40 -42
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.d.ts +19 -19
- package/esm/commands/sync/response.d.ts.map +1 -1
- package/esm/commands/sync/response.js +54 -54
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/socket.d.ts +27 -0
- package/esm/commands/sync/socket.d.ts.map +1 -0
- package/esm/commands/sync/socket.js +66 -0
- package/esm/commands/sync/socket.js.map +1 -0
- package/esm/commands/sync/stat.d.ts +72 -72
- package/esm/commands/sync/stat.d.ts.map +1 -1
- package/esm/commands/sync/stat.js +116 -94
- package/esm/commands/sync/stat.js.map +1 -1
- package/esm/commands/sync/sync.d.ts +72 -60
- package/esm/commands/sync/sync.d.ts.map +1 -1
- package/esm/commands/sync/sync.js +127 -148
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/commands/tcpip.d.ts +5 -5
- package/esm/commands/tcpip.js +18 -18
- package/esm/crypto.d.ts +36 -36
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js +248 -238
- package/esm/crypto.js.map +1 -1
- package/esm/features.d.ts +10 -7
- package/esm/features.d.ts.map +1 -1
- package/esm/features.js +13 -10
- package/esm/features.js.map +1 -1
- package/esm/index.d.ts +9 -9
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +9 -9
- package/esm/index.js.map +1 -1
- package/esm/packet.d.ts +45 -46
- package/esm/packet.d.ts.map +1 -1
- package/esm/packet.js +43 -46
- package/esm/packet.js.map +1 -1
- package/esm/socket/dispatcher.d.ts +59 -59
- package/esm/socket/dispatcher.d.ts.map +1 -1
- package/esm/socket/dispatcher.js +223 -231
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/socket/index.d.ts +2 -2
- package/esm/socket/index.js +2 -2
- package/esm/socket/socket.d.ts +59 -59
- package/esm/socket/socket.d.ts.map +1 -1
- package/esm/socket/socket.js +118 -98
- package/esm/socket/socket.js.map +1 -1
- package/esm/utils/auto-reset-event.d.ts +9 -9
- package/esm/utils/auto-reset-event.d.ts.map +1 -1
- package/esm/utils/auto-reset-event.js +33 -33
- package/esm/utils/auto-reset-event.js.map +1 -1
- package/esm/utils/base64.d.ts +27 -27
- package/esm/utils/base64.d.ts.map +1 -1
- package/esm/utils/base64.js +246 -245
- package/esm/utils/base64.js.map +1 -1
- package/esm/utils/conditional-variable.d.ts +9 -0
- package/esm/utils/conditional-variable.d.ts.map +1 -0
- package/esm/utils/conditional-variable.js +34 -0
- package/esm/utils/conditional-variable.js.map +1 -0
- package/esm/utils/index.d.ts +4 -3
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +4 -3
- package/esm/utils/index.js.map +1 -1
- package/package.json +17 -13
- package/src/adb.ts +160 -101
- package/src/auth.ts +31 -22
- package/src/backend.ts +6 -4
- package/src/commands/base.ts +2 -2
- package/src/commands/framebuffer.ts +37 -41
- package/src/commands/index.ts +7 -8
- package/src/commands/power.ts +15 -11
- package/src/commands/reverse.ts +74 -30
- package/src/commands/subprocess/command.ts +34 -23
- package/src/commands/subprocess/index.ts +3 -3
- package/src/commands/subprocess/protocols/index.ts +3 -3
- package/src/commands/subprocess/protocols/none.ts +26 -11
- package/src/commands/subprocess/protocols/shell.ts +110 -56
- package/src/commands/subprocess/protocols/types.ts +10 -6
- package/src/commands/subprocess/utils.ts +1 -1
- package/src/commands/sync/index.ts +8 -7
- package/src/commands/sync/list.ts +74 -28
- package/src/commands/sync/pull.ts +49 -37
- package/src/commands/sync/push.ts +153 -32
- package/src/commands/sync/request.ts +37 -34
- package/src/commands/sync/response.ts +34 -27
- package/src/commands/sync/socket.ts +97 -0
- package/src/commands/sync/stat.ts +98 -70
- package/src/commands/sync/sync.ts +78 -97
- package/src/commands/tcpip.ts +5 -5
- package/src/crypto.ts +60 -32
- package/src/features.ts +9 -6
- package/src/index.ts +9 -10
- package/src/packet.ts +41 -46
- package/src/socket/dispatcher.ts +130 -108
- package/src/socket/index.ts +2 -2
- package/src/socket/socket.ts +84 -34
- package/src/utils/auto-reset-event.ts +16 -17
- package/src/utils/base64.ts +51 -41
- package/src/utils/conditional-variable.ts +45 -0
- package/src/utils/index.ts +4 -3
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/src/commands/install.ts +0 -32
package/esm/socket/dispatcher.js
CHANGED
|
@@ -1,232 +1,224 @@
|
|
|
1
|
-
import { AsyncOperationManager, PromiseResolver } from
|
|
2
|
-
import { AbortController, WritableStream } from
|
|
3
|
-
import { EMPTY_UINT8_ARRAY } from
|
|
4
|
-
import { AdbCommand, calculateChecksum } from
|
|
5
|
-
import { decodeUtf8, encodeUtf8 } from
|
|
6
|
-
import { AdbSocketController } from
|
|
7
|
-
/**
|
|
8
|
-
* The dispatcher is the "dumb" part of the connection handling logic.
|
|
9
|
-
*
|
|
10
|
-
* Except some options to change some minor behaviors,
|
|
11
|
-
* its only job is forwarding packets between authenticated underlying streams
|
|
12
|
-
* and abstracted socket objects.
|
|
13
|
-
*
|
|
14
|
-
* The `Adb` class is responsible for doing the authentication,
|
|
15
|
-
* negotiating the options, and has shortcuts to high-level services.
|
|
16
|
-
*/
|
|
17
|
-
export class AdbPacketDispatcher {
|
|
18
|
-
// ADB socket id starts from 1
|
|
19
|
-
// (0 means open failed)
|
|
20
|
-
initializers = new AsyncOperationManager(1);
|
|
21
|
-
/**
|
|
22
|
-
* Socket local ID to the socket controller.
|
|
23
|
-
*/
|
|
24
|
-
sockets = new Map();
|
|
25
|
-
_writer;
|
|
26
|
-
options;
|
|
27
|
-
_closed = false;
|
|
28
|
-
_disconnected = new PromiseResolver();
|
|
29
|
-
get disconnected() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
socket
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
* CLOSE()
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
//
|
|
129
|
-
// the
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
*
|
|
134
|
-
* @
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
this.initializers.
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
dispose() {
|
|
226
|
-
for (const socket of this.sockets.values()) {
|
|
227
|
-
socket.dispose();
|
|
228
|
-
}
|
|
229
|
-
this._disconnected.resolve();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
1
|
+
import { AsyncOperationManager, PromiseResolver } from "@yume-chan/async";
|
|
2
|
+
import { AbortController, ConsumableWritableStream, WritableStream, } from "@yume-chan/stream-extra";
|
|
3
|
+
import { EMPTY_UINT8_ARRAY } from "@yume-chan/struct";
|
|
4
|
+
import { AdbCommand, calculateChecksum } from "../packet.js";
|
|
5
|
+
import { decodeUtf8, encodeUtf8 } from "../utils/index.js";
|
|
6
|
+
import { AdbSocketController } from "./socket.js";
|
|
7
|
+
/**
|
|
8
|
+
* The dispatcher is the "dumb" part of the connection handling logic.
|
|
9
|
+
*
|
|
10
|
+
* Except some options to change some minor behaviors,
|
|
11
|
+
* its only job is forwarding packets between authenticated underlying streams
|
|
12
|
+
* and abstracted socket objects.
|
|
13
|
+
*
|
|
14
|
+
* The `Adb` class is responsible for doing the authentication,
|
|
15
|
+
* negotiating the options, and has shortcuts to high-level services.
|
|
16
|
+
*/
|
|
17
|
+
export class AdbPacketDispatcher {
|
|
18
|
+
// ADB socket id starts from 1
|
|
19
|
+
// (0 means open failed)
|
|
20
|
+
initializers = new AsyncOperationManager(1);
|
|
21
|
+
/**
|
|
22
|
+
* Socket local ID to the socket controller.
|
|
23
|
+
*/
|
|
24
|
+
sockets = new Map();
|
|
25
|
+
_writer;
|
|
26
|
+
options;
|
|
27
|
+
_closed = false;
|
|
28
|
+
_disconnected = new PromiseResolver();
|
|
29
|
+
get disconnected() {
|
|
30
|
+
return this._disconnected.promise;
|
|
31
|
+
}
|
|
32
|
+
_incomingSocketHandlers = new Set();
|
|
33
|
+
_abortController = new AbortController();
|
|
34
|
+
constructor(connection, options) {
|
|
35
|
+
this.options = options;
|
|
36
|
+
connection.readable
|
|
37
|
+
.pipeTo(new WritableStream({
|
|
38
|
+
write: async (packet) => {
|
|
39
|
+
switch (packet.command) {
|
|
40
|
+
case AdbCommand.OK:
|
|
41
|
+
this.handleOk(packet);
|
|
42
|
+
break;
|
|
43
|
+
case AdbCommand.Close:
|
|
44
|
+
await this.handleClose(packet);
|
|
45
|
+
break;
|
|
46
|
+
case AdbCommand.Write:
|
|
47
|
+
if (this.sockets.has(packet.arg1)) {
|
|
48
|
+
await this.sockets
|
|
49
|
+
.get(packet.arg1)
|
|
50
|
+
.enqueue(packet.payload);
|
|
51
|
+
await this.sendPacket(AdbCommand.OK, packet.arg1, packet.arg0);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Unknown local socket id: ${packet.arg1}`);
|
|
55
|
+
case AdbCommand.Open:
|
|
56
|
+
await this.handleOpen(packet);
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
// Junk data may only appear in the authentication phase,
|
|
60
|
+
// since the dispatcher only works after authentication,
|
|
61
|
+
// all packets should have a valid command.
|
|
62
|
+
// (although it's possible that Adb added new commands in the future)
|
|
63
|
+
throw new Error(`Unknown command: ${packet.command.toString(16)}`);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
}), {
|
|
67
|
+
// There are multiple reasons for the pipe to stop,
|
|
68
|
+
// (device disconnection, protocol error, or user abortion)
|
|
69
|
+
// if the underlying streams are still open,
|
|
70
|
+
// it's still possible to create another ADB connection.
|
|
71
|
+
// So don't close `readable` here.
|
|
72
|
+
preventCancel: true,
|
|
73
|
+
signal: this._abortController.signal,
|
|
74
|
+
})
|
|
75
|
+
.then(() => {
|
|
76
|
+
this.dispose();
|
|
77
|
+
}, (e) => {
|
|
78
|
+
if (!this._closed) {
|
|
79
|
+
this._disconnected.reject(e);
|
|
80
|
+
}
|
|
81
|
+
this.dispose();
|
|
82
|
+
});
|
|
83
|
+
this._writer = connection.writable.getWriter();
|
|
84
|
+
}
|
|
85
|
+
handleOk(packet) {
|
|
86
|
+
if (this.initializers.resolve(packet.arg1, packet.arg0)) {
|
|
87
|
+
// Device successfully created the socket
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const socket = this.sockets.get(packet.arg1);
|
|
91
|
+
if (socket) {
|
|
92
|
+
// Device has received last `WRTE` to the socket
|
|
93
|
+
socket.ack();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Maybe the device is responding to a packet of last connection
|
|
97
|
+
// Tell the device to close the socket
|
|
98
|
+
void this.sendPacket(AdbCommand.Close, packet.arg1, packet.arg0);
|
|
99
|
+
}
|
|
100
|
+
async handleClose(packet) {
|
|
101
|
+
// If the socket is still pending
|
|
102
|
+
if (packet.arg0 === 0 &&
|
|
103
|
+
this.initializers.reject(packet.arg1, new Error("Socket open failed"))) {
|
|
104
|
+
// Device failed to create the socket
|
|
105
|
+
// (unknown service string, failed to execute command, etc.)
|
|
106
|
+
// it doesn't break the connection,
|
|
107
|
+
// so only reject the socket creation promise,
|
|
108
|
+
// don't throw an error here.
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// From https://android.googlesource.com/platform/packages/modules/adb/+/65d18e2c1cc48b585811954892311b28a4c3d188/adb.cpp#459
|
|
112
|
+
/* According to protocol.txt, p->msg.arg0 might be 0 to indicate
|
|
113
|
+
* a failed OPEN only. However, due to a bug in previous ADB
|
|
114
|
+
* versions, CLOSE(0, remote-id, "") was also used for normal
|
|
115
|
+
* CLOSE() operations.
|
|
116
|
+
*/
|
|
117
|
+
// Ignore `arg0` and search for the socket
|
|
118
|
+
const socket = this.sockets.get(packet.arg1);
|
|
119
|
+
if (socket) {
|
|
120
|
+
// The device want to close the socket
|
|
121
|
+
if (!socket.closed) {
|
|
122
|
+
await this.sendPacket(AdbCommand.Close, packet.arg1, packet.arg0);
|
|
123
|
+
}
|
|
124
|
+
await socket.dispose();
|
|
125
|
+
this.sockets.delete(packet.arg1);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// TODO: adb: is double closing an socket a catastrophic error?
|
|
129
|
+
// If the client sends two `CLSE` packets for one socket,
|
|
130
|
+
// the device may also respond with two `CLSE` packets.
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Add a handler for incoming socket.
|
|
134
|
+
* @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
|
|
135
|
+
* @returns A function to remove the handler.
|
|
136
|
+
*/
|
|
137
|
+
onIncomingSocket(handler) {
|
|
138
|
+
this._incomingSocketHandlers.add(handler);
|
|
139
|
+
const remove = () => {
|
|
140
|
+
this._incomingSocketHandlers.delete(handler);
|
|
141
|
+
};
|
|
142
|
+
remove.dispose = remove;
|
|
143
|
+
return remove;
|
|
144
|
+
}
|
|
145
|
+
async handleOpen(packet) {
|
|
146
|
+
// `AsyncOperationManager` doesn't support skipping IDs
|
|
147
|
+
// Use `add` + `resolve` to simulate this behavior
|
|
148
|
+
const [localId] = this.initializers.add();
|
|
149
|
+
this.initializers.resolve(localId, undefined);
|
|
150
|
+
const remoteId = packet.arg0;
|
|
151
|
+
const serviceString = decodeUtf8(packet.payload);
|
|
152
|
+
const controller = new AdbSocketController({
|
|
153
|
+
dispatcher: this,
|
|
154
|
+
localId,
|
|
155
|
+
remoteId,
|
|
156
|
+
localCreated: false,
|
|
157
|
+
serviceString,
|
|
158
|
+
});
|
|
159
|
+
for (const handler of this._incomingSocketHandlers) {
|
|
160
|
+
if (await handler(controller.socket)) {
|
|
161
|
+
this.sockets.set(localId, controller);
|
|
162
|
+
await this.sendPacket(AdbCommand.OK, localId, remoteId);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
await this.sendPacket(AdbCommand.Close, 0, remoteId);
|
|
167
|
+
}
|
|
168
|
+
async createSocket(serviceString) {
|
|
169
|
+
if (this.options.appendNullToServiceString) {
|
|
170
|
+
serviceString += "\0";
|
|
171
|
+
}
|
|
172
|
+
const [localId, initializer] = this.initializers.add();
|
|
173
|
+
await this.sendPacket(AdbCommand.Open, localId, 0, serviceString);
|
|
174
|
+
// Fulfilled by `handleOk`
|
|
175
|
+
const remoteId = await initializer;
|
|
176
|
+
const controller = new AdbSocketController({
|
|
177
|
+
dispatcher: this,
|
|
178
|
+
localId,
|
|
179
|
+
remoteId,
|
|
180
|
+
localCreated: true,
|
|
181
|
+
serviceString,
|
|
182
|
+
});
|
|
183
|
+
this.sockets.set(localId, controller);
|
|
184
|
+
return controller.socket;
|
|
185
|
+
}
|
|
186
|
+
async sendPacket(command, arg0, arg1, payload = EMPTY_UINT8_ARRAY) {
|
|
187
|
+
if (typeof payload === "string") {
|
|
188
|
+
payload = encodeUtf8(payload);
|
|
189
|
+
}
|
|
190
|
+
if (payload.byteLength > this.options.maxPayloadSize) {
|
|
191
|
+
throw new Error("payload too large");
|
|
192
|
+
}
|
|
193
|
+
await ConsumableWritableStream.write(this._writer, {
|
|
194
|
+
command,
|
|
195
|
+
arg0,
|
|
196
|
+
arg1,
|
|
197
|
+
payload,
|
|
198
|
+
checksum: this.options.calculateChecksum
|
|
199
|
+
? calculateChecksum(payload)
|
|
200
|
+
: 0,
|
|
201
|
+
magic: command ^ 0xffffffff,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async close() {
|
|
205
|
+
// Send `CLSE` packets for all sockets
|
|
206
|
+
await Promise.all(Array.from(this.sockets.values(), (socket) => socket.close()));
|
|
207
|
+
// Stop receiving
|
|
208
|
+
// It's possible that we haven't received all `CLSE` confirm packets,
|
|
209
|
+
// but it doesn't matter, the next connection can cope with them.
|
|
210
|
+
this._closed = true;
|
|
211
|
+
this._abortController.abort();
|
|
212
|
+
this._writer.releaseLock();
|
|
213
|
+
// `pipe().then()` will call `dispose`
|
|
214
|
+
}
|
|
215
|
+
dispose() {
|
|
216
|
+
for (const socket of this.sockets.values()) {
|
|
217
|
+
socket.dispose().catch((e) => {
|
|
218
|
+
void e;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
this._disconnected.resolve();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
232
224
|
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/socket/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/socket/dispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAO1E,OAAO,EACH,eAAe,EACf,wBAAwB,EACxB,cAAc,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;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AM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAChE,CAAC;QAEF,iBAAiB;QACjB,qEAAqE;QACrE,iEAAiE;QACjE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAE3B,sCAAsC;IAC1C,CAAC;IAEO,OAAO;QACX,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE;YACxC,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACzB,KAAK,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;SACN;QAED,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;CACJ"}
|
package/esm/socket/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./dispatcher.js";
|
|
2
|
+
export * from "./socket.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/socket/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./dispatcher.js";
|
|
2
|
+
export * from "./socket.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/esm/socket/socket.d.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import type { Disposable } from
|
|
2
|
-
import {
|
|
3
|
-
import type { AdbPacketDispatcher, Closeable } from
|
|
4
|
-
export interface AdbSocketInfo {
|
|
5
|
-
localId: number;
|
|
6
|
-
remoteId: number;
|
|
7
|
-
localCreated: boolean;
|
|
8
|
-
serviceString: string;
|
|
9
|
-
}
|
|
10
|
-
export interface AdbSocketConstructionOptions extends AdbSocketInfo {
|
|
11
|
-
dispatcher: AdbPacketDispatcher;
|
|
12
|
-
highWaterMark?: number | undefined;
|
|
13
|
-
}
|
|
14
|
-
export declare class AdbSocketController implements AdbSocketInfo, ReadableWritablePair<Uint8Array, Uint8Array
|
|
15
|
-
private readonly dispatcher;
|
|
16
|
-
readonly localId: number;
|
|
17
|
-
readonly remoteId: number;
|
|
18
|
-
readonly localCreated: boolean;
|
|
19
|
-
readonly serviceString: string;
|
|
20
|
-
private _duplex;
|
|
21
|
-
private _readable;
|
|
22
|
-
private _readableController;
|
|
23
|
-
get readable(): ReadableStream<Uint8Array>;
|
|
24
|
-
private _writePromise;
|
|
25
|
-
readonly writable: WritableStream<Uint8Array
|
|
26
|
-
private _closed;
|
|
27
|
-
/**
|
|
28
|
-
* Whether the socket is half-closed (i.e. the local side initiated the close).
|
|
29
|
-
*
|
|
30
|
-
* It's only used by dispatcher to avoid sending another `CLSE` packet to remote.
|
|
31
|
-
*/
|
|
32
|
-
get closed(): boolean;
|
|
33
|
-
private _socket;
|
|
34
|
-
get socket(): AdbSocket;
|
|
35
|
-
constructor(options: AdbSocketConstructionOptions);
|
|
36
|
-
enqueue(
|
|
37
|
-
ack(): void;
|
|
38
|
-
close(): Promise<void>;
|
|
39
|
-
dispose(): void
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A duplex stream representing a socket to ADB daemon.
|
|
43
|
-
*
|
|
44
|
-
* To close it, call either `socket.close()`,
|
|
45
|
-
* `socket.readable.cancel()`, `socket.readable.getReader().cancel()`,
|
|
46
|
-
* `socket.writable.abort()`, `socket.writable.getWriter().abort()`,
|
|
47
|
-
* `socket.writable.close()` or `socket.writable.getWriter().close()`.
|
|
48
|
-
*/
|
|
49
|
-
export declare class AdbSocket implements AdbSocketInfo, ReadableWritablePair<Uint8Array, Uint8Array
|
|
50
|
-
private _controller;
|
|
51
|
-
get localId(): number;
|
|
52
|
-
get remoteId(): number;
|
|
53
|
-
get localCreated(): boolean;
|
|
54
|
-
get serviceString(): string;
|
|
55
|
-
get readable(): ReadableStream<Uint8Array>;
|
|
56
|
-
get writable(): WritableStream<Uint8Array
|
|
57
|
-
constructor(controller: AdbSocketController);
|
|
58
|
-
close(): Promise<void>;
|
|
59
|
-
}
|
|
1
|
+
import type { Disposable } from "@yume-chan/event";
|
|
2
|
+
import type { Consumable, ReadableStream, ReadableWritablePair, WritableStream } from "@yume-chan/stream-extra";
|
|
3
|
+
import type { AdbPacketDispatcher, Closeable } from "./dispatcher.js";
|
|
4
|
+
export interface AdbSocketInfo {
|
|
5
|
+
localId: number;
|
|
6
|
+
remoteId: number;
|
|
7
|
+
localCreated: boolean;
|
|
8
|
+
serviceString: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AdbSocketConstructionOptions extends AdbSocketInfo {
|
|
11
|
+
dispatcher: AdbPacketDispatcher;
|
|
12
|
+
highWaterMark?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class AdbSocketController implements AdbSocketInfo, ReadableWritablePair<Uint8Array, Consumable<Uint8Array>>, Closeable, Disposable {
|
|
15
|
+
private readonly dispatcher;
|
|
16
|
+
readonly localId: number;
|
|
17
|
+
readonly remoteId: number;
|
|
18
|
+
readonly localCreated: boolean;
|
|
19
|
+
readonly serviceString: string;
|
|
20
|
+
private _duplex;
|
|
21
|
+
private _readable;
|
|
22
|
+
private _readableController;
|
|
23
|
+
get readable(): ReadableStream<Uint8Array>;
|
|
24
|
+
private _writePromise;
|
|
25
|
+
readonly writable: WritableStream<Consumable<Uint8Array>>;
|
|
26
|
+
private _closed;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the socket is half-closed (i.e. the local side initiated the close).
|
|
29
|
+
*
|
|
30
|
+
* It's only used by dispatcher to avoid sending another `CLSE` packet to remote.
|
|
31
|
+
*/
|
|
32
|
+
get closed(): boolean;
|
|
33
|
+
private _socket;
|
|
34
|
+
get socket(): AdbSocket;
|
|
35
|
+
constructor(options: AdbSocketConstructionOptions);
|
|
36
|
+
enqueue(data: Uint8Array): Promise<void>;
|
|
37
|
+
ack(): void;
|
|
38
|
+
close(): Promise<void>;
|
|
39
|
+
dispose(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A duplex stream representing a socket to ADB daemon.
|
|
43
|
+
*
|
|
44
|
+
* To close it, call either `socket.close()`,
|
|
45
|
+
* `socket.readable.cancel()`, `socket.readable.getReader().cancel()`,
|
|
46
|
+
* `socket.writable.abort()`, `socket.writable.getWriter().abort()`,
|
|
47
|
+
* `socket.writable.close()` or `socket.writable.getWriter().close()`.
|
|
48
|
+
*/
|
|
49
|
+
export declare class AdbSocket implements AdbSocketInfo, ReadableWritablePair<Uint8Array, Consumable<Uint8Array>> {
|
|
50
|
+
private _controller;
|
|
51
|
+
get localId(): number;
|
|
52
|
+
get remoteId(): number;
|
|
53
|
+
get localCreated(): boolean;
|
|
54
|
+
get serviceString(): string;
|
|
55
|
+
get readable(): ReadableStream<Uint8Array>;
|
|
56
|
+
get writable(): WritableStream<Consumable<Uint8Array>>;
|
|
57
|
+
constructor(controller: AdbSocketController);
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
}
|
|
60
60
|
//# sourceMappingURL=socket.d.ts.map
|