diff --git a/desktop/app/src/devices/AndroidDevice.tsx b/desktop/app/src/devices/AndroidDevice.tsx index 48f392891..7b091e2b8 100644 --- a/desktop/app/src/devices/AndroidDevice.tsx +++ b/desktop/app/src/devices/AndroidDevice.tsx @@ -202,16 +202,20 @@ export default class AndroidDevice extends BaseDevice { } } -export async function launchEmulator(name: string) { +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') .then((emulatorPath) => { if (emulatorPath) { - const child = spawn(emulatorPath, [`@${name}`], { - detached: true, - cwd: dirname(emulatorPath), - }); + const child = spawn( + emulatorPath, + [`@${name}`, ...(coldBoot ? ['-no-snapshot-load'] : [])], + { + detached: true, + cwd: dirname(emulatorPath), + }, + ); child.stderr.on('data', (data) => { console.error(`Android emulator error: ${data}`); }); diff --git a/desktop/app/src/sandy-chrome/appinspect/LaunchEmulator.tsx b/desktop/app/src/sandy-chrome/appinspect/LaunchEmulator.tsx index 3f4b70ba8..40f3d48bb 100644 --- a/desktop/app/src/sandy-chrome/appinspect/LaunchEmulator.tsx +++ b/desktop/app/src/sandy-chrome/appinspect/LaunchEmulator.tsx @@ -8,8 +8,13 @@ */ import React, {useEffect, useState} from 'react'; -import {Modal, Button, message, Alert} from 'antd'; -import {AndroidOutlined, AppleOutlined} from '@ant-design/icons'; +import {Modal, Button, message, Alert, Menu, Dropdown} from 'antd'; +import { + AppleOutlined, + PoweroffOutlined, + MoreOutlined, + AndroidOutlined, +} from '@ant-design/icons'; import {Store} from '../../reducers'; import {useStore} from '../../utils/useStore'; import {launchEmulator} from '../../devices/AndroidDevice'; @@ -23,6 +28,8 @@ import { import GK from '../../fb-stubs/GK'; import {JSEmulatorLauncherSheetSandy} from '../../chrome/JSEmulatorLauncherSheet'; +const COLD_BOOT = 'cold-boot'; + export function showEmulatorLauncher(store: Store) { renderReactRoot((unmount) => ( @@ -65,25 +72,45 @@ export const LaunchEmulatorDialog = withTrackingScope( }, [iosEnabled, getSimulators]); const items = [ - ...androidEmulators.map((name) => ( - - )), + ...(androidEmulators.length > 0 ? [] : []), + ...androidEmulators.map((name) => { + const launch = (coldBoot: boolean) => { + launchEmulator(name, coldBoot) + .catch((e) => { + console.error(e); + message.error('Failed to start emulator: ' + e); + }) + .then(onClose); + }; + const menu = ( + { + switch (key) { + case COLD_BOOT: { + launch(true); + break; + } + } + }}> + }> + Cold Boot + + + ); + return ( + } + onClick={() => launch(false)}> + {name} + + ); + }), + ...(iosEmulators.length > 0 ? [] : []), ...iosEmulators.map((device) => (