diff --git a/desktop/app/src/devices/AndroidDevice.tsx b/desktop/app/src/devices/AndroidDevice.tsx index 64485e56c..3f3823d17 100644 --- a/desktop/app/src/devices/AndroidDevice.tsx +++ b/desktop/app/src/devices/AndroidDevice.tsx @@ -14,7 +14,7 @@ import {createWriteStream} from 'fs'; import type {LogLevel, DeviceType} from 'flipper-plugin'; import which from 'which'; import {spawn} from 'child_process'; -import {dirname} from 'path'; +import {dirname, join} from 'path'; import {DeviceSpec} from 'flipper-plugin-lib'; const DEVICE_RECORDING_DIR = '/sdcard/flipper_recorder'; @@ -262,6 +262,13 @@ export async function launchEmulator(name: string, coldBoot: boolean = false) { // On Linux, you must run the emulator from the directory it's in because // reasons ... return which('emulator') + .catch(() => + join( + process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || '', + 'tools', + 'emulator', + ), + ) .then((emulatorPath) => { if (emulatorPath) { const child = spawn( diff --git a/desktop/app/src/dispatcher/androidDevice.tsx b/desktop/app/src/dispatcher/androidDevice.tsx index 6f4e3a316..bebee643f 100644 --- a/desktop/app/src/dispatcher/androidDevice.tsx +++ b/desktop/app/src/dispatcher/androidDevice.tsx @@ -20,6 +20,7 @@ import {ServerPorts} from '../reducers/application'; import {Client as ADBClient} from 'adbkit'; import {addErrorNotification} from '../reducers/notifications'; import {destroyDevice} from '../reducers/connections'; +import {join} from 'path'; function createDevice( adbClient: ADBClient, @@ -140,15 +141,17 @@ export default (store: Store, logger: Logger) => { const watchAndroidDevices = () => { // get emulators promisify(which)('emulator') - .catch( - () => - `${ - process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || '' - }/tools/emulator`, + .catch(() => + join( + process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || '', + 'tools', + 'emulator', + ), ) .then((emulatorPath) => { - child_process.exec( - `${emulatorPath} -list-avds`, + child_process.execFile( + emulatorPath as string, + ['-list-avds'], (error: Error | null, data: string | null) => { if (error != null || data == null) { console.warn('List AVD failed: ', error); @@ -161,9 +164,12 @@ export default (store: Store, logger: Logger) => { }); }, ); + }) + .catch((err) => { + console.warn('Failed to query AVDs:', err); }); - getAdbClient(store) + return getAdbClient(store) .then((client) => { client .trackDevices() diff --git a/desktop/app/src/utils/adbClient.tsx b/desktop/app/src/utils/adbClient.tsx index 923c7aacc..cf6da2012 100644 --- a/desktop/app/src/utils/adbClient.tsx +++ b/desktop/app/src/utils/adbClient.tsx @@ -8,7 +8,7 @@ */ import {reportPlatformFailures} from './metrics'; -import {exec} from 'promisify-child-process'; +import {execFile} from 'promisify-child-process'; import promiseRetry from 'promise-retry'; import adbConfig from '../utils/adbConfig'; import adbkit, {Client} from 'adbkit'; @@ -32,7 +32,7 @@ function createClient(store: Store): Promise { const androidHome = store.getState().settingsState.androidHome; const adbPath = path.resolve(androidHome, 'platform-tools/adb'); return reportPlatformFailures( - exec(`${adbPath} start-server`).then(() => + execFile(adbPath, ['start-server']).then(() => adbkit.createClient(adbConfig()), ), 'createADBClient.shell', diff --git a/desktop/static/icons.json b/desktop/static/icons.json index 8f5fe8d4e..b93416839 100644 --- a/desktop/static/icons.json +++ b/desktop/static/icons.json @@ -594,5 +594,8 @@ ], "raincloud": [ 16 + ], + "app-microsoft-windows-outline": [ + 24 ] } \ No newline at end of file