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(
|
private processDevices(
|
||||||
activeDevices: IOSDeviceParams[],
|
activeDevices: IOSDeviceParams[],
|
||||||
type: 'physical' | 'emulator',
|
targetType: 'physical' | 'emulator',
|
||||||
) {
|
) {
|
||||||
if (!this.iosBridge) {
|
if (!this.iosBridge) {
|
||||||
throw new Error('iOS bridge not yet initialized');
|
throw new Error('iOS bridge not yet initialized');
|
||||||
@@ -152,10 +152,7 @@ export class IOSDeviceManager {
|
|||||||
this.flipperServer
|
this.flipperServer
|
||||||
.getDevices()
|
.getDevices()
|
||||||
.filter(
|
.filter(
|
||||||
(device) =>
|
(device) => device.os === 'iOS' && device.deviceType === targetType,
|
||||||
device instanceof IOSDevice &&
|
|
||||||
device.deviceType === type &&
|
|
||||||
device.connected.get(),
|
|
||||||
)
|
)
|
||||||
.map((device) => device.serial),
|
.map((device) => device.serial),
|
||||||
);
|
);
|
||||||
@@ -163,13 +160,17 @@ export class IOSDeviceManager {
|
|||||||
for (const {udid, type, name} of activeDevices) {
|
for (const {udid, type, name} of activeDevices) {
|
||||||
if (currentDeviceIDs.has(udid)) {
|
if (currentDeviceIDs.has(udid)) {
|
||||||
currentDeviceIDs.delete(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);
|
const iOSDevice = new IOSDevice(this.iosBridge, udid, type, name);
|
||||||
this.flipperServer.registerDevice(iOSDevice);
|
this.flipperServer.registerDevice(iOSDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDeviceIDs.forEach((id) => {
|
currentDeviceIDs.forEach((id) => {
|
||||||
|
console.log(
|
||||||
|
`[conn] Could no longer find ${targetType} ${id}, removing...`,
|
||||||
|
);
|
||||||
this.flipperServer.unregisterDevice(id);
|
this.flipperServer.unregisterDevice(id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user