Extract idb device querying to IOSBridge

Summary:
Again this is just a code move for now.

However, we now have a common method between simctl and idb cases. This means that the next diff can call an `IOSBridge` with polymorpism taking over. This is still delegated out, but there's an argument to be made to move `iosUtil` functionality back so that this all lives in the same place.

Reviewed By: passy

Differential Revision: D33843093

fbshipit-source-id: 5cd884140817df851cccf63e5780582b16d4231c
This commit is contained in:
Lawrence Lomax
2022-01-31 07:23:29 -08:00
committed by Facebook GitHub Bot
parent aeb0b5f317
commit ccae37aa71
3 changed files with 61 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ import IOSDevice from './IOSDevice';
import {
ERR_NO_IDB_OR_XCODE_AVAILABLE,
IOSBridge,
IDBBridge,
makeIOSBridge,
SimctlBridge,
} from './IOSBridge';
@@ -174,7 +175,11 @@ export class IOSDeviceManager {
}
try {
// Awaiting the promise here to trigger immediate error handling.
this.iosBridge = await makeIOSBridge(settings.idbPath, isDetected);
this.iosBridge = await makeIOSBridge(
settings.idbPath,
isDetected,
settings.enablePhysicalIOS,
);
this.queryDevicesForever();
} catch (err) {
// This case is expected if both Xcode and idb are missing.
@@ -252,10 +257,7 @@ function getActiveDevices(
idbPath: string,
isPhysicalDeviceEnabled: boolean,
): Promise<Array<IOSDeviceParams>> {
return iosUtil.targets(idbPath, isPhysicalDeviceEnabled).catch((e) => {
console.error('Failed to get active iOS devices:', e.message);
return [];
});
return new IDBBridge(idbPath, isPhysicalDeviceEnabled).getActiveDevices(true);
}
export function parseXcodeFromCoreSimPath(