1
- import * as path from "path" ;
2
1
import * as net from "net" ;
3
2
import Future = require( "fibers/future" ) ;
4
3
import { sleep } from "../common/helpers" ;
5
4
import { ChildProcess } from "child_process" ;
6
5
7
6
class AndroidDebugService implements IDebugService {
8
- private static DEFAULT_NODE_INSPECTOR_URL = "http://127.0.0.1:8080/debug" ;
9
-
10
7
private _device : Mobile . IAndroidDevice = null ;
11
8
private _debuggerClientProcess : ChildProcess ;
12
9
@@ -78,8 +75,10 @@ class AndroidDebugService implements IDebugService {
78
75
let port = - 1 ;
79
76
let forwardsResult = this . device . adb . executeCommand ( [ "forward" , "--list" ] ) . wait ( ) ;
80
77
78
+ let unixSocketName = `${ packageName } -inspectorServer` ;
79
+
81
80
//matches 123a188909e6czzc tcp:40001 localabstract:org.nativescript.testUnixSockets-debug
82
- let regexp = new RegExp ( `(?:${ deviceId } tcp:)([\\d]+)(?= localabstract:${ packageName } -debug )` , "g" ) ;
81
+ let regexp = new RegExp ( `(?:${ deviceId } tcp:)([\\d]+)(?= localabstract:${ unixSocketName } )` , "g" ) ;
83
82
let match = regexp . exec ( forwardsResult ) ;
84
83
if ( match ) {
85
84
port = parseInt ( match [ 1 ] ) ;
@@ -92,7 +91,7 @@ class AndroidDebugService implements IDebugService {
92
91
}
93
92
port = candidatePort ;
94
93
95
- this . unixSocketForward ( port , packageName + "-debug" ) . wait ( ) ;
94
+ this . unixSocketForward ( port , ` ${ unixSocketName } ` ) . wait ( ) ;
96
95
}
97
96
98
97
return port ;
@@ -159,7 +158,6 @@ class AndroidDebugService implements IDebugService {
159
158
if ( this . $options . client ) {
160
159
let port = this . getForwardedLocalDebugPortForPackageName ( deviceId , packageName ) . wait ( ) ;
161
160
this . startDebuggerClient ( port ) . wait ( ) ;
162
- this . openDebuggerClient ( AndroidDebugService . DEFAULT_NODE_INSPECTOR_URL + "?port=" + port ) ;
163
161
}
164
162
} ) . future < void > ( ) ( ) ;
165
163
}
@@ -238,11 +236,12 @@ class AndroidDebugService implements IDebugService {
238
236
239
237
private startDebuggerClient ( port : Number ) : IFuture < void > {
240
238
return ( ( ) => {
241
- let nodeInspectorModuleFilePath = require . resolve ( "node-inspector" ) ;
242
- let nodeInspectorModuleDir = path . dirname ( nodeInspectorModuleFilePath ) ;
243
- let nodeInspectorFullPath = path . join ( nodeInspectorModuleDir , "bin" , "inspector" ) ;
244
- this . _debuggerClientProcess = this . $childProcess . spawn ( process . argv [ 0 ] , [ nodeInspectorFullPath , "--debug-port" , port . toString ( ) ] , { stdio : "ignore" , detached : true } ) ;
245
- this . $processService . attachToProcessExitSignals ( this , this . debugStop ) ;
239
+ //let nodeInspectorModuleFilePath = require.resolve("node-inspector");
240
+ //let nodeInspectorModuleDir = path.dirname(nodeInspectorModuleFilePath);
241
+ //let nodeInspectorFullPath = path.join(nodeInspectorModuleDir, "bin", "inspector");
242
+ //this._debuggerClientProcess = this.$childProcess.spawn(process.argv[0], [nodeInspectorFullPath, "--debug-port", port.toString()], { stdio: "ignore", detached: true });
243
+ //this.$processService.attachToProcessExitSignals(this, this.debugStop);
244
+ this . $logger . info ( `To start debugging, open the following URL in Chrome:\nchrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:${ port } \n` ) ;
246
245
} ) . future < void > ( ) ( ) ;
247
246
}
248
247
@@ -253,20 +252,5 @@ class AndroidDebugService implements IDebugService {
253
252
}
254
253
}
255
254
256
- private openDebuggerClient ( url : string ) : void {
257
- let defaultDebugUI = "chrome" ;
258
- if ( this . $hostInfo . isDarwin ) {
259
- defaultDebugUI = "Google Chrome" ;
260
- }
261
- if ( this . $hostInfo . isLinux ) {
262
- defaultDebugUI = "google-chrome" ;
263
- }
264
-
265
- let debugUI = this . $config . ANDROID_DEBUG_UI || defaultDebugUI ;
266
- let child = this . $opener . open ( url , debugUI ) ;
267
- if ( ! child ) {
268
- this . $errors . failWithoutHelp ( `Unable to open ${ debugUI } .` ) ;
269
- }
270
- }
271
255
}
272
256
$injector . register ( "androidDebugService" , AndroidDebugService ) ;
0 commit comments