@yume-chan/adb 0.0.18 → 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.
Files changed (164) hide show
  1. package/CHANGELOG.json +21 -0
  2. package/CHANGELOG.md +11 -1
  3. package/esm/adb.d.ts +63 -60
  4. package/esm/adb.d.ts.map +1 -1
  5. package/esm/adb.js +257 -249
  6. package/esm/adb.js.map +1 -1
  7. package/esm/auth.d.ts +51 -51
  8. package/esm/auth.d.ts.map +1 -1
  9. package/esm/auth.js +95 -96
  10. package/esm/auth.js.map +1 -1
  11. package/esm/backend.d.ts +8 -8
  12. package/esm/backend.d.ts.map +1 -1
  13. package/esm/backend.js +1 -1
  14. package/esm/commands/base.d.ts +6 -6
  15. package/esm/commands/base.d.ts.map +1 -1
  16. package/esm/commands/base.js +8 -8
  17. package/esm/commands/framebuffer.d.ts +53 -53
  18. package/esm/commands/framebuffer.d.ts.map +1 -1
  19. package/esm/commands/framebuffer.js +46 -46
  20. package/esm/commands/framebuffer.js.map +1 -1
  21. package/esm/commands/index.d.ts +7 -8
  22. package/esm/commands/index.d.ts.map +1 -1
  23. package/esm/commands/index.js +7 -8
  24. package/esm/commands/index.js.map +1 -1
  25. package/esm/commands/install.d.ts +9 -3
  26. package/esm/commands/install.d.ts.map +1 -1
  27. package/esm/commands/install.js +26 -26
  28. package/esm/commands/install.js.map +1 -1
  29. package/esm/commands/power.d.ts +22 -22
  30. package/esm/commands/power.js +48 -48
  31. package/esm/commands/reverse.d.ts +41 -28
  32. package/esm/commands/reverse.d.ts.map +1 -1
  33. package/esm/commands/reverse.js +125 -100
  34. package/esm/commands/reverse.js.map +1 -1
  35. package/esm/commands/subprocess/command.d.ts +57 -51
  36. package/esm/commands/subprocess/command.d.ts.map +1 -1
  37. package/esm/commands/subprocess/command.js +86 -80
  38. package/esm/commands/subprocess/command.js.map +1 -1
  39. package/esm/commands/subprocess/index.d.ts +3 -3
  40. package/esm/commands/subprocess/index.js +3 -3
  41. package/esm/commands/subprocess/protocols/index.d.ts +3 -3
  42. package/esm/commands/subprocess/protocols/index.js +3 -3
  43. package/esm/commands/subprocess/protocols/none.d.ts +35 -35
  44. package/esm/commands/subprocess/protocols/none.d.ts.map +1 -1
  45. package/esm/commands/subprocess/protocols/none.js +65 -55
  46. package/esm/commands/subprocess/protocols/none.js.map +1 -1
  47. package/esm/commands/subprocess/protocols/shell.d.ts +39 -38
  48. package/esm/commands/subprocess/protocols/shell.d.ts.map +1 -1
  49. package/esm/commands/subprocess/protocols/shell.js +166 -162
  50. package/esm/commands/subprocess/protocols/shell.js.map +1 -1
  51. package/esm/commands/subprocess/protocols/types.d.ts +49 -49
  52. package/esm/commands/subprocess/protocols/types.d.ts.map +1 -1
  53. package/esm/commands/subprocess/protocols/types.js +1 -1
  54. package/esm/commands/subprocess/utils.d.ts +1 -1
  55. package/esm/commands/subprocess/utils.js +18 -18
  56. package/esm/commands/sync/index.d.ts +8 -7
  57. package/esm/commands/sync/index.d.ts.map +1 -1
  58. package/esm/commands/sync/index.js +8 -7
  59. package/esm/commands/sync/index.js.map +1 -1
  60. package/esm/commands/sync/list.d.ts +42 -40
  61. package/esm/commands/sync/list.d.ts.map +1 -1
  62. package/esm/commands/sync/list.js +67 -47
  63. package/esm/commands/sync/list.js.map +1 -1
  64. package/esm/commands/sync/pull.d.ts +13 -11
  65. package/esm/commands/sync/pull.d.ts.map +1 -1
  66. package/esm/commands/sync/pull.js +35 -37
  67. package/esm/commands/sync/pull.js.map +1 -1
  68. package/esm/commands/sync/push.d.ts +46 -7
  69. package/esm/commands/sync/push.d.ts.map +1 -1
  70. package/esm/commands/sync/push.js +89 -22
  71. package/esm/commands/sync/push.js.map +1 -1
  72. package/esm/commands/sync/request.d.ts +26 -23
  73. package/esm/commands/sync/request.d.ts.map +1 -1
  74. package/esm/commands/sync/request.js +40 -42
  75. package/esm/commands/sync/request.js.map +1 -1
  76. package/esm/commands/sync/response.d.ts +19 -19
  77. package/esm/commands/sync/response.d.ts.map +1 -1
  78. package/esm/commands/sync/response.js +54 -54
  79. package/esm/commands/sync/response.js.map +1 -1
  80. package/esm/commands/sync/socket.d.ts +27 -0
  81. package/esm/commands/sync/socket.d.ts.map +1 -0
  82. package/esm/commands/sync/socket.js +66 -0
  83. package/esm/commands/sync/socket.js.map +1 -0
  84. package/esm/commands/sync/stat.d.ts +72 -72
  85. package/esm/commands/sync/stat.d.ts.map +1 -1
  86. package/esm/commands/sync/stat.js +116 -104
  87. package/esm/commands/sync/stat.js.map +1 -1
  88. package/esm/commands/sync/sync.d.ts +72 -60
  89. package/esm/commands/sync/sync.d.ts.map +1 -1
  90. package/esm/commands/sync/sync.js +127 -149
  91. package/esm/commands/sync/sync.js.map +1 -1
  92. package/esm/commands/tcpip.d.ts +5 -5
  93. package/esm/commands/tcpip.js +18 -18
  94. package/esm/crypto.d.ts +36 -36
  95. package/esm/crypto.js +248 -248
  96. package/esm/features.d.ts +10 -7
  97. package/esm/features.d.ts.map +1 -1
  98. package/esm/features.js +13 -10
  99. package/esm/features.js.map +1 -1
  100. package/esm/index.d.ts +9 -9
  101. package/esm/index.js +9 -9
  102. package/esm/packet.d.ts +45 -46
  103. package/esm/packet.d.ts.map +1 -1
  104. package/esm/packet.js +43 -48
  105. package/esm/packet.js.map +1 -1
  106. package/esm/socket/dispatcher.d.ts +59 -59
  107. package/esm/socket/dispatcher.d.ts.map +1 -1
  108. package/esm/socket/dispatcher.js +223 -234
  109. package/esm/socket/dispatcher.js.map +1 -1
  110. package/esm/socket/index.d.ts +2 -2
  111. package/esm/socket/index.js +2 -2
  112. package/esm/socket/socket.d.ts +59 -59
  113. package/esm/socket/socket.d.ts.map +1 -1
  114. package/esm/socket/socket.js +118 -118
  115. package/esm/socket/socket.js.map +1 -1
  116. package/esm/utils/auto-reset-event.d.ts +9 -9
  117. package/esm/utils/auto-reset-event.d.ts.map +1 -1
  118. package/esm/utils/auto-reset-event.js +33 -33
  119. package/esm/utils/auto-reset-event.js.map +1 -1
  120. package/esm/utils/base64.d.ts +27 -27
  121. package/esm/utils/base64.js +246 -246
  122. package/esm/utils/conditional-variable.d.ts +9 -0
  123. package/esm/utils/conditional-variable.d.ts.map +1 -0
  124. package/esm/utils/conditional-variable.js +34 -0
  125. package/esm/utils/conditional-variable.js.map +1 -0
  126. package/esm/utils/index.d.ts +4 -3
  127. package/esm/utils/index.d.ts.map +1 -1
  128. package/esm/utils/index.js +4 -3
  129. package/esm/utils/index.js.map +1 -1
  130. package/package.json +11 -10
  131. package/src/adb.ts +47 -37
  132. package/src/auth.ts +7 -6
  133. package/src/backend.ts +4 -4
  134. package/src/commands/base.ts +1 -1
  135. package/src/commands/framebuffer.ts +4 -4
  136. package/src/commands/index.ts +7 -8
  137. package/src/commands/reverse.ts +35 -10
  138. package/src/commands/subprocess/command.ts +12 -4
  139. package/src/commands/subprocess/index.ts +3 -3
  140. package/src/commands/subprocess/protocols/index.ts +3 -3
  141. package/src/commands/subprocess/protocols/none.ts +25 -11
  142. package/src/commands/subprocess/protocols/shell.ts +50 -28
  143. package/src/commands/subprocess/protocols/types.ts +8 -7
  144. package/src/commands/subprocess/utils.ts +1 -1
  145. package/src/commands/sync/index.ts +8 -7
  146. package/src/commands/sync/list.ts +42 -23
  147. package/src/commands/sync/pull.ts +40 -45
  148. package/src/commands/sync/push.ts +146 -39
  149. package/src/commands/sync/request.ts +20 -15
  150. package/src/commands/sync/response.ts +7 -6
  151. package/src/commands/sync/socket.ts +97 -0
  152. package/src/commands/sync/stat.ts +47 -42
  153. package/src/commands/sync/sync.ts +68 -108
  154. package/src/commands/tcpip.ts +5 -5
  155. package/src/features.ts +9 -6
  156. package/src/packet.ts +19 -34
  157. package/src/socket/dispatcher.ts +32 -47
  158. package/src/socket/index.ts +2 -2
  159. package/src/socket/socket.ts +26 -17
  160. package/src/utils/auto-reset-event.ts +14 -15
  161. package/src/utils/conditional-variable.ts +45 -0
  162. package/src/utils/index.ts +4 -3
  163. package/tsconfig.build.tsbuildinfo +1 -1
  164. package/src/commands/install.ts +0 -40
package/esm/adb.js CHANGED
@@ -1,250 +1,258 @@
1
- // cspell: ignore libusb
2
- import { PromiseResolver } from "@yume-chan/async";
3
- import { AbortController, DecodeUtf8Stream, GatherStringStream, WritableStream, } from "@yume-chan/stream-extra";
4
- import { ADB_DEFAULT_AUTHENTICATORS, AdbAuthenticationProcessor, } from "./auth.js";
5
- import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, install, } from "./commands/index.js";
6
- import { AdbFeatures } from "./features.js";
7
- import { AdbCommand, calculateChecksum, } from "./packet.js";
8
- import { AdbPacketDispatcher, } from "./socket/index.js";
9
- import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
10
- export var AdbPropKey;
11
- (function (AdbPropKey) {
12
- AdbPropKey["Product"] = "ro.product.name";
13
- AdbPropKey["Model"] = "ro.product.model";
14
- AdbPropKey["Device"] = "ro.product.device";
15
- AdbPropKey["Features"] = "features";
16
- })(AdbPropKey = AdbPropKey || (AdbPropKey = {}));
17
- export const VERSION_OMIT_CHECKSUM = 0x01000001;
18
- export class Adb {
19
- /**
20
- * It's possible to call `authenticate` multiple times on a single connection,
21
- * every time the device receives a `CNXN` packet, it resets its internal state,
22
- * and starts a new authentication process.
23
- */
24
- static async authenticate(connection, credentialStore, authenticators = ADB_DEFAULT_AUTHENTICATORS) {
25
- // Initially, set to highest-supported version and payload size.
26
- let version = 0x01000001;
27
- let maxPayloadSize = 0x100000;
28
- const resolver = new PromiseResolver();
29
- const authProcessor = new AdbAuthenticationProcessor(authenticators, credentialStore);
30
- // Here is similar to `AdbPacketDispatcher`,
31
- // But the received packet types and send packet processing are different.
32
- const abortController = new AbortController();
33
- const pipe = connection.readable
34
- .pipeTo(new WritableStream({
35
- async write(packet) {
36
- switch (packet.command) {
37
- case AdbCommand.Connect:
38
- version = Math.min(version, packet.arg0);
39
- maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
40
- resolver.resolve(decodeUtf8(packet.payload));
41
- break;
42
- case AdbCommand.Auth: {
43
- const response = await authProcessor.process(packet);
44
- await sendPacket(response);
45
- break;
46
- }
47
- default:
48
- // Maybe the previous ADB client exited without reading all packets,
49
- // so they are still waiting in OS internal buffer.
50
- // Just ignore them.
51
- // Because a `Connect` packet will reset the device,
52
- // Eventually there will be `Connect` and `Auth` response packets.
53
- break;
54
- }
55
- },
56
- }), {
57
- // Don't cancel the source ReadableStream on AbortSignal abort.
58
- preventCancel: true,
59
- signal: abortController.signal,
60
- })
61
- .catch((e) => {
62
- resolver.reject(e);
63
- });
64
- const writer = connection.writable.getWriter();
65
- async function sendPacket(init) {
66
- // Always send checksum in auth steps
67
- // Because we don't know if the device needs it or not.
68
- await writer.write(calculateChecksum(init));
69
- }
70
- let banner;
71
- try {
72
- // https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
73
- // There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
74
- const features = [
75
- AdbFeatures.ShellV2,
76
- AdbFeatures.Cmd,
77
- AdbFeatures.StatV2,
78
- AdbFeatures.ListV2,
79
- AdbFeatures.FixedPushMkdir,
80
- "apex",
81
- "abb",
82
- // only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
83
- // No special handling required.
84
- "fixed_push_symlink_timestamp",
85
- "abb_exec",
86
- "remount_shell",
87
- "track_app",
88
- "sendrecv_v2",
89
- "sendrecv_v2_brotli",
90
- "sendrecv_v2_lz4",
91
- "sendrecv_v2_zstd",
92
- "sendrecv_v2_dry_run_send",
93
- ].join(",");
94
- await sendPacket({
95
- command: AdbCommand.Connect,
96
- arg0: version,
97
- arg1: maxPayloadSize,
98
- // The terminating `;` is required in formal definition
99
- // But ADB daemon (all versions) can still work without it
100
- payload: encodeUtf8(`host::features=${features};`),
101
- });
102
- banner = await resolver.promise;
103
- }
104
- finally {
105
- // When failed, release locks on `connection` so the caller can try again.
106
- // When success, also release locks so `AdbPacketDispatcher` can use them.
107
- abortController.abort();
108
- writer.releaseLock();
109
- // Wait until pipe stops (`ReadableStream` lock released)
110
- await pipe;
111
- }
112
- return new Adb(connection, version, maxPayloadSize, banner);
113
- }
114
- dispatcher;
115
- get disconnected() {
116
- return this.dispatcher.disconnected;
117
- }
118
- _protocolVersion;
119
- get protocolVersion() {
120
- return this._protocolVersion;
121
- }
122
- _product;
123
- get product() {
124
- return this._product;
125
- }
126
- _model;
127
- get model() {
128
- return this._model;
129
- }
130
- _device;
131
- get device() {
132
- return this._device;
133
- }
134
- _features = [];
135
- get features() {
136
- return this._features;
137
- }
138
- subprocess;
139
- power;
140
- reverse;
141
- tcpip;
142
- constructor(connection, version, maxPayloadSize, banner) {
143
- this.parseBanner(banner);
144
- let calculateChecksum;
145
- let appendNullToServiceString;
146
- if (version >= VERSION_OMIT_CHECKSUM) {
147
- calculateChecksum = false;
148
- appendNullToServiceString = false;
149
- }
150
- else {
151
- calculateChecksum = true;
152
- appendNullToServiceString = true;
153
- }
154
- this.dispatcher = new AdbPacketDispatcher(connection, {
155
- calculateChecksum,
156
- appendNullToServiceString,
157
- maxPayloadSize,
158
- });
159
- this._protocolVersion = version;
160
- this.subprocess = new AdbSubprocess(this);
161
- this.power = new AdbPower(this);
162
- this.reverse = new AdbReverseCommand(this);
163
- this.tcpip = new AdbTcpIpCommand(this);
164
- }
165
- parseBanner(banner) {
166
- const pieces = banner.split("::");
167
- if (pieces.length > 1) {
168
- const props = pieces[1];
169
- for (const prop of props.split(";")) {
170
- if (!prop) {
171
- continue;
172
- }
173
- const keyValue = prop.split("=");
174
- if (keyValue.length !== 2) {
175
- continue;
176
- }
177
- const [key, value] = keyValue;
178
- switch (key) {
179
- case AdbPropKey.Product:
180
- this._product = value;
181
- break;
182
- case AdbPropKey.Model:
183
- this._model = value;
184
- break;
185
- case AdbPropKey.Device:
186
- this._device = value;
187
- break;
188
- case AdbPropKey.Features:
189
- this._features = value.split(",");
190
- break;
191
- }
192
- }
193
- }
194
- }
195
- /**
196
- * Add a handler for incoming socket.
197
- * @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
198
- * @returns A function to remove the handler.
199
- */
200
- onIncomingSocket(handler) {
201
- return this.dispatcher.onIncomingSocket(handler);
202
- }
203
- async createSocket(service) {
204
- return this.dispatcher.createSocket(service);
205
- }
206
- async createSocketAndWait(service) {
207
- const socket = await this.createSocket(service);
208
- const gatherStream = new GatherStringStream();
209
- await socket.readable
210
- .pipeThrough(new DecodeUtf8Stream())
211
- .pipeTo(gatherStream);
212
- return gatherStream.result;
213
- }
214
- async getProp(key) {
215
- const stdout = await this.subprocess.spawnAndWaitLegacy([
216
- "getprop",
217
- key,
218
- ]);
219
- return stdout.trim();
220
- }
221
- async rm(...filenames) {
222
- const stdout = await this.subprocess.spawnAndWaitLegacy([
223
- "rm",
224
- "-rf",
225
- ...filenames.map((arg) => escapeArg(arg)),
226
- ]);
227
- return stdout;
228
- }
229
- install() {
230
- return install(this);
231
- }
232
- async sync() {
233
- const socket = await this.createSocket("sync:");
234
- return new AdbSync(this, socket);
235
- }
236
- async framebuffer() {
237
- return framebuffer(this);
238
- }
239
- /**
240
- * Close the ADB connection.
241
- *
242
- * Note that it won't close the streams from backends.
243
- * The streams are both physically and logically intact,
244
- * and can be reused.
245
- */
246
- async close() {
247
- await this.dispatcher.close();
248
- }
249
- }
1
+ import { PromiseResolver } from "@yume-chan/async";
2
+ import { AbortController, ConsumableWritableStream, DecodeUtf8Stream, GatherStringStream, WritableStream, } from "@yume-chan/stream-extra";
3
+ import { ADB_DEFAULT_AUTHENTICATORS, AdbAuthenticationProcessor, } from "./auth.js";
4
+ import { AdbPower, AdbReverseCommand, AdbSubprocess, AdbSync, AdbTcpIpCommand, escapeArg, framebuffer, } from "./commands/index.js";
5
+ import { AdbFeature } from "./features.js";
6
+ import { AdbCommand, calculateChecksum } from "./packet.js";
7
+ import { AdbPacketDispatcher } from "./socket/index.js";
8
+ import { decodeUtf8, encodeUtf8 } from "./utils/index.js";
9
+ export var AdbPropKey;
10
+ (function (AdbPropKey) {
11
+ AdbPropKey["Product"] = "ro.product.name";
12
+ AdbPropKey["Model"] = "ro.product.model";
13
+ AdbPropKey["Device"] = "ro.product.device";
14
+ AdbPropKey["Features"] = "features";
15
+ })(AdbPropKey = AdbPropKey || (AdbPropKey = {}));
16
+ export const VERSION_OMIT_CHECKSUM = 0x01000001;
17
+ export class Adb {
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 = ADB_DEFAULT_AUTHENTICATORS) {
24
+ // Initially, set to highest-supported version and payload size.
25
+ let version = 0x01000001;
26
+ // Android 4: 4K, Android 7: 256K, Android 9: 1M
27
+ let maxPayloadSize = 1024 * 1024;
28
+ const resolver = new PromiseResolver();
29
+ const authProcessor = new AdbAuthenticationProcessor(authenticators, credentialStore);
30
+ // Here is similar to `AdbPacketDispatcher`,
31
+ // But the received packet types and send packet processing are different.
32
+ const abortController = new AbortController();
33
+ const pipe = connection.readable
34
+ .pipeTo(new WritableStream({
35
+ async write(packet) {
36
+ switch (packet.command) {
37
+ case AdbCommand.Connect:
38
+ version = Math.min(version, packet.arg0);
39
+ maxPayloadSize = Math.min(maxPayloadSize, packet.arg1);
40
+ resolver.resolve(decodeUtf8(packet.payload));
41
+ break;
42
+ case AdbCommand.Auth: {
43
+ const response = await authProcessor.process(packet);
44
+ await sendPacket(response);
45
+ break;
46
+ }
47
+ default:
48
+ // Maybe the previous ADB client exited without reading all packets,
49
+ // so they are still waiting in OS internal buffer.
50
+ // Just ignore them.
51
+ // Because a `Connect` packet will reset the device,
52
+ // Eventually there will be `Connect` and `Auth` response packets.
53
+ break;
54
+ }
55
+ },
56
+ }), {
57
+ // Don't cancel the source ReadableStream on AbortSignal abort.
58
+ preventCancel: true,
59
+ signal: abortController.signal,
60
+ })
61
+ .catch((e) => {
62
+ resolver.reject(e);
63
+ });
64
+ const writer = connection.writable.getWriter();
65
+ async function sendPacket(init) {
66
+ // Always send checksum in auth steps
67
+ // Because we don't know if the device needs it or not.
68
+ init.checksum = calculateChecksum(init.payload);
69
+ init.magic = init.command ^ 0xffffffff;
70
+ await ConsumableWritableStream.write(writer, init);
71
+ }
72
+ let banner;
73
+ try {
74
+ // https://android.googlesource.com/platform/packages/modules/adb/+/79010dc6d5ca7490c493df800d4421730f5466ca/transport.cpp#1252
75
+ // There are some other feature constants, but some of them are only used by ADB server, not devices (daemons).
76
+ const features = [
77
+ AdbFeature.ShellV2,
78
+ AdbFeature.Cmd,
79
+ AdbFeature.StatV2,
80
+ AdbFeature.ListV2,
81
+ AdbFeature.FixedPushMkdir,
82
+ "apex",
83
+ AdbFeature.Abb,
84
+ // only tells the client the symlink timestamp issue in `adb push --sync` has been fixed.
85
+ // No special handling required.
86
+ "fixed_push_symlink_timestamp",
87
+ AdbFeature.AbbExec,
88
+ "remount_shell",
89
+ "track_app",
90
+ "sendrecv_v2",
91
+ "sendrecv_v2_brotli",
92
+ "sendrecv_v2_lz4",
93
+ "sendrecv_v2_zstd",
94
+ "sendrecv_v2_dry_run_send",
95
+ ].join(",");
96
+ await sendPacket({
97
+ command: AdbCommand.Connect,
98
+ arg0: version,
99
+ arg1: maxPayloadSize,
100
+ // The terminating `;` is required in formal definition
101
+ // But ADB daemon (all versions) can still work without it
102
+ payload: encodeUtf8(`host::features=${features};`),
103
+ });
104
+ banner = await resolver.promise;
105
+ }
106
+ finally {
107
+ // When failed, release locks on `connection` so the caller can try again.
108
+ // When success, also release locks so `AdbPacketDispatcher` can use them.
109
+ abortController.abort();
110
+ writer.releaseLock();
111
+ // Wait until pipe stops (`ReadableStream` lock released)
112
+ await pipe;
113
+ }
114
+ return new Adb(connection, version, maxPayloadSize, banner);
115
+ }
116
+ dispatcher;
117
+ get disconnected() {
118
+ return this.dispatcher.disconnected;
119
+ }
120
+ _protocolVersion;
121
+ get protocolVersion() {
122
+ return this._protocolVersion;
123
+ }
124
+ _maxPayloadSize;
125
+ get maxPayloadSize() {
126
+ return this._maxPayloadSize;
127
+ }
128
+ _product;
129
+ get product() {
130
+ return this._product;
131
+ }
132
+ _model;
133
+ get model() {
134
+ return this._model;
135
+ }
136
+ _device;
137
+ get device() {
138
+ return this._device;
139
+ }
140
+ _features = [];
141
+ get features() {
142
+ return this._features;
143
+ }
144
+ subprocess;
145
+ power;
146
+ reverse;
147
+ tcpip;
148
+ constructor(connection, version, maxPayloadSize, banner) {
149
+ this.parseBanner(banner);
150
+ let calculateChecksum;
151
+ let appendNullToServiceString;
152
+ if (version >= VERSION_OMIT_CHECKSUM) {
153
+ calculateChecksum = false;
154
+ appendNullToServiceString = false;
155
+ }
156
+ else {
157
+ calculateChecksum = true;
158
+ appendNullToServiceString = true;
159
+ }
160
+ this.dispatcher = new AdbPacketDispatcher(connection, {
161
+ calculateChecksum,
162
+ appendNullToServiceString,
163
+ maxPayloadSize,
164
+ });
165
+ this._protocolVersion = version;
166
+ this._maxPayloadSize = maxPayloadSize;
167
+ this.subprocess = new AdbSubprocess(this);
168
+ this.power = new AdbPower(this);
169
+ this.reverse = new AdbReverseCommand(this);
170
+ this.tcpip = new AdbTcpIpCommand(this);
171
+ }
172
+ parseBanner(banner) {
173
+ const pieces = banner.split("::");
174
+ if (pieces.length > 1) {
175
+ const props = pieces[1];
176
+ for (const prop of props.split(";")) {
177
+ if (!prop) {
178
+ continue;
179
+ }
180
+ const keyValue = prop.split("=");
181
+ if (keyValue.length !== 2) {
182
+ continue;
183
+ }
184
+ const [key, value] = keyValue;
185
+ switch (key) {
186
+ case AdbPropKey.Product:
187
+ this._product = value;
188
+ break;
189
+ case AdbPropKey.Model:
190
+ this._model = value;
191
+ break;
192
+ case AdbPropKey.Device:
193
+ this._device = value;
194
+ break;
195
+ case AdbPropKey.Features:
196
+ this._features = value.split(",");
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ }
202
+ supportsFeature(feature) {
203
+ return this._features.includes(feature);
204
+ }
205
+ /**
206
+ * Add a handler for incoming socket.
207
+ * @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
208
+ * @returns A function to remove the handler.
209
+ */
210
+ onIncomingSocket(handler) {
211
+ return this.dispatcher.onIncomingSocket(handler);
212
+ }
213
+ async createSocket(service) {
214
+ return this.dispatcher.createSocket(service);
215
+ }
216
+ async createSocketAndWait(service) {
217
+ const socket = await this.createSocket(service);
218
+ const gatherStream = new GatherStringStream();
219
+ await socket.readable
220
+ .pipeThrough(new DecodeUtf8Stream())
221
+ .pipeTo(gatherStream);
222
+ return gatherStream.result;
223
+ }
224
+ async getProp(key) {
225
+ const stdout = await this.subprocess.spawnAndWaitLegacy([
226
+ "getprop",
227
+ key,
228
+ ]);
229
+ return stdout.trim();
230
+ }
231
+ async rm(...filenames) {
232
+ // https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984
233
+ const stdout = await this.subprocess.spawnAndWaitLegacy([
234
+ "rm",
235
+ ...filenames.map((arg) => escapeArg(arg)),
236
+ "</dev/null",
237
+ ]);
238
+ return stdout;
239
+ }
240
+ async sync() {
241
+ const socket = await this.createSocket("sync:");
242
+ return new AdbSync(this, socket);
243
+ }
244
+ async framebuffer() {
245
+ return framebuffer(this);
246
+ }
247
+ /**
248
+ * Close the ADB connection.
249
+ *
250
+ * Note that it won't close the streams from backends.
251
+ * The streams are both physically and logically intact,
252
+ * and can be reused.
253
+ */
254
+ async close() {
255
+ await this.dispatcher.close();
256
+ }
257
+ }
250
258
  //# sourceMappingURL=adb.js.map
package/esm/adb.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"adb.js","sourceRoot":"","sources":["../src/adb.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACH,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GAEjB,M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