@@ -174,7 +174,8 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
174
174
175
175
for ( const deviceDiscovery of this . _allDeviceDiscoveries ) {
176
176
try {
177
- await deviceDiscovery . startLookingForDevices ( { shouldReturnImmediateResult : false , platform : this . _platform } ) ;
177
+ const deviceLookingOptions = this . getDeviceLookingOptions ( ) ;
178
+ await deviceDiscovery . startLookingForDevices ( deviceLookingOptions ) ;
178
179
} catch ( err ) {
179
180
this . $logger . trace ( "Error while checking for new devices." , err ) ;
180
181
}
@@ -220,7 +221,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
220
221
private async startLookingForDevices ( options ?: Mobile . IDeviceLookingOptions ) : Promise < void > {
221
222
this . $logger . trace ( "startLookingForDevices; platform is %s" , this . _platform ) ;
222
223
if ( ! options ) {
223
- options = { shouldReturnImmediateResult : false , platform : this . _platform } ;
224
+ options = this . getDeviceLookingOptions ( ) ;
224
225
}
225
226
if ( ! this . _platform ) {
226
227
await this . detectCurrentlyAttachedDevices ( options ) ;
@@ -259,7 +260,8 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
259
260
* @param identifier parameter passed by the user to --device flag
260
261
*/
261
262
public async getDevice ( deviceOption : string ) : Promise < Mobile . IDevice > {
262
- await this . detectCurrentlyAttachedDevices ( { shouldReturnImmediateResult : false , platform : this . _platform } ) ;
263
+ const deviceLookingOptions = this . getDeviceLookingOptions ( ) ;
264
+ await this . detectCurrentlyAttachedDevices ( deviceLookingOptions ) ;
263
265
let device : Mobile . IDevice = null ;
264
266
265
267
let emulatorIdentifier = null ;
@@ -462,7 +464,8 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
462
464
if ( data . skipDeviceDetectionInterval ) {
463
465
await this . detectCurrentlyAttachedDevices ( ) ;
464
466
} else {
465
- await this . startLookingForDevices ( { shouldReturnImmediateResult : true , platform : this . _platform } ) ;
467
+ const deviceLookingOptions = this . getDeviceLookingOptions ( this . _platform , true ) ;
468
+ await this . startLookingForDevices ( deviceLookingOptions ) ;
466
469
}
467
470
} else {
468
471
await this . detectCurrentlyAttachedDevices ( ) ;
@@ -600,7 +603,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
600
603
public async startEmulator ( platform ?: string , emulatorImage ?: string ) : Promise < void > {
601
604
602
605
platform = platform || this . _platform ;
603
-
606
+ const deviceLookingOptions = this . getDeviceLookingOptions ( platform ) ;
604
607
let emulatorServices = this . resolveEmulatorServices ( platform ) ;
605
608
if ( ! emulatorServices ) {
606
609
this . $errors . failWithoutHelp ( "Unable to detect platform for which to start emulator." ) ;
@@ -609,9 +612,9 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
609
612
await emulatorServices . startEmulator ( emulatorImage ) ;
610
613
611
614
if ( this . $mobileHelper . isAndroidPlatform ( platform ) ) {
612
- await this . $androidDeviceDiscovery . startLookingForDevices ( { shouldReturnImmediateResult : false , platform : platform } ) ;
615
+ await this . $androidDeviceDiscovery . startLookingForDevices ( deviceLookingOptions ) ;
613
616
} else if ( this . $mobileHelper . isiOSPlatform ( platform ) && this . $hostInfo . isDarwin ) {
614
- await this . $iOSSimulatorDiscovery . startLookingForDevices ( { shouldReturnImmediateResult : false , platform : platform } ) ;
617
+ await this . $iOSSimulatorDiscovery . startLookingForDevices ( deviceLookingOptions ) ;
615
618
}
616
619
}
617
620
@@ -663,6 +666,12 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
663
666
isLiveSyncSupported
664
667
} ;
665
668
}
669
+
670
+ private getDeviceLookingOptions ( platform ?: string , shouldReturnImmediateResult ?: boolean ) : Mobile . IDeviceLookingOptions {
671
+ platform = platform || this . _platform ;
672
+ shouldReturnImmediateResult = shouldReturnImmediateResult || false ;
673
+ return { shouldReturnImmediateResult : shouldReturnImmediateResult , platform : platform } ;
674
+ }
666
675
}
667
676
668
677
$injector . register ( "devicesService" , DevicesService ) ;
0 commit comments