-
-
Notifications
You must be signed in to change notification settings - Fork 197
Implement Android debugging with unix sockets redirection #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b0971a1
to
a289bee
Compare
let forwardsResult = this.device.adb.executeCommand(["forward", "--list"]).wait(); | ||
|
||
//matches 123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug | ||
let regexp = new RegExp(`(${deviceId} tcp:)([\\d])+(?= localabstract:${packageName}-debug)`, "g"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this RegExp could be rewritten as follows:
new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${packageName}-debug)`, "g");
The benefits would be that you could execute regexp.exec(forwardsResult)
on the line below instead of forwardsResult.match(regexp)
. That way the result port would simply be match[1]
instead of parseInt(match[0].substring(match[0].length - 5));
Example:
let deviceId = "123a188909e6czzc";
let packageName = "org.nativescript.testUnixSockets";
let forwardsResult = "123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug";
let regexp = new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${packageName}-debug)`, "g");
let match = regexp.exec(forwardsResult);
console.log(match);
// output
/* [ '123a188909e6czzc tcp:40001',
'40001',
index: 0,
input: '123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug' ]
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good one.
the best way should have been with a negative lookbehind... Not sure if exec is the optimal way thus I have done this with substring, which is ugly.
I leave it to you guys to decide.
Overall great work! |
a289bee
to
e743e9c
Compare
let regexp = new RegExp(`(?:${deviceId} tcp:)([\\d]+)(?= localabstract:${packageName}-debug)`, "g"); | ||
let match = regexp.exec(forwardsResult); | ||
if (match) { | ||
port = parseInt(match[0].substring(match[0].length - 5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
port=match[1];
Because the regex is now exec
-ed instead of match
-ed
e743e9c
to
182660a
Compare
…xsockets Implement Android debugging with unix sockets redirection
This is cleaned-up version of #1227
To test it, you need this runtime.
This pull request is releated to the changes here.
The android debugger now uses named sockets instead of ports hence the code rewrite in adndroid-debug-service to accommodate for that.
Contact @blagoev directly in order to merge this successfully into the respected main branches.