@@ -106,12 +106,7 @@ class AndroidDebugService implements IDebugService {
106
106
return ( ( ) => {
107
107
let packageFile = "" ;
108
108
109
- if ( ! this . $options . debugBrk && ! this . $options . start && ! this . $options . getPort && ! this . $options . stop ) {
110
- this . $logger . warn ( "Neither --debug-brk nor --start option was specified. Defaulting to --debug-brk." ) ;
111
- this . $options . debugBrk = true ;
112
- }
113
-
114
- if ( this . $options . debugBrk && ! this . $options . emulator ) {
109
+ if ( ! this . $options . start && ! this . $options . emulator ) {
115
110
let cachedDeviceOption = this . $options . forDevice ;
116
111
this . $options . forDevice = true ;
117
112
this . $platformService . buildPlatform ( this . platform ) . wait ( ) ;
@@ -141,6 +136,12 @@ class AndroidDebugService implements IDebugService {
141
136
this . detachDebugger ( packageName ) . wait ( ) ;
142
137
} else if ( this . $options . debugBrk ) {
143
138
this . startAppWithDebugger ( packageFile , packageName ) . wait ( ) ;
139
+ } else {
140
+ this . startAppWithDebugger ( packageFile , packageName ) . wait ( ) ;
141
+ //TODO: Find different way to make sure that the app is started.
142
+ sleep ( 500 ) ;
143
+ this . attachDebugger ( device . deviceInfo . identifier , packageName ) . wait ( ) ;
144
+
144
145
}
145
146
} ) . future < void > ( ) ( ) ;
146
147
}
@@ -197,33 +198,38 @@ class AndroidDebugService implements IDebugService {
197
198
// Arguments passed to executeShellCommand must be in array ([]), but it turned out adb shell "arg with intervals" still works correctly.
198
199
// As we need to redirect output of a command on the device, keep using only one argument.
199
200
// 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.
200
- this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
201
+
202
+ if ( this . $options . debugBrk ) {
203
+ this . device . adb . executeShellCommand ( [ `cat /dev/null > /data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
204
+ }
201
205
202
206
this . device . applicationManager . stopApplication ( packageName ) . wait ( ) ;
203
207
this . device . applicationManager . startApplication ( packageName ) . wait ( ) ;
204
-
205
- let waitText : string = `0 /data/local/tmp/${ packageName } -debugbreak` ;
206
- let maxWait = 12 ;
207
- let debugerStarted : boolean = false ;
208
- while ( maxWait > 0 && ! debugerStarted ) {
209
- let forwardsResult = this . device . adb . executeShellCommand ( [ "ls" , "-s" , `/data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
210
- maxWait -- ;
211
- debugerStarted = forwardsResult . indexOf ( waitText ) === - 1 ;
212
- if ( ! debugerStarted ) {
213
- sleep ( 500 ) ;
208
+
209
+ if ( this . $options . debugBrk ) {
210
+ let waitText : string = `0 /data/local/tmp/${ packageName } -debugbreak` ;
211
+ let maxWait = 12 ;
212
+ let debugerStarted : boolean = false ;
213
+ while ( maxWait > 0 && ! debugerStarted ) {
214
+ let forwardsResult = this . device . adb . executeShellCommand ( [ "ls" , "-s" , `/data/local/tmp/${ packageName } -debugbreak` ] ) . wait ( ) ;
215
+ maxWait -- ;
216
+ debugerStarted = forwardsResult . indexOf ( waitText ) === - 1 ;
217
+ if ( ! debugerStarted ) {
218
+ sleep ( 500 ) ;
219
+ }
214
220
}
215
- }
216
221
217
- if ( debugerStarted ) {
218
- this . $logger . info ( "# NativeScript Debugger started #" ) ;
219
- } else {
220
- this . $logger . warn ( "# NativeScript Debugger did not start in time #" ) ;
221
- }
222
+ if ( debugerStarted ) {
223
+ this . $logger . info ( "# NativeScript Debugger started #" ) ;
224
+ } else {
225
+ this . $logger . warn ( "# NativeScript Debugger did not start in time #" ) ;
226
+ }
222
227
223
- if ( this . $options . client ) {
224
- let localDebugPort = this . getForwardedLocalDebugPortForPackageName ( this . device . deviceInfo . identifier , packageName ) . wait ( ) ;
225
- this . startDebuggerClient ( localDebugPort ) . wait ( ) ;
226
- this . openDebuggerClient ( AndroidDebugService . DEFAULT_NODE_INSPECTOR_URL + "?port=" + localDebugPort ) ;
228
+ if ( this . $options . client ) {
229
+ let localDebugPort = this . getForwardedLocalDebugPortForPackageName ( this . device . deviceInfo . identifier , packageName ) . wait ( ) ;
230
+ this . startDebuggerClient ( localDebugPort ) . wait ( ) ;
231
+ this . openDebuggerClient ( AndroidDebugService . DEFAULT_NODE_INSPECTOR_URL + "?port=" + localDebugPort ) ;
232
+ }
227
233
}
228
234
} ) . future < void > ( ) ( ) ;
229
235
}
0 commit comments