@@ -134,12 +134,8 @@ class AndroidDebugService implements IDebugService {
134
134
this . attachDebugger ( device . deviceInfo . identifier , packageName ) . wait ( ) ;
135
135
} else if ( this . $options . stop ) {
136
136
this . detachDebugger ( packageName ) . wait ( ) ;
137
- } else if ( this . $options . debugBrk ) {
138
- this . startAppWithDebugger ( packageFile , packageName ) . wait ( ) ;
139
137
} else {
140
138
this . startAppWithDebugger ( packageFile , packageName ) . wait ( ) ;
141
- //TODO: Find different way to make sure that the app is started.
142
- sleep ( 500 ) ;
143
139
this . attachDebugger ( device . deviceInfo . identifier , packageName ) . wait ( ) ;
144
140
}
145
141
} ) . future < void > ( ) ( ) ;
@@ -202,39 +198,38 @@ class AndroidDebugService implements IDebugService {
202
198
// As we need to redirect output of a command on the device, keep using only one argument.
203
199
// We could rewrite this with two calls - touch and rm -f , but -f flag is not available on old Android, so rm call will fail when file does not exist.
204
200
201
+ this . device . applicationManager . stopApplication ( packageName ) . wait ( ) ;
202
+
205
203
if ( this . $options . debugBrk ) {
206
204
this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
207
205
}
206
+ this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugger-started` ] ) . wait ( ) ;
208
207
209
- this . device . applicationManager . stopApplication ( packageName ) . wait ( ) ;
210
208
this . device . applicationManager . startApplication ( packageName ) . wait ( ) ;
211
209
212
- if ( this . $options . debugBrk ) {
213
- let waitText : string = `0 /data/local/tmp/${ packageName } -debugbreak` ;
214
- let maxWait = 12 ;
215
- let debugerStarted : boolean = false ;
216
- while ( maxWait > 0 && ! debugerStarted ) {
217
- let forwardsResult = this . device . adb . executeShellCommand ( [ "ls" , "-s" , `/data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
218
- maxWait -- ;
219
- debugerStarted = forwardsResult . indexOf ( waitText ) === - 1 ;
220
- if ( ! debugerStarted ) {
221
- sleep ( 500 ) ;
222
- }
223
- }
210
+ this . waitForDebugger ( packageName ) ;
224
211
225
- if ( debugerStarted ) {
226
- this . $logger . info ( "# NativeScript Debugger started #" ) ;
227
- } else {
228
- this . $logger . warn ( "# NativeScript Debugger did not start in time #" ) ;
229
- }
212
+ } ) . future < void > ( ) ( ) ;
213
+ }
230
214
231
- if ( this . $options . client ) {
232
- let localDebugPort = this . getForwardedLocalDebugPortForPackageName ( this . device . deviceInfo . identifier , packageName ) . wait ( ) ;
233
- this . startDebuggerClient ( localDebugPort ) . wait ( ) ;
234
- this . openDebuggerClient ( AndroidDebugService . DEFAULT_NODE_INSPECTOR_URL + "?port=" + localDebugPort ) ;
235
- }
215
+ private waitForDebugger ( packageName : String ) {
216
+ let waitText : string = `0 /data/local/tmp/${ packageName } -debugger-started` ;
217
+ let maxWait = 12 ;
218
+ let debugerStarted : boolean = false ;
219
+ while ( maxWait > 0 && ! debugerStarted ) {
220
+ let forwardsResult = this . device . adb . executeShellCommand ( [ "ls" , "-s" , `/data/local/tmp/${ packageName } -debugger-started` ] ) . wait ( ) ;
221
+ maxWait -- ;
222
+ debugerStarted = forwardsResult . indexOf ( waitText ) === - 1 ;
223
+ if ( ! debugerStarted ) {
224
+ sleep ( 500 ) ;
236
225
}
237
- } ) . future < void > ( ) ( ) ;
226
+ }
227
+
228
+ if ( debugerStarted ) {
229
+ this . $logger . info ( "# NativeScript Debugger started #" ) ;
230
+ } else {
231
+ this . $logger . warn ( "# NativeScript Debugger did not start in time #" ) ;
232
+ }
238
233
}
239
234
240
235
private startDebuggerClient ( port : Number ) : IFuture < void > {
0 commit comments