@yume-chan/adb 0.0.9 → 0.0.10
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 +23 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -21
- package/README.md +227 -257
- package/dts/adb.d.ts.map +1 -1
- package/dts/auth.d.ts +11 -1
- package/dts/auth.d.ts.map +1 -1
- package/dts/backend.d.ts +3 -5
- package/dts/backend.d.ts.map +1 -1
- package/dts/commands/demo-mode.d.ts +3 -3
- package/dts/commands/demo-mode.d.ts.map +1 -1
- package/dts/commands/reverse.d.ts +2 -2
- package/dts/commands/reverse.d.ts.map +1 -1
- package/dts/commands/shell/index.d.ts +31 -5
- package/dts/commands/shell/index.d.ts.map +1 -1
- package/dts/commands/shell/legacy.d.ts +13 -2
- package/dts/commands/shell/legacy.d.ts.map +1 -1
- package/dts/commands/shell/protocol.d.ts +11 -3
- package/dts/commands/shell/protocol.d.ts.map +1 -1
- package/dts/commands/shell/types.d.ts +35 -3
- package/dts/commands/shell/types.d.ts.map +1 -1
- package/dts/commands/sync/request.d.ts +1 -1
- package/dts/commands/sync/request.d.ts.map +1 -1
- package/dts/commands/sync/response.d.ts +2 -2
- package/dts/commands/sync/response.d.ts.map +1 -1
- package/dts/commands/sync/sync.d.ts.map +1 -1
- package/dts/crypto.d.ts +7 -0
- package/dts/crypto.d.ts.map +1 -1
- package/dts/packet.d.ts.map +1 -1
- package/dts/socket/close-event-emitter.d.ts.map +1 -1
- package/dts/socket/controller.d.ts.map +1 -1
- package/dts/socket/data-event-emitter.d.ts.map +1 -1
- package/dts/socket/dispatcher.d.ts.map +1 -1
- package/dts/stream/buffered-stream.d.ts +2 -4
- package/dts/stream/buffered-stream.d.ts.map +1 -1
- package/dts/utils/encoding.d.ts +3 -0
- package/dts/utils/encoding.d.ts.map +1 -0
- package/dts/utils/index.d.ts +1 -0
- package/dts/utils/index.d.ts.map +1 -1
- package/esm/adb.js +3 -2
- package/esm/adb.js.map +1 -1
- package/esm/auth.js +2 -2
- package/esm/auth.js.map +1 -1
- package/esm/commands/demo-mode.js +9 -9
- package/esm/commands/demo-mode.js.map +1 -1
- package/esm/commands/reverse.js +3 -2
- package/esm/commands/reverse.js.map +1 -1
- package/esm/commands/shell/index.js +28 -18
- package/esm/commands/shell/index.js.map +1 -1
- package/esm/commands/shell/legacy.js +16 -0
- package/esm/commands/shell/legacy.js.map +1 -1
- package/esm/commands/shell/protocol.js +36 -9
- package/esm/commands/shell/protocol.js.map +1 -1
- package/esm/commands/sync/request.js +5 -4
- package/esm/commands/sync/request.js.map +1 -1
- package/esm/commands/sync/response.js +4 -3
- package/esm/commands/sync/response.js.map +1 -1
- package/esm/commands/sync/sync.js.map +1 -1
- package/esm/crypto.js +7 -2
- package/esm/crypto.js.map +1 -1
- package/esm/packet.js +12 -14
- package/esm/packet.js.map +1 -1
- package/esm/socket/close-event-emitter.js.map +1 -1
- package/esm/socket/controller.js.map +1 -1
- package/esm/socket/data-event-emitter.js.map +1 -1
- package/esm/socket/dispatcher.js +7 -7
- package/esm/socket/dispatcher.js.map +1 -1
- package/esm/stream/buffered-stream.js +0 -6
- package/esm/stream/buffered-stream.js.map +1 -1
- package/esm/utils/encoding.js +11 -0
- package/esm/utils/encoding.js.map +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/package.json +44 -51
- package/src/adb.ts +243 -242
- package/src/auth.ts +166 -156
- package/src/backend.ts +20 -24
- package/src/commands/base.ts +11 -11
- package/src/commands/demo-mode.ts +160 -160
- package/src/commands/framebuffer.ts +73 -73
- package/src/commands/index.ts +8 -8
- package/src/commands/install.ts +21 -21
- package/src/commands/reverse.ts +134 -133
- package/src/commands/shell/index.ts +87 -68
- package/src/commands/shell/legacy.ts +59 -42
- package/src/commands/shell/protocol.ts +121 -94
- package/src/commands/shell/types.ts +55 -21
- package/src/commands/shell/utils.ts +20 -20
- package/src/commands/sync/index.ts +7 -7
- package/src/commands/sync/list.ts +39 -39
- package/src/commands/sync/pull.ts +34 -34
- package/src/commands/sync/push.ts +46 -46
- package/src/commands/sync/request.ts +49 -48
- package/src/commands/sync/response.ts +58 -57
- package/src/commands/sync/stat.ts +121 -121
- package/src/commands/sync/sync.ts +113 -113
- package/src/commands/tcpip.ts +21 -21
- package/src/crypto.ts +285 -280
- package/src/features.ts +5 -5
- package/src/index.ts +10 -10
- package/src/packet.ts +84 -89
- package/src/socket/close-event-emitter.ts +28 -28
- package/src/socket/controller.ts +105 -105
- package/src/socket/data-event-emitter.ts +27 -27
- package/src/socket/dispatcher.ts +269 -269
- package/src/socket/index.ts +6 -6
- package/src/socket/logger.ts +12 -12
- package/src/socket/socket.ts +28 -28
- package/src/stream/buffered-stream.ts +92 -100
- package/src/stream/index.ts +2 -2
- package/src/stream/stream.ts +50 -50
- package/src/utils/auto-reset-event.ts +41 -41
- package/src/utils/base64.ts +274 -274
- package/src/utils/chunk.ts +70 -70
- package/src/utils/encoding.ts +13 -0
- package/src/utils/event-queue.ts +145 -145
- package/src/utils/index.ts +5 -4
- package/cjs/adb.js +0 -205
- package/cjs/adb.js.map +0 -1
- package/cjs/auth.js +0 -141
- package/cjs/auth.js.map +0 -1
- package/cjs/backend.js +0 -3
- package/cjs/backend.js.map +0 -1
- package/cjs/commands/base.js +0 -12
- package/cjs/commands/base.js.map +0 -1
- package/cjs/commands/demo-mode.js +0 -174
- package/cjs/commands/demo-mode.js.map +0 -1
- package/cjs/commands/framebuffer.js +0 -66
- package/cjs/commands/framebuffer.js.map +0 -1
- package/cjs/commands/index.js +0 -12
- package/cjs/commands/index.js.map +0 -1
- package/cjs/commands/install.js +0 -20
- package/cjs/commands/install.js.map +0 -1
- package/cjs/commands/reverse.js +0 -105
- package/cjs/commands/reverse.js.map +0 -1
- package/cjs/commands/shell/index.js +0 -56
- package/cjs/commands/shell/index.js.map +0 -1
- package/cjs/commands/shell/legacy.js +0 -37
- package/cjs/commands/shell/legacy.js.map +0 -1
- package/cjs/commands/shell/protocol.js +0 -83
- package/cjs/commands/shell/protocol.js.map +0 -1
- package/cjs/commands/shell/types.js +0 -3
- package/cjs/commands/shell/types.js.map +0 -1
- package/cjs/commands/shell/utils.js +0 -23
- package/cjs/commands/shell/utils.js.map +0 -1
- package/cjs/commands/sync/index.js +0 -11
- package/cjs/commands/sync/index.js.map +0 -1
- package/cjs/commands/sync/list.js +0 -36
- package/cjs/commands/sync/list.js.map +0 -1
- package/cjs/commands/sync/pull.js +0 -34
- package/cjs/commands/sync/pull.js.map +0 -1
- package/cjs/commands/sync/push.js +0 -49
- package/cjs/commands/sync/push.js.map +0 -1
- package/cjs/commands/sync/request.js +0 -48
- package/cjs/commands/sync/request.js.map +0 -1
- package/cjs/commands/sync/response.js +0 -53
- package/cjs/commands/sync/response.js.map +0 -1
- package/cjs/commands/sync/stat.js +0 -109
- package/cjs/commands/sync/stat.js.map +0 -1
- package/cjs/commands/sync/sync.js +0 -118
- package/cjs/commands/sync/sync.js.map +0 -1
- package/cjs/commands/tcpip.js +0 -28
- package/cjs/commands/tcpip.js.map +0 -1
- package/cjs/crypto.js +0 -231
- package/cjs/crypto.js.map +0 -1
- package/cjs/features.js +0 -10
- package/cjs/features.js.map +0 -1
- package/cjs/index.js +0 -14
- package/cjs/index.js.map +0 -1
- package/cjs/packet.js +0 -77
- package/cjs/packet.js.map +0 -1
- package/cjs/socket/close-event-emitter.js +0 -32
- package/cjs/socket/close-event-emitter.js.map +0 -1
- package/cjs/socket/controller.js +0 -84
- package/cjs/socket/controller.js.map +0 -1
- package/cjs/socket/data-event-emitter.js +0 -29
- package/cjs/socket/data-event-emitter.js.map +0 -1
- package/cjs/socket/dispatcher.js +0 -219
- package/cjs/socket/dispatcher.js.map +0 -1
- package/cjs/socket/index.js +0 -10
- package/cjs/socket/index.js.map +0 -1
- package/cjs/socket/logger.js +0 -3
- package/cjs/socket/logger.js.map +0 -1
- package/cjs/socket/socket.js +0 -24
- package/cjs/socket/socket.js.map +0 -1
- package/cjs/stream/buffered-stream.js +0 -78
- package/cjs/stream/buffered-stream.js.map +0 -1
- package/cjs/stream/index.js +0 -6
- package/cjs/stream/index.js.map +0 -1
- package/cjs/stream/stream.js +0 -45
- package/cjs/stream/stream.js.map +0 -1
- package/cjs/utils/auto-reset-event.js +0 -37
- package/cjs/utils/auto-reset-event.js.map +0 -1
- package/cjs/utils/base64.js +0 -210
- package/cjs/utils/base64.js.map +0 -1
- package/cjs/utils/chunk.js +0 -75
- package/cjs/utils/chunk.js.map +0 -1
- package/cjs/utils/event-queue.js +0 -108
- package/cjs/utils/event-queue.js.map +0 -1
- package/cjs/utils/index.js +0 -8
- package/cjs/utils/index.js.map +0 -1
- package/tsconfig.cjs.json +0 -11
- package/tsconfig.esm.json +0 -28
- package/tsconfig.esm.tsbuildinfo +0 -1305
- package/tsconfig.json +0 -18
package/cjs/auth.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdbAuthenticationHandler = exports.AdbDefaultAuthenticators = exports.AdbPublicKeyAuthenticator = exports.AdbSignatureAuthenticator = exports.AdbAuthType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const async_1 = require("@yume-chan/async");
|
|
6
|
-
const crypto_1 = require("./crypto");
|
|
7
|
-
const packet_1 = require("./packet");
|
|
8
|
-
const utils_1 = require("./utils");
|
|
9
|
-
var AdbAuthType;
|
|
10
|
-
(function (AdbAuthType) {
|
|
11
|
-
AdbAuthType[AdbAuthType["Token"] = 1] = "Token";
|
|
12
|
-
AdbAuthType[AdbAuthType["Signature"] = 2] = "Signature";
|
|
13
|
-
AdbAuthType[AdbAuthType["PublicKey"] = 3] = "PublicKey";
|
|
14
|
-
})(AdbAuthType = exports.AdbAuthType || (exports.AdbAuthType = {}));
|
|
15
|
-
const AdbSignatureAuthenticator = function (credentialStore, getNextRequest) {
|
|
16
|
-
return tslib_1.__asyncGenerator(this, arguments, function* () {
|
|
17
|
-
var e_1, _a;
|
|
18
|
-
try {
|
|
19
|
-
for (var _b = tslib_1.__asyncValues(credentialStore.iterateKeys()), _c; _c = yield tslib_1.__await(_b.next()), !_c.done;) {
|
|
20
|
-
const key = _c.value;
|
|
21
|
-
const packet = yield tslib_1.__await(getNextRequest());
|
|
22
|
-
if (packet.arg0 !== AdbAuthType.Token) {
|
|
23
|
-
return yield tslib_1.__await(void 0);
|
|
24
|
-
}
|
|
25
|
-
const signature = crypto_1.sign(key, packet.payload);
|
|
26
|
-
yield yield tslib_1.__await({
|
|
27
|
-
command: packet_1.AdbCommand.Auth,
|
|
28
|
-
arg0: AdbAuthType.Signature,
|
|
29
|
-
arg1: 0,
|
|
30
|
-
payload: signature,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (_c && !_c.done && (_a = _b.return)) yield tslib_1.__await(_a.call(_b));
|
|
38
|
-
}
|
|
39
|
-
finally { if (e_1) throw e_1.error; }
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
exports.AdbSignatureAuthenticator = AdbSignatureAuthenticator;
|
|
44
|
-
const AdbPublicKeyAuthenticator = function (credentialStore, getNextRequest) {
|
|
45
|
-
return tslib_1.__asyncGenerator(this, arguments, function* () {
|
|
46
|
-
var e_2, _a;
|
|
47
|
-
const packet = yield tslib_1.__await(getNextRequest());
|
|
48
|
-
if (packet.arg0 !== AdbAuthType.Token) {
|
|
49
|
-
return yield tslib_1.__await(void 0);
|
|
50
|
-
}
|
|
51
|
-
let privateKey;
|
|
52
|
-
try {
|
|
53
|
-
for (var _b = tslib_1.__asyncValues(credentialStore.iterateKeys()), _c; _c = yield tslib_1.__await(_b.next()), !_c.done;) {
|
|
54
|
-
const key = _c.value;
|
|
55
|
-
privateKey = key;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
60
|
-
finally {
|
|
61
|
-
try {
|
|
62
|
-
if (_c && !_c.done && (_a = _b.return)) yield tslib_1.__await(_a.call(_b));
|
|
63
|
-
}
|
|
64
|
-
finally { if (e_2) throw e_2.error; }
|
|
65
|
-
}
|
|
66
|
-
if (!privateKey) {
|
|
67
|
-
privateKey = yield tslib_1.__await(credentialStore.generateKey());
|
|
68
|
-
}
|
|
69
|
-
const publicKeyLength = crypto_1.calculatePublicKeyLength();
|
|
70
|
-
const [publicKeyBase64Length] = utils_1.calculateBase64EncodedLength(publicKeyLength);
|
|
71
|
-
// The public key is null terminated,
|
|
72
|
-
// So we allocate the buffer with one extra byte.
|
|
73
|
-
const publicKeyBuffer = new ArrayBuffer(publicKeyBase64Length + 1);
|
|
74
|
-
crypto_1.calculatePublicKey(privateKey, publicKeyBuffer);
|
|
75
|
-
utils_1.encodeBase64(publicKeyBuffer, 0, publicKeyLength, publicKeyBuffer);
|
|
76
|
-
yield yield tslib_1.__await({
|
|
77
|
-
command: packet_1.AdbCommand.Auth,
|
|
78
|
-
arg0: AdbAuthType.PublicKey,
|
|
79
|
-
arg1: 0,
|
|
80
|
-
payload: publicKeyBuffer
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
exports.AdbPublicKeyAuthenticator = AdbPublicKeyAuthenticator;
|
|
85
|
-
exports.AdbDefaultAuthenticators = [
|
|
86
|
-
exports.AdbSignatureAuthenticator,
|
|
87
|
-
exports.AdbPublicKeyAuthenticator
|
|
88
|
-
];
|
|
89
|
-
class AdbAuthenticationHandler {
|
|
90
|
-
constructor(authenticators, credentialStore) {
|
|
91
|
-
this.pendingRequest = new async_1.PromiseResolver();
|
|
92
|
-
this.getNextRequest = () => {
|
|
93
|
-
return this.pendingRequest.promise;
|
|
94
|
-
};
|
|
95
|
-
this.authenticators = authenticators;
|
|
96
|
-
this.credentialStore = credentialStore;
|
|
97
|
-
}
|
|
98
|
-
runAuthenticator() {
|
|
99
|
-
return tslib_1.__asyncGenerator(this, arguments, function* runAuthenticator_1() {
|
|
100
|
-
var e_3, _a;
|
|
101
|
-
for (const authenticator of this.authenticators) {
|
|
102
|
-
try {
|
|
103
|
-
for (var _b = (e_3 = void 0, tslib_1.__asyncValues(authenticator(this.credentialStore, this.getNextRequest))), _c; _c = yield tslib_1.__await(_b.next()), !_c.done;) {
|
|
104
|
-
const packet = _c.value;
|
|
105
|
-
// If the authenticator yielded a response
|
|
106
|
-
// Prepare `nextRequest` for next authentication request
|
|
107
|
-
this.pendingRequest = new async_1.PromiseResolver();
|
|
108
|
-
// Yield the response to outer layer
|
|
109
|
-
yield yield tslib_1.__await(packet);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
113
|
-
finally {
|
|
114
|
-
try {
|
|
115
|
-
if (_c && !_c.done && (_a = _b.return)) yield tslib_1.__await(_a.call(_b));
|
|
116
|
-
}
|
|
117
|
-
finally { if (e_3) throw e_3.error; }
|
|
118
|
-
}
|
|
119
|
-
// If the authenticator returned,
|
|
120
|
-
// Next authenticator will be given the same `pendingRequest`
|
|
121
|
-
}
|
|
122
|
-
throw new Error('Cannot authenticate with device');
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
handle(packet) {
|
|
126
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
if (!this.iterator) {
|
|
128
|
-
this.iterator = this.runAuthenticator();
|
|
129
|
-
}
|
|
130
|
-
this.pendingRequest.resolve(packet);
|
|
131
|
-
const result = yield this.iterator.next();
|
|
132
|
-
return result.value;
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
dispose() {
|
|
136
|
-
var _a, _b;
|
|
137
|
-
(_b = (_a = this.iterator) === null || _a === void 0 ? void 0 : _a.return) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.AdbAuthenticationHandler = AdbAuthenticationHandler;
|
|
141
|
-
//# sourceMappingURL=auth.js.map
|
package/cjs/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";;;;AAAA,4CAAmD;AAGnD,qCAA8E;AAC9E,qCAAgE;AAChE,mCAAqE;AAUrE,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,+CAAS,CAAA;IACT,uDAAa,CAAA;IACb,uDAAa,CAAA;AACjB,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAoBM,MAAM,yBAAyB,GAAqB,UACvD,eAAmC,EACnC,cAAwC;;;;YAExC,KAAwB,IAAA,KAAA,sBAAA,eAAe,CAAC,WAAW,EAAE,CAAA,IAAA;gBAA1C,MAAM,GAAG,WAAA,CAAA;gBAChB,MAAM,MAAM,GAAG,sBAAM,cAAc,EAAE,CAAA,CAAC;gBAEtC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,EAAE;oBACnC,qCAAO;iBACV;gBAED,MAAM,SAAS,GAAG,aAAI,CAAC,GAAG,EAAE,MAAM,CAAC,OAAQ,CAAC,CAAC;gBAC7C,4BAAM;oBACF,OAAO,EAAE,mBAAU,CAAC,IAAI;oBACxB,IAAI,EAAE,WAAW,CAAC,SAAS;oBAC3B,IAAI,EAAE,CAAC;oBACP,OAAO,EAAE,SAAS;iBACrB,CAAA,CAAC;aACL;;;;;;;;;IACL,CAAC;CAAA,CAAC;AAnBW,QAAA,yBAAyB,6BAmBpC;AAEK,MAAM,yBAAyB,GAAqB,UACvD,eAAmC,EACnC,cAAwC;;;QAExC,MAAM,MAAM,GAAG,sBAAM,cAAc,EAAE,CAAA,CAAC;QAEtC,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,KAAK,EAAE;YACnC,qCAAO;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MAAM,aAAa,IAAI,IAAI,CAAC,cAAc,EAAE;;oBAC7C,KAA2B,IAAA,oBAAA,sBAAA,aAAa,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA,CAAA,IAAA;wBAAxE,MAAM,MAAM,WAAA,CAAA;wBACnB,0CAA0C;wBAC1C,wDAAwD;wBACxD,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAe,EAAa,CAAC;wBAEvD,oCAAoC;wBACpC,4BAAM,MAAM,CAAA,CAAC;qBAChB;;;;;;;;;gBAED,iCAAiC;gBACjC,6DAA6D;aAChE;YAED,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;KAAA;IAEY,MAAM,CAAC,MAAiB;;YACjC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;aAC3C;YAED,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC,KAAK,CAAC;QACxB,CAAC;KAAA;IAEM,OAAO;;QACV,MAAA,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,kDAAI,CAAC;IAC9B,CAAC;CACJ;AApDD,4DAoDC"}
|
package/cjs/backend.js
DELETED
package/cjs/backend.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":""}
|
package/cjs/commands/base.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdbCommandBase = void 0;
|
|
4
|
-
const event_1 = require("@yume-chan/event");
|
|
5
|
-
class AdbCommandBase extends event_1.AutoDisposable {
|
|
6
|
-
constructor(adb) {
|
|
7
|
-
super();
|
|
8
|
-
this.adb = adb;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.AdbCommandBase = AdbCommandBase;
|
|
12
|
-
//# sourceMappingURL=base.js.map
|
package/cjs/commands/base.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":";;;AAAA,4CAAkD;AAGlD,MAAa,cAAe,SAAQ,sBAAc;IAG9C,YAAmB,GAAQ;QACvB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAPD,wCAOC"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdbDemoMode = exports.AdbDemoModeStatusBarModes = exports.AdbDemoModeMobileDataTypes = exports.AdbDemoModeWifiSignalStrength = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const base_1 = require("./base");
|
|
6
|
-
var AdbDemoModeWifiSignalStrength;
|
|
7
|
-
(function (AdbDemoModeWifiSignalStrength) {
|
|
8
|
-
AdbDemoModeWifiSignalStrength["Hidden"] = "null";
|
|
9
|
-
AdbDemoModeWifiSignalStrength["Level0"] = "0";
|
|
10
|
-
AdbDemoModeWifiSignalStrength["Level1"] = "1";
|
|
11
|
-
AdbDemoModeWifiSignalStrength["Level2"] = "2";
|
|
12
|
-
AdbDemoModeWifiSignalStrength["Level3"] = "3";
|
|
13
|
-
AdbDemoModeWifiSignalStrength["Level4"] = "4";
|
|
14
|
-
})(AdbDemoModeWifiSignalStrength = exports.AdbDemoModeWifiSignalStrength || (exports.AdbDemoModeWifiSignalStrength = {}));
|
|
15
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java;l=1073
|
|
16
|
-
exports.AdbDemoModeMobileDataTypes = ['1x', '3g', '4g', '4g+', '5g', '5ge', '5g+',
|
|
17
|
-
'e', 'g', 'h', 'h+', 'lte', 'lte+', 'dis', 'not', 'null'];
|
|
18
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3136
|
|
19
|
-
exports.AdbDemoModeStatusBarModes = ['opaque', 'translucent', 'semi-transparent', 'transparent', 'warning'];
|
|
20
|
-
class AdbDemoMode extends base_1.AdbCommandBase {
|
|
21
|
-
getAllowed() {
|
|
22
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const result = yield this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.AllowedSettingKey);
|
|
24
|
-
return result.trim() === '1';
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
setAllowed(value) {
|
|
28
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
if (value) {
|
|
30
|
-
yield this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.AllowedSettingKey, '1');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
yield this.setEnabled(false);
|
|
34
|
-
yield this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.AllowedSettingKey);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
getEnabled() {
|
|
39
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const result = yield this.adb.childProcess.exec('settings', 'get', 'global', AdbDemoMode.EnabledSettingKey);
|
|
41
|
-
return result.trim() === '1';
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
setEnabled(value) {
|
|
45
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
if (value) {
|
|
47
|
-
yield this.adb.childProcess.exec('settings', 'put', 'global', AdbDemoMode.EnabledSettingKey, '1');
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
yield this.adb.childProcess.exec('settings', 'delete', 'global', AdbDemoMode.EnabledSettingKey);
|
|
51
|
-
yield this.broadcast('exit');
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
broadcast(command, extra) {
|
|
56
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
yield this.adb.childProcess.exec('am', 'broadcast', '-a', 'com.android.systemui.demo', '-e', 'command', command, ...(extra ? Object.entries(extra).flatMap(([key, value]) => ['-e', key, value]) : []));
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
setBatteryLevel(level) {
|
|
61
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
yield this.broadcast('battery', { level: level.toString() });
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
setBatteryCharging(value) {
|
|
66
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
yield this.broadcast('battery', { plugged: value.toString() });
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
setPowerSaveMode(value) {
|
|
71
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
yield this.broadcast('battery', { powersave: value.toString() });
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
setAirplaneMode(show) {
|
|
76
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
yield this.broadcast('network', { airplane: show ? 'show' : 'hide' });
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
setWifiSignalStrength(value) {
|
|
81
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
yield this.broadcast('network', { wifi: 'show', level: value });
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
setMobileDataType(value) {
|
|
86
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
for (let i = 0; i < 2; i += 1) {
|
|
88
|
-
yield this.broadcast('network', {
|
|
89
|
-
mobile: 'show',
|
|
90
|
-
sims: '1',
|
|
91
|
-
nosim: 'hide',
|
|
92
|
-
slot: '0',
|
|
93
|
-
datatype: value,
|
|
94
|
-
fully: 'true',
|
|
95
|
-
roam: 'false',
|
|
96
|
-
level: '4',
|
|
97
|
-
inflate: 'false',
|
|
98
|
-
activity: 'in',
|
|
99
|
-
carriernetworkchange: 'hide',
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
setMobileSignalStrength(value) {
|
|
105
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
yield this.broadcast('network', { mobile: 'show', level: value });
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
setNoSimCardIcon(show) {
|
|
110
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
yield this.broadcast('network', { nosim: show ? 'show' : 'hide' });
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
setStatusBarMode(mode) {
|
|
115
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
yield this.broadcast('bars', { mode });
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
setVibrateModeEnabled(value) {
|
|
120
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=103
|
|
122
|
-
yield this.broadcast('status', { volume: value ? 'vibrate' : 'hide' });
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
setBluetoothConnected(value) {
|
|
126
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/DemoStatusIcons.java;l=114
|
|
128
|
-
yield this.broadcast('status', { bluetooth: value ? 'connected' : 'hide' });
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
setLocatingIcon(show) {
|
|
132
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
yield this.broadcast('status', { location: show ? 'show' : 'hide' });
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
setAlarmIcon(show) {
|
|
137
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
yield this.broadcast('status', { alarm: show ? 'show' : 'hide' });
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
setSyncingIcon(show) {
|
|
142
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
yield this.broadcast('status', { sync: show ? 'show' : 'hide' });
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
setMuteIcon(show) {
|
|
147
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
148
|
-
yield this.broadcast('status', { mute: show ? 'show' : 'hide' });
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
setSpeakerPhoneIcon(show) {
|
|
152
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
yield this.broadcast('status', { speakerphone: show ? 'show' : 'hide' });
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
setNotificationsVisibility(show) {
|
|
157
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
158
|
-
// https://cs.android.com/android/platform/superproject/+/master:frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java;l=3131
|
|
159
|
-
yield this.broadcast('notifications', { visible: show.toString() });
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
setTime(hour, minute) {
|
|
163
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
yield this.broadcast('clock', { hhmm: `${hour.toString().padStart(2, '0')}${minute.toString().padStart(2, '0')}` });
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.AdbDemoMode = AdbDemoMode;
|
|
169
|
-
AdbDemoMode.AllowedSettingKey = 'sysui_demo_allowed';
|
|
170
|
-
// Demo Mode actually doesn't have a setting indicates its enablement
|
|
171
|
-
// However Developer Mode menu uses this key
|
|
172
|
-
// So we can only try our best to guess if it's enabled
|
|
173
|
-
AdbDemoMode.EnabledSettingKey = 'sysui_tuner_demo_on';
|
|
174
|
-
//# sourceMappingURL=demo-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"demo-mode.js","sourceRoot":"","sources":["../../src/commands/demo-mode.ts"],"names":[],"mappings":";;;;AAAA,iCAAwC;AAExC,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACrC,gDAAe,CAAA;IACf,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,6CAAY,CAAA;IACZ,6CAAY,CAAA;AAChB,CAAC,EAPW,6BAA6B,GAA7B,qCAA6B,KAA7B,qCAA6B,QAOxC;AAED,8KAA8K;AACjK,QAAA,0BAA0B,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK;IAClF,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAIvE,iKAAiK;AACpJ,QAAA,yBAAyB,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,CAAU,CAAC;AAI1H,MAAa,WAAY,SAAQ,qBAAc;IAQ9B,UAAU;;YACnB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC;YAC5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AAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QACxH,CAAC;KAAA;;AAxIL,kCAyIC;AAxI0B,6BAAiB,GAAG,oBAAoB,CAAC;AAEhE,qEAAqE;AACrE,4CAA4C;AAC5C,uDAAuD;AAChC,6BAAiB,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.framebuffer = exports.AdbFrameBufferV2 = exports.AdbFrameBufferV1 = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const struct_1 = tslib_1.__importDefault(require("@yume-chan/struct"));
|
|
6
|
-
const stream_1 = require("../stream");
|
|
7
|
-
const Version = new struct_1.default({ littleEndian: true })
|
|
8
|
-
.uint32('version');
|
|
9
|
-
/*
|
|
10
|
-
* ADB uses 8 int32 fields to describe bit depths
|
|
11
|
-
* The only combination I have seen is RGBA8888, which is
|
|
12
|
-
* red_offset: 0
|
|
13
|
-
* red_length: 8
|
|
14
|
-
* blue_offset: 16
|
|
15
|
-
* blue_length: 8
|
|
16
|
-
* green_offset: 8
|
|
17
|
-
* green_length: 8
|
|
18
|
-
* alpha_offset: 24
|
|
19
|
-
* alpha_length: 8
|
|
20
|
-
*/
|
|
21
|
-
exports.AdbFrameBufferV1 = new struct_1.default({ littleEndian: true })
|
|
22
|
-
.uint32('bpp')
|
|
23
|
-
.uint32('size')
|
|
24
|
-
.uint32('width')
|
|
25
|
-
.uint32('height')
|
|
26
|
-
.uint32('red_offset')
|
|
27
|
-
.uint32('red_length')
|
|
28
|
-
.uint32('blue_offset')
|
|
29
|
-
.uint32('blue_length')
|
|
30
|
-
.uint32('green_offset')
|
|
31
|
-
.uint32('green_length')
|
|
32
|
-
.uint32('alpha_offset')
|
|
33
|
-
.uint32('alpha_length')
|
|
34
|
-
.uint8ClampedArray('data', { lengthField: 'size' });
|
|
35
|
-
exports.AdbFrameBufferV2 = new struct_1.default({ littleEndian: true })
|
|
36
|
-
.uint32('bpp')
|
|
37
|
-
.uint32('colorSpace')
|
|
38
|
-
.uint32('size')
|
|
39
|
-
.uint32('width')
|
|
40
|
-
.uint32('height')
|
|
41
|
-
.uint32('red_offset')
|
|
42
|
-
.uint32('red_length')
|
|
43
|
-
.uint32('blue_offset')
|
|
44
|
-
.uint32('blue_length')
|
|
45
|
-
.uint32('green_offset')
|
|
46
|
-
.uint32('green_length')
|
|
47
|
-
.uint32('alpha_offset')
|
|
48
|
-
.uint32('alpha_length')
|
|
49
|
-
.uint8ClampedArray('data', { lengthField: 'size' });
|
|
50
|
-
function framebuffer(adb) {
|
|
51
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const socket = yield adb.createSocket('framebuffer:');
|
|
53
|
-
const stream = new stream_1.AdbBufferedStream(socket);
|
|
54
|
-
const { version } = yield Version.deserialize(stream);
|
|
55
|
-
switch (version) {
|
|
56
|
-
case 1:
|
|
57
|
-
return exports.AdbFrameBufferV1.deserialize(stream);
|
|
58
|
-
case 2:
|
|
59
|
-
return exports.AdbFrameBufferV2.deserialize(stream);
|
|
60
|
-
default:
|
|
61
|
-
throw new Error('Unknown FrameBuffer version');
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
exports.framebuffer = framebuffer;
|
|
66
|
-
//# sourceMappingURL=framebuffer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"framebuffer.js","sourceRoot":"","sources":["../../src/commands/framebuffer.ts"],"names":[],"mappings":";;;;AAAA,uEAAuC;AAEvC,sCAA8C;AAE9C,MAAM,OAAO,GACT,IAAI,gBAAM,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;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;QACtD,MAAM,MAAM,GAAG,IAAI,0BAAiB,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACtD,QAAQ,OAAO,EAAE;YACb,KAAK,CAAC;gBACF,OAAO,wBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAChD,KAAK,CAAC;gBACF,OAAO,wBAAgB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAChD;gBACI,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;SACtD;IACL,CAAC;CAAA;AAZD,kCAYC"}
|
package/cjs/commands/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./base"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./demo-mode"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./framebuffer"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./install"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./reverse"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./shell"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./sync"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./tcpip"), exports);
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,sDAA4B;AAC5B,wDAA8B;AAC9B,oDAA0B;AAC1B,oDAA0B;AAC1B,kDAAwB;AACxB,iDAAuB;AACvB,kDAAwB"}
|
package/cjs/commands/install.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.install = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const shell_1 = require("./shell");
|
|
6
|
-
function install(adb, apk, onProgress) {
|
|
7
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
-
const filename = `/data/local/tmp/${Math.random().toString().substr(2)}.apk`;
|
|
9
|
-
// Upload apk file to tmp folder
|
|
10
|
-
const sync = yield adb.sync();
|
|
11
|
-
yield sync.write(filename, apk, undefined, undefined, onProgress);
|
|
12
|
-
sync.dispose();
|
|
13
|
-
// Invoke `pm install` to install it
|
|
14
|
-
yield adb.childProcess.exec('pm', 'install', shell_1.escapeArg(filename));
|
|
15
|
-
// Remove the temp file
|
|
16
|
-
yield adb.rm(filename);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
exports.install = install;
|
|
20
|
-
//# sourceMappingURL=install.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":";;;;AACA,mCAAoC;AAEpC,SAAsB,OAAO,CACzB,GAAQ,EACR,GAAqE,EACrE,UAAuC;;QAEvC,MAAM,QAAQ,GAAG,mBAAmB,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;QAE7E,gCAAgC;QAChC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,oCAAoC;QACpC,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAElE,uBAAuB;QACvB,MAAM,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CAAA;AAjBD,0BAiBC"}
|
package/cjs/commands/reverse.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdbReverseCommand = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const event_1 = require("@yume-chan/event");
|
|
6
|
-
const struct_1 = tslib_1.__importDefault(require("@yume-chan/struct"));
|
|
7
|
-
const stream_1 = require("../stream");
|
|
8
|
-
const AdbReverseStringResponse = new struct_1.default({ littleEndian: true })
|
|
9
|
-
.string('length', { length: 4 })
|
|
10
|
-
.string('content', { lengthField: 'length', lengthFieldBase: 16 });
|
|
11
|
-
const AdbReverseErrorResponse = new struct_1.default({ littleEndian: true })
|
|
12
|
-
.fields(AdbReverseStringResponse)
|
|
13
|
-
.postDeserialize((value) => {
|
|
14
|
-
throw new Error(value.content);
|
|
15
|
-
});
|
|
16
|
-
class AdbReverseCommand extends event_1.AutoDisposable {
|
|
17
|
-
constructor(dispatcher) {
|
|
18
|
-
super();
|
|
19
|
-
this.localPortToHandler = new Map();
|
|
20
|
-
this.deviceAddressToLocalPort = new Map();
|
|
21
|
-
this.listening = false;
|
|
22
|
-
this.dispatcher = dispatcher;
|
|
23
|
-
this.addDisposable(this.dispatcher.onIncomingSocket(this.handleIncomingSocket, this));
|
|
24
|
-
}
|
|
25
|
-
handleIncomingSocket(e) {
|
|
26
|
-
if (e.handled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const address = this.dispatcher.backend.decodeUtf8(e.packet.payload);
|
|
30
|
-
// tcp:1234\0
|
|
31
|
-
const port = Number.parseInt(address.substring(4));
|
|
32
|
-
if (this.localPortToHandler.has(port)) {
|
|
33
|
-
this.localPortToHandler.get(port).onSocket(e.packet, e.socket);
|
|
34
|
-
e.handled = true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
createBufferedStream(service) {
|
|
38
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const socket = yield this.dispatcher.createSocket(service);
|
|
40
|
-
return new stream_1.AdbBufferedStream(socket);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
sendRequest(service) {
|
|
44
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const stream = yield this.createBufferedStream(service);
|
|
46
|
-
const success = this.dispatcher.backend.decodeUtf8(yield stream.read(4)) === 'OKAY';
|
|
47
|
-
if (!success) {
|
|
48
|
-
yield AdbReverseErrorResponse.deserialize(stream);
|
|
49
|
-
}
|
|
50
|
-
return stream;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
list() {
|
|
54
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const stream = yield this.createBufferedStream('reverse:list-forward');
|
|
56
|
-
const response = yield AdbReverseStringResponse.deserialize(stream);
|
|
57
|
-
return response.content.split('\n').map(line => {
|
|
58
|
-
const [deviceSerial, localName, remoteName] = line.split(' ');
|
|
59
|
-
return { deviceSerial, localName, remoteName };
|
|
60
|
-
});
|
|
61
|
-
// No need to close the stream, device will close it
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @param deviceAddress The address adbd on device is listening on. Can be `tcp:0` to let adbd choose an available TCP port by itself.
|
|
66
|
-
* @param localPort Native ADB will open a connection to localPort when reverse connection starts. In webadb, it's only used to uniquely identify a reverse registry, `handler` will be called on connection.
|
|
67
|
-
* @param handler A callback to handle incoming connections
|
|
68
|
-
* @returns If `deviceAddress` is `tcp:0`, return `tcp:{ACTUAL_LISTENING_PORT}`; otherwise, return `deviceAddress`.
|
|
69
|
-
*/
|
|
70
|
-
add(deviceAddress, localPort, handler) {
|
|
71
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const stream = yield this.sendRequest(`reverse:forward:${deviceAddress};tcp:${localPort}`);
|
|
73
|
-
// `tcp:0` tells the device to pick an available port.
|
|
74
|
-
// However, device will response with the selected port for all `tcp:` requests.
|
|
75
|
-
if (deviceAddress.startsWith('tcp:')) {
|
|
76
|
-
const response = yield AdbReverseStringResponse.deserialize(stream);
|
|
77
|
-
deviceAddress = `tcp:${Number.parseInt(response.content, 10)}`;
|
|
78
|
-
}
|
|
79
|
-
this.localPortToHandler.set(localPort, handler);
|
|
80
|
-
this.deviceAddressToLocalPort.set(deviceAddress, localPort);
|
|
81
|
-
return deviceAddress;
|
|
82
|
-
// No need to close the stream, device will close it
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
remove(deviceAddress) {
|
|
86
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
yield this.sendRequest(`reverse:killforward:${deviceAddress}`);
|
|
88
|
-
if (this.deviceAddressToLocalPort.has(deviceAddress)) {
|
|
89
|
-
this.localPortToHandler.delete(this.deviceAddressToLocalPort.get(deviceAddress));
|
|
90
|
-
this.deviceAddressToLocalPort.delete(deviceAddress);
|
|
91
|
-
}
|
|
92
|
-
// No need to close the stream, device will close it
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
removeAll() {
|
|
96
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
yield this.sendRequest(`reverse:killforward-all`);
|
|
98
|
-
this.deviceAddressToLocalPort.clear();
|
|
99
|
-
this.localPortToHandler.clear();
|
|
100
|
-
// No need to close the stream, device will close it
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.AdbReverseCommand = AdbReverseCommand;
|
|
105
|
-
//# sourceMappingURL=reverse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.js","sourceRoot":"","sources":["../../src/commands/reverse.ts"],"names":[],"mappings":";;;;AAAA,4CAAkD;AAClD,uEAAuC;AAGvC,sCAA8C;AAc9C,MAA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GD,8CAsGC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdbChildProcess = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const features_1 = require("../../features");
|
|
6
|
-
const legacy_1 = require("./legacy");
|
|
7
|
-
const protocol_1 = require("./protocol");
|
|
8
|
-
tslib_1.__exportStar(require("./legacy"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./protocol"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./types"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./utils"), exports);
|
|
12
|
-
const DefaultOptions = {
|
|
13
|
-
shellProtocol: 'auto',
|
|
14
|
-
};
|
|
15
|
-
class AdbChildProcess {
|
|
16
|
-
constructor(adb) {
|
|
17
|
-
this.adb = adb;
|
|
18
|
-
}
|
|
19
|
-
get supportsShellProtocol() {
|
|
20
|
-
return this.adb.features.includes(features_1.AdbFeatures.ShellV2);
|
|
21
|
-
}
|
|
22
|
-
createShell(command, options) {
|
|
23
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
let { shellProtocol } = Object.assign(Object.assign({}, DefaultOptions), options);
|
|
25
|
-
switch (shellProtocol) {
|
|
26
|
-
case 'auto':
|
|
27
|
-
shellProtocol = this.supportsShellProtocol ? 'enable' : 'disable';
|
|
28
|
-
break;
|
|
29
|
-
case 'enable':
|
|
30
|
-
if (!shellProtocol) {
|
|
31
|
-
throw new Error('`shellProtocol` has been set to `enable` but the device does not support it');
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
if (shellProtocol === 'enable') {
|
|
36
|
-
return new protocol_1.AdbShellProtocol(yield this.adb.createSocket(`shell,v2,pty:${command}`));
|
|
37
|
-
}
|
|
38
|
-
return new legacy_1.AdbLegacyShell(yield this.adb.createSocket(`shell:${command}`));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
shell(options) {
|
|
42
|
-
return this.createShell('', options);
|
|
43
|
-
}
|
|
44
|
-
spawn(command, options) {
|
|
45
|
-
if (Array.isArray(command)) {
|
|
46
|
-
command = command.join(' ');
|
|
47
|
-
}
|
|
48
|
-
return this.createShell(command, options);
|
|
49
|
-
}
|
|
50
|
-
exec(command, ...args) {
|
|
51
|
-
// `exec` only need all output, using Shell Protocol only makes it more complicate.
|
|
52
|
-
return this.adb.createSocketAndReadAll(`shell:${command} ${args.join(' ')}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.AdbChildProcess = AdbChildProcess;
|
|
56
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/shell/index.ts"],"names":[],"mappings":";;;;AACA,6CAA6C;AAC7C,qCAA0C;AAC1C,yCAA8C;AAG9C,mDAAyB;AACzB,qDAA2B;AAC3B,kDAAwB;AACxB,kDAAwB;AAQxB,MAAM,cAAc,GAA2B;IAC3C,aAAa,EAAE,MAAM;CACxB,CAAC;AAEF,MAAa,eAAe;IAOxB,YAAmB,GAAQ;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAND,IAAW,qBAAqB;QAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,QAAS,CAAC,QAAQ,CAAC,sBAAW,CAAC,OAAO,CAAC,CAAC;IAC5D,CAAC;IAMa,WAAW,CAAC,OAAe,EAAE,OAAyC;;YAChF,IAAI,EAAE,aAAa,EAAE,mCAAQ,cAAc,GAAK,OAAO,CAAE,CAAC;YAC1D,QAAQ,aAAa,EAAE;gBACnB,KAAK,MAAM;oBACP,aAAa,GAAG,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;oBAClE,MAAM;gBACV,KAAK,QAAQ;oBACT,IAAI,CAAC,aAAa,EAAE;wBA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