Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 1a769e9

Browse files
committed
Add check in iOS device and simulator discovery if platform is Android.
1 parent 0fb7b5f commit 1a769e9

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

definitions/mobile.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ declare module Mobile {
406406
startDeviceDetectionInterval(): Promise<void>;
407407
getDeviceByIdentifier(identifier: string): Mobile.IDevice;
408408
mapAbstractToTcpPort(deviceIdentifier: string, appIdentifier: string, framework: string): Promise<string>;
409-
detectCurrentlyAttachedDevices(): Promise<void>;
409+
detectCurrentlyAttachedDevices(options?: Mobile.IDeviceLookingOptions): Promise<void>;
410410
startEmulator(platform?: string, emulatorImage?: string): Promise<void>;
411411
isCompanionAppInstalledOnDevices(deviceIdentifiers: string[], framework: string): Promise<IAppInstalledInfo>[];
412412
getDebuggableApps(deviceIdentifiers: string[]): Promise<Mobile.IDeviceApplicationInformation[]>[];

mobile/mobile-core/devices-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
255255
* Method expects running devices.
256256
* @param identifier parameter passed by the user to --device flag
257257
*/
258-
private async getDevice(deviceOption: string): Promise<Mobile.IDevice> {
259-
await this.detectCurrentlyAttachedDevices();
258+
private async getDevice(deviceOption: string, platform?: string): Promise<Mobile.IDevice> {
259+
await this.detectCurrentlyAttachedDevices({ shouldReturnImmediateResult: false, platform: this._platform });
260260
let device: Mobile.IDevice = null;
261261

262262
let emulatorIdentifier = null;
@@ -442,7 +442,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi
442442

443443
if (platform && deviceOption) {
444444
this._platform = this.getPlatform(data.platform);
445-
this._device = await this.getDevice(deviceOption);
445+
this._device = await this.getDevice(deviceOption, this._platform);
446446
if (this._device.deviceInfo.platform !== this._platform) {
447447
this.$errors.fail(constants.ERROR_CANNOT_RESOLVE_DEVICE);
448448
}

mobile/mobile-core/ios-device-discovery.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export class IOSDeviceDiscovery extends DeviceDiscovery {
77
constructor(private $injector: IInjector,
88
private $logger: ILogger,
99
private $iTunesValidator: Mobile.IiTunesValidator,
10+
private $mobileHelper: Mobile.IMobileHelper,
1011
private $iosDeviceOperations: IIOSDeviceOperations) {
1112
super();
1213
}
@@ -24,6 +25,9 @@ export class IOSDeviceDiscovery extends DeviceDiscovery {
2425
}
2526

2627
public async startLookingForDevices(options?: Mobile.IDeviceLookingOptions): Promise<void> {
28+
if (options && options.platform && !this.$mobileHelper.isiOSPlatform(options.platform)) {
29+
return;
30+
}
2731
if (this.validateiTunes()) {
2832
await this.$iosDeviceOperations.startLookingForDevices((deviceInfo: IOSDeviceLib.IDeviceActionInfo) => {
2933
this.createAndAddDevice(deviceInfo);

mobile/mobile-core/ios-simulator-discovery.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ export class IOSSimulatorDiscovery extends DeviceDiscovery {
77
constructor(private $injector: IInjector,
88
private $childProcess: IChildProcess,
99
private $iOSSimResolver: Mobile.IiOSSimResolver,
10+
private $mobileHelper: Mobile.IMobileHelper,
1011
private $hostInfo: IHostInfo) {
1112
super();
1213
}
1314

14-
public async startLookingForDevices(): Promise<void> {
15+
public async startLookingForDevices(options?: Mobile.IDeviceLookingOptions): Promise<void> {
16+
if (options && options.platform && !this.$mobileHelper.isiOSPlatform(options.platform)) {
17+
return;
18+
}
19+
1520
return new Promise<void>((resolve, reject) => {
1621
return this.checkForDevices(resolve, reject);
1722
});

0 commit comments

Comments
 (0)