mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 09:59:25 +00:00
Compare commits
215 Commits
v1.3.1
...
adelphes/j
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e84509a072 | ||
|
|
6a29651208 | ||
|
|
f551a92236 | ||
|
|
33daf68649 | ||
|
|
cc3b995de3 | ||
|
|
f2137eb35c | ||
|
|
78c8c4ac6a | ||
|
|
f33cc13ebd | ||
|
|
346c4a937b | ||
|
|
2fd2c001ce | ||
|
|
a902d3daeb | ||
|
|
b5cc60a516 | ||
|
|
4740f6533a | ||
|
|
92129e4cb0 | ||
|
|
f50aaa48aa | ||
|
|
7aa04dfc56 | ||
|
|
b2eb0c973b | ||
|
|
27db9f5e3b | ||
|
|
279807a4c5 | ||
|
|
ea9a7f1a85 | ||
|
|
10848b2910 | ||
|
|
4cd0764a9d | ||
|
|
dc8098c471 | ||
|
|
ad585a8a84 | ||
|
|
9fde7bcd9d | ||
|
|
3e1bd63330 | ||
|
|
7d1d215b79 | ||
|
|
1b2cd957ec | ||
|
|
2f5ed65461 | ||
|
|
00da3cd2f1 | ||
|
|
31f3826971 | ||
|
|
9498888ee6 | ||
|
|
d74837158a | ||
|
|
cd1c360ef0 | ||
|
|
61397dab95 | ||
|
|
bdb5986c4b | ||
|
|
acd18e4105 | ||
|
|
3dbe1dea3e | ||
|
|
0205a317d9 | ||
|
|
3e77b3f1c9 | ||
|
|
a278237486 | ||
|
|
6ca4ea353d | ||
|
|
4554b8890e | ||
|
|
2716505a77 | ||
|
|
fed16b22f5 | ||
|
|
3a55d3627f | ||
|
|
2ee1c72b6a | ||
|
|
c8311ea2e4 | ||
|
|
bb1a326768 | ||
|
|
18049ea08c | ||
|
|
113a7379ed | ||
|
|
baabf1e7a9 | ||
|
|
71600cf366 | ||
|
|
a567ea7266 | ||
|
|
2c522e38b1 | ||
|
|
8f9bf25e4c | ||
|
|
edb16c667b | ||
|
|
c943408613 | ||
|
|
43dbcb4d47 | ||
|
|
8aaf6a6f0e | ||
|
|
563142661a | ||
|
|
f9a2665364 | ||
|
|
7038bf7090 | ||
|
|
175ce1d644 | ||
|
|
849c49acb6 | ||
|
|
cda0810df1 | ||
|
|
e2765fd982 | ||
|
|
f67c03bb34 | ||
|
|
b0a2475696 | ||
|
|
69e77eae8a | ||
|
|
b45314cc95 | ||
|
|
e7e73387aa | ||
|
|
089d174e08 | ||
|
|
b70592a0f7 | ||
|
|
db865825d0 | ||
|
|
591907f523 | ||
|
|
cd6bf29e9f | ||
|
|
ce345965e5 | ||
|
|
3073dfcd25 | ||
|
|
085f027856 | ||
|
|
56464ef537 | ||
|
|
4f0e55a909 | ||
|
|
fbb275600a | ||
|
|
4fc616daa1 | ||
|
|
df210b4659 | ||
|
|
491086a750 | ||
|
|
43c701adc8 | ||
|
|
153a6e869b | ||
|
|
6badc9fdb6 | ||
|
|
a034a90735 | ||
|
|
82e660eabc | ||
|
|
9be298293f | ||
|
|
7fd7809be3 | ||
|
|
f4743e456b | ||
|
|
1255a15bba | ||
|
|
f05b34171c | ||
|
|
d869afe2fa | ||
|
|
c1f2ccdc4a | ||
|
|
b143772b26 | ||
|
|
0f296379c6 | ||
|
|
2da127edc0 | ||
|
|
13cdd1e0bc | ||
|
|
3c505b05be | ||
|
|
458d8e553e | ||
|
|
4f62b5a06e | ||
|
|
b9fd805a6d | ||
|
|
29e6132cac | ||
|
|
d85f49546a | ||
|
|
143a31b0c4 | ||
|
|
1c8eb75b4f | ||
|
|
fe28924e0c | ||
|
|
dc39ae53b1 | ||
|
|
9d4e8ab7d0 | ||
|
|
ecf67d44c0 | ||
|
|
198317a5c2 | ||
|
|
bccc29251c | ||
|
|
e88475dddd | ||
|
|
8df1a3464b | ||
|
|
26e54bba37 | ||
|
|
b61ef125fc | ||
|
|
6af16cac43 | ||
|
|
9017752d7b | ||
|
|
58ff585a9d | ||
|
|
46838686ea | ||
|
|
9ac6086bad | ||
|
|
8b71037a58 | ||
|
|
eeb6d7c3d0 | ||
|
|
f74f4b26c6 | ||
|
|
b050f3a82d | ||
|
|
1801a81c0f | ||
|
|
14582503da | ||
|
|
4af183e4e1 | ||
|
|
a8653f26df | ||
|
|
2f3349c359 | ||
|
|
549473d765 | ||
|
|
01ae51d91a | ||
|
|
18d56e0bc0 | ||
|
|
da8d37aafd | ||
|
|
f4a18ebcdc | ||
|
|
c70b75783e | ||
|
|
ac9a7ed43a | ||
|
|
d0308781f7 | ||
|
|
974ec93841 | ||
|
|
c454753385 | ||
|
|
3ab97ef235 | ||
|
|
5b29b9998d | ||
|
|
90c537b82d | ||
|
|
cd725638cd | ||
|
|
87a2d72ae3 | ||
|
|
c9ab48031e | ||
|
|
dd9d23c64a | ||
|
|
b175b52065 | ||
|
|
6dffe61d62 | ||
|
|
309cc47107 | ||
|
|
41adfbe53e | ||
|
|
74a21ecbf8 | ||
|
|
252b476147 | ||
|
|
74a0339962 | ||
|
|
426735aa25 | ||
|
|
7c9acfd7ca | ||
|
|
261abb9cc7 | ||
|
|
1b1202598c | ||
|
|
c09620c481 | ||
|
|
3a85c6f819 | ||
|
|
6fd6376dea | ||
|
|
04c0e97c81 | ||
|
|
bbc6007338 | ||
|
|
930237359e | ||
|
|
c16bb1b30a | ||
|
|
f14d70feb6 | ||
|
|
67c1fc9db6 | ||
|
|
49b5480870 | ||
|
|
6bcdecee07 | ||
|
|
a4be37d872 | ||
|
|
6ef64b1d9c | ||
|
|
4750212484 | ||
|
|
20831c2326 | ||
|
|
fc9d58b9da | ||
|
|
c56732c689 | ||
|
|
ebc5f73bcc | ||
|
|
7d6af70ae1 | ||
|
|
ce6ed14aaa | ||
|
|
b30228c10b | ||
|
|
00d4998301 | ||
|
|
52db53e65a | ||
|
|
37dddc48d9 | ||
|
|
18ff477d34 | ||
|
|
de846fef12 | ||
|
|
4ba7fd1b3d | ||
|
|
f294cb2af1 | ||
|
|
67f1b617ff | ||
|
|
09c15ef401 | ||
|
|
13068cbcea | ||
|
|
432cd24f3c | ||
|
|
1238d7980a | ||
|
|
19810a2f75 | ||
|
|
61b787d5ff | ||
|
|
c113e8bee0 | ||
|
|
ee8f6513bf | ||
|
|
4ed8411180 | ||
|
|
9c579662e6 | ||
|
|
b1d4261f28 | ||
|
|
b50e7bea46 | ||
|
|
9a4dd63dc7 | ||
|
|
c43ba6ccf1 | ||
|
|
4f70cb0128 | ||
|
|
81a608b6da | ||
|
|
ff8cf5b91a | ||
|
|
a46474c3c2 | ||
|
|
23dc6d3871 | ||
|
|
bdc5b1d4cd | ||
|
|
25a6ace1e4 | ||
|
|
66cee87685 | ||
|
|
79bba76b9f | ||
|
|
3156a2ddc2 |
@@ -1,14 +1,5 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
### version 1.3.0
|
|
||||||
* Support `ADB_SERVER_SOCKET`, `ANDROID_ADB_SERVER_ADDRESS` & `ANDROID_ADB_SERVER_PORT` env vars when connecting to ADB.
|
|
||||||
* Replace `adbPort` configuration option with a new `adbSocket` value to allow ADB server host to be overidden. (`adbPort` is now deprecated).
|
|
||||||
* Allow the JDWP local port to be fixed using a new `jdwpPort` configuration option.
|
|
||||||
|
|
||||||
### version 1.2.1
|
|
||||||
* Java Intellisense: automatically import dependencies of AndroidX libraries.
|
|
||||||
* Debugger: Warn about open instances of Android Studio
|
|
||||||
|
|
||||||
### version 1.2.0
|
### version 1.2.0
|
||||||
* Java Intellisense beta.
|
* Java Intellisense beta.
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ The following settings are used to configure the debugger:
|
|||||||
// Fully qualified path to the built APK (Android Application Package).
|
// Fully qualified path to the built APK (Android Application Package).
|
||||||
"apkFile": "${workspaceRoot}/app/build/outputs/apk/app-debug.apk",
|
"apkFile": "${workspaceRoot}/app/build/outputs/apk/app-debug.apk",
|
||||||
|
|
||||||
// `host:port` configuration for connecting to the ADB (Android Debug Bridge) server instance.
|
// Port number to connect to the local ADB (Android Debug Bridge) instance.
|
||||||
// Default: localhost:5037
|
// Default: 5037
|
||||||
"adbSocket": "localhost:5037",
|
"adbPort": 5037,
|
||||||
|
|
||||||
// Automatically launch 'adb start-server' if not already started.
|
// Automatically launch 'adb start-server' if not already started.
|
||||||
// Default: true
|
// Default: true
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
const os = require('os');
|
|
||||||
let mp;
|
let mp;
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
let uid;
|
let uid;
|
||||||
@@ -7,11 +6,6 @@ let sid;
|
|||||||
/** @type {Map<string,[number,number]>} */
|
/** @type {Map<string,[number,number]>} */
|
||||||
const timeLabels = new Map();
|
const timeLabels = new Map();
|
||||||
let session_start = Date.now();
|
let session_start = Date.now();
|
||||||
/** @type {string|Promise<string>} */
|
|
||||||
let ip = getCurrentIP()
|
|
||||||
.catch(() => null)
|
|
||||||
.then(res => ip = res);
|
|
||||||
let queued_events = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [t]
|
* @param {string} [t]
|
||||||
@@ -36,6 +30,7 @@ function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props)
|
|||||||
if (!props) {
|
if (!props) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const os = require('os');
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
event(`${package_json.name}-start`, {
|
event(`${package_json.name}-start`, {
|
||||||
extension: package_json.name,
|
extension: package_json.name,
|
||||||
@@ -52,17 +47,6 @@ function init(t = '0cca95950055c6553804a46ce7e3df18', u, s, package_json, props)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentIP() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
require('https').get(
|
|
||||||
Buffer.from('aHR0cHM6Ly91YTF4c3JhM2ZhLmV4ZWN1dGUtYXBpLmV1LXdlc3QtMi5hbWF6b25hd3MuY29tL3JlbA==','base64').toString(),
|
|
||||||
{ headers: { 'Content-Type': 'application/json' } },
|
|
||||||
res => resolve(res.headers['x-request-ip'])
|
|
||||||
)
|
|
||||||
.on('error', err => reject(err));
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} eventName
|
* @param {string} eventName
|
||||||
@@ -72,36 +56,16 @@ function event(eventName, properties) {
|
|||||||
if (!mp) {
|
if (!mp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (queued_events) {
|
|
||||||
queued_events.push({eventName, properties});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ip instanceof Promise) {
|
|
||||||
queued_events = [{eventName, properties}]
|
|
||||||
ip.catch(() => {}).then(() => {
|
|
||||||
const e = queued_events;
|
|
||||||
queued_events = null;
|
|
||||||
e.forEach(({eventName, properties}) => event(eventName, properties));
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
if (uid) {
|
if (uid) {
|
||||||
mp.track(eventName, {
|
mp.track(eventName, {
|
||||||
ip,
|
|
||||||
distinct_id: uid,
|
distinct_id: uid,
|
||||||
session_id: sid,
|
session_id: sid,
|
||||||
session_length: Math.trunc((Date.now() - session_start) / 60e3),
|
session_length: Math.trunc((Date.now() - session_start) / 60e3),
|
||||||
...properties,
|
...properties,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mp.track(eventName, {
|
mp.track(eventName, properties);
|
||||||
ip,
|
|
||||||
platform: process.platform,
|
|
||||||
release: os.release(),
|
|
||||||
node_version: process.version,
|
|
||||||
...properties,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|||||||
6
langserver/package-lock.json
generated
6
langserver/package-lock.json
generated
@@ -171,10 +171,10 @@
|
|||||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||||
},
|
},
|
||||||
"java-mti": {
|
"java-mti": {
|
||||||
"version": "github:adelphes/java-mti#ec164ace68267813a1ca9df18651b51e3f3f067d",
|
"version": "github:adelphes/java-mti#d0e1e45bad4d2bba453dbcb5ad527db023f223e8",
|
||||||
"from": "github:adelphes/java-mti#ec164ac",
|
"from": "github:adelphes/java-mti#d0e1e45",
|
||||||
"requires": {
|
"requires": {
|
||||||
"unzipper": "0.10.11"
|
"unzipper": "^0.10.11"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"listenercount": {
|
"listenercount": {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"java-mti": "adelphes/java-mti#ec164ac",
|
"java-mti": "adelphes/java-mti#d0e1e45",
|
||||||
"mixpanel": "0.11.0",
|
"mixpanel": "0.11.0",
|
||||||
"uuid": "8.2.0",
|
"uuid": "8.2.0",
|
||||||
"vscode-languageserver": "6.1.1",
|
"vscode-languageserver": "6.1.1",
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "android-dev-ext",
|
"name": "android-dev-ext",
|
||||||
"version": "1.3.1",
|
"version": "1.2.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
32
package.json
32
package.json
@@ -2,7 +2,7 @@
|
|||||||
"name": "android-dev-ext",
|
"name": "android-dev-ext",
|
||||||
"displayName": "Android",
|
"displayName": "Android",
|
||||||
"description": "Android debugging support for VS Code",
|
"description": "Android debugging support for VS Code",
|
||||||
"version": "1.3.1",
|
"version": "1.2.0",
|
||||||
"publisher": "adelphes",
|
"publisher": "adelphes",
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -238,7 +238,8 @@
|
|||||||
"launch": {
|
"launch": {
|
||||||
"required": [
|
"required": [
|
||||||
"appSrcRoot",
|
"appSrcRoot",
|
||||||
"apkFile"
|
"apkFile",
|
||||||
|
"adbPort"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"amStartArgs": {
|
"amStartArgs": {
|
||||||
@@ -264,17 +265,12 @@
|
|||||||
},
|
},
|
||||||
"adbPort": {
|
"adbPort": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037\nDeprecated: Configure the 'adbSocket' property instead.",
|
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037",
|
||||||
"default": 5037
|
"default": 5037
|
||||||
},
|
},
|
||||||
"adbSocket": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "`host : port` configuration for connecting to the ADB (Android Debug Bridge) server instance. Default: \"localhost:5037\"",
|
|
||||||
"default": "localhost:5037"
|
|
||||||
},
|
|
||||||
"autoStartADB": {
|
"autoStartADB": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Automatically attempt to launch 'adb start-server' if not already started. Default: true",
|
"description": "Automatically launch 'adb start-server' if not already started. Default: true",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
"callStackDisplaySize": {
|
"callStackDisplaySize": {
|
||||||
@@ -282,11 +278,6 @@
|
|||||||
"description": "Number of entries to display in call stack views (for locations outside of the project source). 0 shows the entire call stack. Default: 1",
|
"description": "Number of entries to display in call stack views (for locations outside of the project source). 0 shows the entire call stack. Default: 1",
|
||||||
"default": 1
|
"default": 1
|
||||||
},
|
},
|
||||||
"jdwpPort": {
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Manually specify the local port used for connecting to the on-device debugger client.\nThis can be useful if you are using port-forwarding to connect to a remote device.\nThe specified port must be available and different from the ADB socket port.\nSet to 0 for automatic (dynamic) assignment.\nDefault: 0",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"launchActivity": {
|
"launchActivity": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Manually specify the activity to run when the app is started.",
|
"description": "Manually specify the activity to run when the app is started.",
|
||||||
@@ -334,6 +325,7 @@
|
|||||||
"attach": {
|
"attach": {
|
||||||
"required": [
|
"required": [
|
||||||
"appSrcRoot",
|
"appSrcRoot",
|
||||||
|
"adbPort",
|
||||||
"processId"
|
"processId"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -344,19 +336,9 @@
|
|||||||
},
|
},
|
||||||
"adbPort": {
|
"adbPort": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037\nDeprecated: Configure the 'adbSocket' property instead.",
|
"description": "Port number to connect to the local ADB (Android Debug Bridge) instance. Default: 5037",
|
||||||
"default": 5037
|
"default": 5037
|
||||||
},
|
},
|
||||||
"adbSocket": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "`host : port` configuration for connecting to the ADB (Android Debug Bridge) server instance. Default: \"localhost:5037\"",
|
|
||||||
"default": "localhost:5037"
|
|
||||||
},
|
|
||||||
"jdwpPort": {
|
|
||||||
"type": "integer",
|
|
||||||
"description": "Manually specify the local port used for connecting to the on-device debugger client.\nThis can be useful if you are using port-forwarding to connect to a remote device.\nThe specified port must be available and different from the ADB socket port.\nSet to 0 for automatic (dynamic) assignment.\nDefault: 0",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"processId": {
|
"processId": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "PID of process to attach to.\n\"${command:PickAndroidProcess}\" will display a list of debuggable PIDs to choose from during launch.",
|
"description": "PID of process to attach to.\n\"${command:PickAndroidProcess}\" will display a list of debuggable PIDs to choose from during launch.",
|
||||||
|
|||||||
@@ -36,94 +36,17 @@ function parse_device_list(data, extended = false) {
|
|||||||
return devicelist;
|
return devicelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
let adbSocketParams;
|
|
||||||
/**
|
|
||||||
* Return the host and port for connecting to the ADB server
|
|
||||||
*/
|
|
||||||
function getADBSocketParams() {
|
|
||||||
// this is memoized to prevent alterations once the debug session is up and running
|
|
||||||
if (adbSocketParams) {
|
|
||||||
return adbSocketParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
return adbSocketParams = getIntialADBSocketParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the socket parameters for connecting to an ADB server instance.
|
|
||||||
|
|
||||||
* In priority order (highest first):
|
|
||||||
* 1. adbSocket debug configuration value
|
|
||||||
* 2. non-default adbPort debug configuration value (using localhost)
|
|
||||||
* 3. ADB_SERVER_SOCKET environment variable
|
|
||||||
* 4. ANDROID_ADB_SERVER_ADDRESS / ANDROID_ADB_SERVER_PORT environment variables
|
|
||||||
* 5. [localhost]:5037
|
|
||||||
*/
|
|
||||||
function getIntialADBSocketParams() {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve a trimmed environment variable or return a blank string
|
|
||||||
* @param {string} name
|
|
||||||
*/
|
|
||||||
function envValue(name) {
|
|
||||||
return (process.env[name] || '').trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
function decode_port_string(s) {
|
|
||||||
if (!/^\d+$/.test(s)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const portnum = parseInt(s, 10);
|
|
||||||
if (portnum < 1 || portnum > 65535) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return portnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
const default_host = '', default_port = 5037;
|
|
||||||
|
|
||||||
// the ADBSocket.HostPort value is automatically set with adbSocket/adbPort values from
|
|
||||||
// the debug configuration when the debugger session starts.
|
|
||||||
let socket_str = ADBSocket.HostPort.trim();
|
|
||||||
|
|
||||||
if (socket_str !== ADBSocket.DefaultHostPort) {
|
|
||||||
// non-default debug configuration values are configured (1. or 2.)
|
|
||||||
const [host, port] = socket_str.split(':');
|
|
||||||
return {
|
|
||||||
host,
|
|
||||||
port: decode_port_string(port) || default_port
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ADB_SERVER_SOCKET=tcp:<host>:<port>
|
|
||||||
const adb_server_socket_match = envValue('ADB_SERVER_SOCKET').match(/^\s*tcp(?::(.*))?(?::(\d+))\s*$/);
|
|
||||||
if (adb_server_socket_match) {
|
|
||||||
return {
|
|
||||||
host: adb_server_socket_match[1] || default_host,
|
|
||||||
port: decode_port_string(adb_server_socket_match[2]) || default_port,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
host: envValue('ANDROID_ADB_SERVER_ADDRESS') || default_host,
|
|
||||||
port: decode_port_string(envValue('ANDROID_ADB_SERVER_PORT')) || default_port,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ADBClient {
|
class ADBClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [deviceid]
|
* @param {string} [deviceid]
|
||||||
* @param {number} [adbPort] the port number to connect to ADB
|
* @param {number} [adbPort] the port number to connect to ADB
|
||||||
* @param {number} [adbHost] the hostname/ip address to connect to ADB
|
|
||||||
*/
|
*/
|
||||||
constructor(deviceid, adbPort, adbHost) {
|
constructor(deviceid, adbPort = ADBSocket.ADBPort) {
|
||||||
this.deviceid = deviceid;
|
this.deviceid = deviceid;
|
||||||
this.adbsocket = null;
|
this.adbsocket = null;
|
||||||
this.jdwp_socket = null;
|
this.jdwp_socket = null;
|
||||||
const default_adb_socket = getADBSocketParams();
|
this.adbPort = adbPort;
|
||||||
this.adbHost = adbHost || default_adb_socket.host;
|
|
||||||
this.adbPort = adbPort || default_adb_socket.port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async test_adb_connection() {
|
async test_adb_connection() {
|
||||||
@@ -247,10 +170,7 @@ class ADBClient {
|
|||||||
// note that upon success, this method does not close the connection (it must be left open for
|
// note that upon success, this method does not close the connection (it must be left open for
|
||||||
// future commands to be sent over the jdwp socket)
|
// future commands to be sent over the jdwp socket)
|
||||||
this.jdwp_socket = new JDWPSocket(o.onreply, o.ondisconnect);
|
this.jdwp_socket = new JDWPSocket(o.onreply, o.ondisconnect);
|
||||||
// assume the 'local' port (routed to connect to the process on the device)
|
await this.jdwp_socket.connect(o.localport)
|
||||||
// is set up on the same host that the adb server is running on
|
|
||||||
const adb_server_socket = getADBSocketParams();
|
|
||||||
await this.jdwp_socket.connect(o.localport, adb_server_socket.host);
|
|
||||||
await this.jdwp_socket.start();
|
await this.jdwp_socket.start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -356,9 +276,12 @@ class ADBClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect_to_adb() {
|
/**
|
||||||
|
* @param {string} [hostname]
|
||||||
|
*/
|
||||||
|
connect_to_adb(hostname = '127.0.0.1') {
|
||||||
this.adbsocket = new ADBSocket();
|
this.adbsocket = new ADBSocket();
|
||||||
return this.adbsocket.connect(this.adbPort, this.adbHost);
|
return this.adbsocket.connect(this.adbPort, hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect_from_adb () {
|
disconnect_from_adb () {
|
||||||
@@ -367,4 +290,3 @@ class ADBClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.ADBClient = ADBClient;
|
exports.ADBClient = ADBClient;
|
||||||
exports.getADBSocketParams = getADBSocketParams;
|
|
||||||
|
|||||||
@@ -325,11 +325,8 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef AndroidAttachArguments
|
* @typedef AndroidAttachArguments
|
||||||
* @property {number} adbPort
|
|
||||||
* @property {string} adbSocket
|
|
||||||
* @property {string} appSrcRoot
|
* @property {string} appSrcRoot
|
||||||
* @property {boolean} autoStartADB
|
* @property {boolean} autoStartADB
|
||||||
* @property {number} jdwpPort
|
|
||||||
* @property {number} processId
|
* @property {number} processId
|
||||||
* @property {string} targetDevice
|
* @property {string} targetDevice
|
||||||
* @property {boolean} trace
|
* @property {boolean} trace
|
||||||
@@ -343,7 +340,7 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
this.trace = args.trace;
|
this.trace = args.trace;
|
||||||
onMessagePrint(this.LOG.bind(this));
|
onMessagePrint(this.LOG.bind(this));
|
||||||
}
|
}
|
||||||
D(JSON.stringify({type: 'attach', args, env:process.env}, null, ' '));
|
D(`Attach: ${JSON.stringify(args)}`);
|
||||||
|
|
||||||
if (args.targetDevice === 'null') {
|
if (args.targetDevice === 'null') {
|
||||||
// "null" is returned from the device picker if there's an error or if the
|
// "null" is returned from the device picker if there's an error or if the
|
||||||
@@ -371,18 +368,6 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the custom ADB host and port
|
|
||||||
if (typeof args.adbSocket === 'string' && args.adbSocket) {
|
|
||||||
ADBSocket.HostPort = args.adbSocket;
|
|
||||||
} else if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
|
|
||||||
ADBSocket.HostPort = `:${args.adbPort}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the fixed JDWP port number (if any)
|
|
||||||
if (typeof args.jdwpPort === 'number' && args.jdwpPort >= 0 && args.jdwpPort <= 65535) {
|
|
||||||
Debugger.portManager.fixedport = args.jdwpPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// app_src_root must end in a path-separator for correct validation of sub-paths
|
// app_src_root must end in a path-separator for correct validation of sub-paths
|
||||||
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
|
this.app_src_root = ensure_path_end_slash(args.appSrcRoot);
|
||||||
@@ -453,21 +438,17 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
dbg_emulator: /^emulator/.test(this._device.serial),
|
dbg_emulator: /^emulator/.test(this._device.serial),
|
||||||
})
|
})
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
const msg = e.message||e.msg;
|
|
||||||
//this.performDisconnect();
|
//this.performDisconnect();
|
||||||
// exceptions use message, adbclient uses msg
|
// exceptions use message, adbclient uses msg
|
||||||
this.LOG('Attach failed: '+(msg||'No additional information is available'));
|
this.LOG('Attach failed: '+(e.message||e.msg||'No additional information is available'));
|
||||||
// more info for adb connect errors
|
// more info for adb connect errors
|
||||||
if (/^ADB server is not running/.test(e.msg)) {
|
if (/^ADB server is not running/.test(e.msg)) {
|
||||||
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
|
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
|
||||||
this.LOG(' adb start-server');
|
this.LOG(' adb start-server');
|
||||||
this.LOG('If you are running ADB using a non-default configuration, also make sure the adbSocket value in your launch.json is correct.');
|
this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.');
|
||||||
}
|
|
||||||
if (/ADB|JDWP/.test(msg)) {
|
|
||||||
this.LOG('Ensure any instances of Android Studio are closed and ADB is running.');
|
|
||||||
}
|
}
|
||||||
// tell the client we're done
|
// tell the client we're done
|
||||||
this.terminate_reason = `start-exception: ${msg}`;
|
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
|
||||||
this.sendEvent(new TerminatedEvent(false));
|
this.sendEvent(new TerminatedEvent(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,13 +456,11 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
/**
|
/**
|
||||||
* @typedef AndroidLaunchArguments
|
* @typedef AndroidLaunchArguments
|
||||||
* @property {number} adbPort
|
* @property {number} adbPort
|
||||||
* @property {string} adbSocket
|
|
||||||
* @property {string[]} amStartArgs
|
* @property {string[]} amStartArgs
|
||||||
* @property {string} apkFile
|
* @property {string} apkFile
|
||||||
* @property {string} appSrcRoot
|
* @property {string} appSrcRoot
|
||||||
* @property {boolean} autoStartADB
|
* @property {boolean} autoStartADB
|
||||||
* @property {number} callStackDisplaySize
|
* @property {number} callStackDisplaySize
|
||||||
* @property {number} jdwpPort
|
|
||||||
* @property {string} launchActivity
|
* @property {string} launchActivity
|
||||||
* @property {string} manifestFile
|
* @property {string} manifestFile
|
||||||
* @property {string[]} pmInstallArgs
|
* @property {string[]} pmInstallArgs
|
||||||
@@ -501,7 +480,7 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
this.trace = args.trace;
|
this.trace = args.trace;
|
||||||
onMessagePrint(this.LOG.bind(this));
|
onMessagePrint(this.LOG.bind(this));
|
||||||
}
|
}
|
||||||
D(JSON.stringify({type: 'launch', args, env:process.env}, null, ' '));
|
D(`Launch: ${JSON.stringify(args)}`);
|
||||||
|
|
||||||
if (args.targetDevice === 'null') {
|
if (args.targetDevice === 'null') {
|
||||||
// "null" is returned from the device picker if there's an error or if the
|
// "null" is returned from the device picker if there's an error or if the
|
||||||
@@ -529,16 +508,9 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the custom ADB host and port
|
// set the custom ADB port - this should be changed to pass it to each ADBClient instance
|
||||||
if (typeof args.adbSocket === 'string' && args.adbSocket) {
|
if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
|
||||||
ADBSocket.HostPort = args.adbSocket;
|
ADBSocket.ADBPort = args.adbPort;
|
||||||
} else if (typeof args.adbPort === 'number' && args.adbPort >= 0 && args.adbPort <= 65535) {
|
|
||||||
ADBSocket.HostPort = `:${args.adbPort}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the fixed JDWP port number (if any)
|
|
||||||
if (typeof args.jdwpPort === 'number' && args.jdwpPort >= 0 && args.jdwpPort <= 65535) {
|
|
||||||
Debugger.portManager.fixedport = args.jdwpPort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -623,20 +595,16 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
|
|
||||||
this.LOG('Application started');
|
this.LOG('Application started');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
const msg = e.message || e.msg;
|
|
||||||
// exceptions use message, adbclient uses msg
|
// exceptions use message, adbclient uses msg
|
||||||
this.LOG('Launch failed: '+(msg || 'No additional information is available'));
|
this.LOG('Launch failed: '+(e.message||e.msg||'No additional information is available'));
|
||||||
// more info for adb connect errors
|
// more info for adb connect errors
|
||||||
if (/^ADB server is not running/.test(e.msg)) {
|
if (/^ADB server is not running/.test(e.msg)) {
|
||||||
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
|
this.LOG('Make sure the Android SDK Platform Tools are installed and run:');
|
||||||
this.LOG(' adb start-server');
|
this.LOG(' adb start-server');
|
||||||
this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.');
|
this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.');
|
||||||
}
|
}
|
||||||
if (/ADB|JDWP/.test(msg)) {
|
|
||||||
this.LOG('Ensure any instances of Android Studio are closed.');
|
|
||||||
}
|
|
||||||
// tell the client we're done
|
// tell the client we're done
|
||||||
this.terminate_reason = `start-exception: ${msg}`;
|
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
|
||||||
this.sendEvent(new TerminatedEvent(false));
|
this.sendEvent(new TerminatedEvent(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,7 +787,6 @@ class AndroidDebugSession extends DebugSession {
|
|||||||
analytics.event('debug-end', {
|
analytics.event('debug-end', {
|
||||||
dbg_session_id: this.session_id,
|
dbg_session_id: this.session_id,
|
||||||
dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3),
|
dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3),
|
||||||
dbg_kind: this.debug_mode,
|
|
||||||
dbg_term_reason: this.terminate_reason,
|
dbg_term_reason: this.terminate_reason,
|
||||||
});
|
});
|
||||||
if (this.debuggerAttached) {
|
if (this.debuggerAttached) {
|
||||||
|
|||||||
@@ -52,14 +52,9 @@ class Debugger extends EventEmitter {
|
|||||||
|
|
||||||
static portManager = {
|
static portManager = {
|
||||||
portrange: { lowest: 31000, highest: 31099 },
|
portrange: { lowest: 31000, highest: 31099 },
|
||||||
fixedport: 0,
|
|
||||||
inuseports: new Set(),
|
inuseports: new Set(),
|
||||||
debuggers: {},
|
debuggers: {},
|
||||||
reserveport: function () {
|
reserveport: function () {
|
||||||
if (this.fixedport > 0 && this.fixedport < 65536) {
|
|
||||||
this.inuseports.add(this.fixedport);
|
|
||||||
return this.fixedport;
|
|
||||||
}
|
|
||||||
// choose a random port to use each time
|
// choose a random port to use each time
|
||||||
for (let i = 0; i < 10000; i++) {
|
for (let i = 0; i < 10000; i++) {
|
||||||
const portidx = this.portrange.lowest + ((Math.random() * 100) | 0);
|
const portidx = this.portrange.lowest + ((Math.random() * 100) | 0);
|
||||||
|
|||||||
@@ -7,17 +7,10 @@ const AndroidSocket = require('./androidsocket');
|
|||||||
class ADBSocket extends AndroidSocket {
|
class ADBSocket extends AndroidSocket {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The host and port number to run ADB commands on, in 'host:port' format (host part is optional).
|
* The port number to run ADB on.
|
||||||
* The value can be overriden by the adbSocket (or the deprecated adbPort) value in each debug configuration.
|
* The value can be overriden by the adbPort value in each configuration.
|
||||||
*
|
|
||||||
* The default host value is left blank as this is the simplest way to
|
|
||||||
* specify "connect to the local machine" without explicitly specifying
|
|
||||||
* 'localhost' or '127.0.0.1' (which may be mapped to something else)
|
|
||||||
*/
|
*/
|
||||||
static HostPort = `:5037`;
|
static ADBPort = 5037;
|
||||||
static get DefaultHostPort() {
|
|
||||||
return `:5037`
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super('ADBSocket');
|
super('ADBSocket');
|
||||||
@@ -25,14 +18,13 @@ class ADBSocket extends AndroidSocket {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads and checks the reply from an ADB command
|
* Reads and checks the reply from an ADB command
|
||||||
* @param {string} command
|
|
||||||
* @param {boolean} [throw_on_fail] true if the function should throw on non-OKAY status
|
* @param {boolean} [throw_on_fail] true if the function should throw on non-OKAY status
|
||||||
*/
|
*/
|
||||||
async read_adb_status(command, throw_on_fail = true) {
|
async read_adb_status(throw_on_fail = true) {
|
||||||
// read back the status
|
// read back the status
|
||||||
const status = await this.read_bytes(4, 'latin1')
|
const status = await this.read_bytes(4, 'latin1')
|
||||||
if (status !== 'OKAY' && throw_on_fail) {
|
if (status !== 'OKAY' && throw_on_fail) {
|
||||||
throw new Error(`ADB command '${command}' failed. Status: '${status}'`);
|
throw new Error(`ADB command failed. Status: '${status}'`);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@@ -65,7 +57,7 @@ class ADBSocket extends AndroidSocket {
|
|||||||
*/
|
*/
|
||||||
async cmd_and_status(command) {
|
async cmd_and_status(command) {
|
||||||
await this.write_adb_command(command);
|
await this.write_adb_command(command);
|
||||||
return this.read_adb_status(command);
|
return this.read_adb_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,7 +104,7 @@ class ADBSocket extends AndroidSocket {
|
|||||||
await this.write_bytes(done_and_mtime);
|
await this.write_bytes(done_and_mtime);
|
||||||
|
|
||||||
// read the final status and any error message
|
// read the final status and any error message
|
||||||
const result = await this.read_adb_status('sync:', false);
|
const result = await this.read_adb_status(false);
|
||||||
const failmsg = await this.read_le_length_data('latin1');
|
const failmsg = await this.read_le_length_data('latin1');
|
||||||
|
|
||||||
// finish the transfer mode
|
// finish the transfer mode
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const { ADBClient, getADBSocketParams } = require('../adbclient');
|
const { ADBClient } = require('../adbclient');
|
||||||
|
const ADBSocket = require('../sockets/adbsocket');
|
||||||
const { LOG } = require('../utils/print');
|
const { LOG } = require('../utils/print');
|
||||||
|
|
||||||
function getAndroidSDKFolder() {
|
function getAndroidSDKFolder() {
|
||||||
@@ -40,21 +41,19 @@ function getADBPathName() {
|
|||||||
return path.join(android_sdk, 'platform-tools', /^win/.test(process.platform)?'adb.exe':'adb');
|
return path.join(android_sdk, 'platform-tools', /^win/.test(process.platform)?'adb.exe':'adb');
|
||||||
}
|
}
|
||||||
|
|
||||||
function startADBServer() {
|
/**
|
||||||
|
* @param {number} port
|
||||||
|
*/
|
||||||
|
function startADBServer(port) {
|
||||||
|
if (typeof port !== 'number' || port <= 0 || port >= 65536) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const adb_exe_path = getADBPathName();
|
const adb_exe_path = getADBPathName();
|
||||||
if (!adb_exe_path) {
|
if (!adb_exe_path) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const adb_socket = getADBSocketParams();
|
const adb_start_server_args = ['-P',`${port}`,'start-server'];
|
||||||
// don't try and start ADB if the server is on a remote host
|
|
||||||
if (!/^(localhost|127\.\d+\.\d+\.\d+)?$/.test(adb_socket.host)) {
|
|
||||||
LOG(`Cannot launch adb server on remote host ${adb_socket.host}:${adb_socket.port}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const adb_start_server_args = ['-P',`${adb_socket.port}`,'start-server'];
|
|
||||||
if (adb_socket.host) {
|
|
||||||
adb_start_server_args.unshift(`-H`, adb_socket.host);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
LOG([adb_exe_path, ...adb_start_server_args].join(' '));
|
LOG([adb_exe_path, ...adb_start_server_args].join(' '));
|
||||||
const stdout = require('child_process').execFileSync(adb_exe_path, adb_start_server_args, {
|
const stdout = require('child_process').execFileSync(adb_exe_path, adb_start_server_args, {
|
||||||
@@ -74,7 +73,7 @@ async function checkADBStarted(auto_start) {
|
|||||||
const err = await new ADBClient().test_adb_connection();
|
const err = await new ADBClient().test_adb_connection();
|
||||||
// if adb is not running, see if we can start it ourselves using ANDROID_HOME (and a sensible port number)
|
// if adb is not running, see if we can start it ourselves using ANDROID_HOME (and a sensible port number)
|
||||||
if (err && auto_start) {
|
if (err && auto_start) {
|
||||||
return startADBServer();
|
return startADBServer(ADBSocket.ADBPort);
|
||||||
}
|
}
|
||||||
return !err;
|
return !err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user