Fix bug in iOSDevice detection if both physical and emulator are active
Summary: When connecting both to an iOS emulator and physical device, the emulator devices would continuesly be replaced, and Flipper would print the warning `Tried to replace still connected device XXX with a new instance` Fixed the logical mistake that causes it. Not sure if this caused any actual bugs, but at least it was incorrect. Reviewed By: lblasa Differential Revision: D31015451 fbshipit-source-id: 32dd29043e9dc48357fdbf68cde930d3be11419a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5739e0c943
commit
3ee8aef154
@@ -143,7 +143,7 @@ export class IOSDeviceManager {
|
||||
|
||||
private processDevices(
|
||||
activeDevices: IOSDeviceParams[],
|
||||
type: 'physical' | 'emulator',
|
||||
targetType: 'physical' | 'emulator',
|
||||
) {
|
||||
if (!this.iosBridge) {
|
||||
throw new Error('iOS bridge not yet initialized');
|
||||
@@ -152,10 +152,7 @@ export class IOSDeviceManager {
|
||||
this.flipperServer
|
||||
.getDevices()
|
||||
.filter(
|
||||
(device) =>
|
||||
device instanceof IOSDevice &&
|
||||
device.deviceType === type &&
|
||||
device.connected.get(),
|
||||
(device) => device.os === 'iOS' && device.deviceType === targetType,
|
||||
)
|
||||
.map((device) => device.serial),
|
||||
);
|
||||
@@ -163,13 +160,17 @@ export class IOSDeviceManager {
|
||||
for (const {udid, type, name} of activeDevices) {
|
||||
if (currentDeviceIDs.has(udid)) {
|
||||
currentDeviceIDs.delete(udid);
|
||||
} else {
|
||||
} else if (targetType === type) {
|
||||
console.log(`[conn] detected new iOS device ${targetType} ${udid}`);
|
||||
const iOSDevice = new IOSDevice(this.iosBridge, udid, type, name);
|
||||
this.flipperServer.registerDevice(iOSDevice);
|
||||
}
|
||||
}
|
||||
|
||||
currentDeviceIDs.forEach((id) => {
|
||||
console.log(
|
||||
`[conn] Could no longer find ${targetType} ${id}, removing...`,
|
||||
);
|
||||
this.flipperServer.unregisterDevice(id);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user