@@ -64,7 +64,8 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
64
64
private $opener : IOpener ,
65
65
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
66
66
private $options : IOptions ,
67
- private $logcatHelper : Mobile . ILogcatHelper ) {
67
+ private $logcatHelper : Mobile . ILogcatHelper ,
68
+ private $hostInfo : IHostInfo ) {
68
69
let details : IAndroidDeviceDetails = this . getDeviceDetails ( ) . wait ( ) ;
69
70
70
71
this . model = details . model ;
@@ -209,7 +210,12 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
209
210
}
210
211
211
212
private openDebuggerClient ( url : string ) : void {
212
- this . $opener . open ( url , "chrome" ) ;
213
+ let chrome = this . $hostInfo . isDarwin ? "Google\ Chrome" : "chrome" ;
214
+ let child = this . $opener . open ( url , chrome ) ;
215
+ if ( ! child ) {
216
+ this . $errors . fail ( `Unable to open ${ chrome } .` ) ;
217
+ }
218
+ return child ;
213
219
}
214
220
215
221
private printDebugPort ( packageName : string ) : void {
@@ -257,17 +263,20 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
257
263
let port = this . $options . debugPort ;
258
264
259
265
let packageDir = util . format ( AndroidDevice . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
260
- let envDebugOutFullpath = packageDir + AndroidDevice . ENV_DEBUG_OUT_FILENAME ;
266
+ let envDebugOutFullpath = this . buildDevicePath ( packageDir , AndroidDevice . ENV_DEBUG_OUT_FILENAME ) ;
261
267
let clearDebugEnvironmentCommand = this . composeCommand ( 'shell rm "%s"' , envDebugOutFullpath ) ;
262
268
this . $childProcess . exec ( clearDebugEnvironmentCommand ) . wait ( ) ;
263
269
264
- let setDebugBreakEnvironmentCommand = this . composeCommand ( 'shell echo "" > "%s"' , "debugbreak" ) ;
265
- this . $childProcess . exec ( setDebugBreakEnvironmentCommand ) . wait ( ) ;
270
+ let createPackageDir = this . composeCommand ( 'shell mkdir -p "%s"' , packageDir ) ;
271
+ this . $childProcess . exec ( createPackageDir ) . wait ( ) ;
272
+
273
+ let debugBreakPath = this . buildDevicePath ( packageDir , "debugbreak" ) ;
274
+ let setDebugBreakEnvironmentCommand = this . composeCommand ( 'shell "cat /dev/null > %s"' , debugBreakPath ) ;
275
+ this . $childProcess . exec ( setDebugBreakEnvironmentCommand ) . wait ( ) ;
266
276
267
277
this . startPackageOnDevice ( packageName ) . wait ( ) ;
268
278
269
279
let dbgPort = this . startAndGetPort ( packageName ) . wait ( ) ;
270
-
271
280
if ( dbgPort > 0 ) {
272
281
this . tcpForward ( dbgPort , dbgPort ) ;
273
282
this . startDebuggerClient ( dbgPort ) . wait ( ) ;
@@ -310,25 +319,26 @@ export class AndroidDevice implements Mobile.IAndroidDevice {
310
319
private startAndGetPort ( packageName : string ) : IFuture < number > {
311
320
return ( ( ) => {
312
321
let port = - 1 ;
322
+ let timeout = 60 ;
313
323
314
324
let packageDir = util . format ( AndroidDevice . PACKAGE_EXTERNAL_DIR_TEMPLATE , packageName ) ;
315
325
let envDebugInFullpath = packageDir + AndroidDevice . ENV_DEBUG_IN_FILENAME ;
316
326
let clearDebugEnvironmentCommand = this . composeCommand ( 'shell rm "%s"' , envDebugInFullpath ) ;
317
327
this . $childProcess . exec ( clearDebugEnvironmentCommand ) . wait ( ) ;
318
328
319
329
let isRunning = false ;
320
- for ( let i = 0 ; i < 60 ; i ++ ) {
330
+ for ( let i = 0 ; i < timeout ; i ++ ) {
321
331
helpers . sleep ( 1000 /* ms */ ) ;
322
332
isRunning = this . checkIfRunning ( packageName ) ;
323
333
if ( isRunning )
324
334
break ;
325
335
}
326
-
336
+
327
337
if ( isRunning ) {
328
338
let setEnvironmentCommand = this . composeCommand ( 'shell "cat /dev/null > %s"' , envDebugInFullpath ) ;
329
339
this . $childProcess . exec ( setEnvironmentCommand ) . wait ( ) ;
330
340
331
- for ( let i = 0 ; i < 10 ; i ++ ) {
341
+ for ( let i = 0 ; i < timeout ; i ++ ) {
332
342
helpers . sleep ( 1000 /* ms */ ) ;
333
343
let envDebugOutFullpath = packageDir + AndroidDevice . ENV_DEBUG_OUT_FILENAME ;
334
344
let exists = this . checkIfFileExists ( envDebugOutFullpath ) . wait ( ) ;
0 commit comments