From e2c826ddd23c669d9014a32d32d806467a234b9d Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Mon, 13 May 2024 07:00:26 -0700 Subject: [PATCH] Upgrade dummy devices Summary: Dummy devices are not "real devices" but rather devices that are created in the absence of them. Sometimes, when trying to find a real device which a specific serial, it will fail, and a dummy device with said serial will be created instead. Later on, it is possible for the real device to become available. In this case, it should be possible to promote the dummy device to an actual device. Reviewed By: passy Differential Revision: D57163208 fbshipit-source-id: 0d42d586ba767f5bee37af9a9d4c52b7518d4adc --- desktop/flipper-server/src/FlipperServerImpl.tsx | 5 ++++- desktop/flipper-ui/src/dispatcher/flipperServer.tsx | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-server/src/FlipperServerImpl.tsx b/desktop/flipper-server/src/FlipperServerImpl.tsx index 45d25b7a185..98f7374d3cc 100644 --- a/desktop/flipper-server/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server/src/FlipperServerImpl.tsx @@ -685,7 +685,10 @@ export class FlipperServerImpl implements FlipperServer { const existing = this.devices.get(serial); if (existing) { // assert different kind of devices aren't accidentally reusing the same serial - if (Object.getPrototypeOf(existing) !== Object.getPrototypeOf(device)) { + if ( + existing.info.deviceType !== 'dummy' && + Object.getPrototypeOf(existing) !== Object.getPrototypeOf(device) + ) { throw new Error( `Tried to register a new device type for existing serial '${serial}': Trying to replace existing '${ Object.getPrototypeOf(existing).constructor.name diff --git a/desktop/flipper-ui/src/dispatcher/flipperServer.tsx b/desktop/flipper-ui/src/dispatcher/flipperServer.tsx index 5d4950067d9..8118cd6d23a 100644 --- a/desktop/flipper-ui/src/dispatcher/flipperServer.tsx +++ b/desktop/flipper-ui/src/dispatcher/flipperServer.tsx @@ -361,8 +361,11 @@ export function handleDeviceConnected( `Tried to replace still connected device '${existing.serial}' with a new instance.`, ); } - if (store.getState().settingsState.persistDeviceData) { - //Recycle device + if ( + existing.deviceType !== 'dummy' && + store.getState().settingsState.persistDeviceData + ) { + // Recycle device existing?.connected.set(true); store.dispatch({ type: 'SELECT_DEVICE',