From 85d1b060c7d5133c5c99ee2b97e58c6ba4bff2a7 Mon Sep 17 00:00:00 2001 From: Lawrence Lomax Date: Thu, 27 Jan 2022 00:31:11 -0800 Subject: [PATCH] Match on device serial as well as title Summary: Device UDID/serial is necessary for matching uniquely. It's certainly possible to connect more than one of the same phone model, or have multiple iOS Sims with the same model and different OS versions. Reviewed By: nikoant Differential Revision: D33793569 fbshipit-source-id: aabd31a5b86c78a85aa867c6fa34d92f411fcb6e --- desktop/flipper-dump/src/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/desktop/flipper-dump/src/index.tsx b/desktop/flipper-dump/src/index.tsx index f0ff60873..2843257cf 100644 --- a/desktop/flipper-dump/src/index.tsx +++ b/desktop/flipper-dump/src/index.tsx @@ -34,7 +34,7 @@ const argv = yargs .usage('$0 [args]') .options({ device: { - describe: 'The device name to listen to', + describe: 'The device name or serial/udid to listen to', type: 'string', }, client: { @@ -54,7 +54,7 @@ const argv = yargs // .strict() .parse(process.argv.slice(1)); -async function start(deviceTitle: string, appName: string, pluginId: string) { +async function start(deviceQuery: string, appName: string, pluginId: string) { return new Promise(async (_resolve, reject) => { const staticPath = path.resolve(__dirname, '..', '..', 'static'); let device: DeviceDescription | undefined; @@ -96,7 +96,7 @@ async function start(deviceTitle: string, appName: string, pluginId: string) { ); logger.info( - `Waiting for device '${deviceTitle}' client '${appName}' plugin '${pluginId}' ...`, + `Waiting for device '${deviceQuery}' client '${appName}' plugin '${pluginId}' ...`, ); server.on('notification', ({type, title, description}) => { @@ -116,8 +116,12 @@ async function start(deviceTitle: string, appName: string, pluginId: string) { logger.info( `Detected device [${deviceInfo.os}] ${deviceInfo.title} ${deviceInfo.serial}`, ); - if (deviceInfo.title === deviceTitle) { - logger.info('Device matched'); + if (deviceInfo.serial == deviceQuery) { + logger.info(`Device matched on device serial ${deviceQuery}`); + device = deviceInfo; + deviceResolver(); + } else if (deviceInfo.title === deviceQuery) { + logger.info(`Device matched on device title ${deviceQuery}`); device = deviceInfo; deviceResolver(); }