Skip to content

Commit

Permalink
Group "cold boot" emulators next to their normal boot versions
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTup committed Feb 8, 2022
1 parent 2609cc4 commit 8574536
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/shared/vscode/device_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,37 +455,41 @@ export class FlutterDeviceManager implements vs.Disposable {
if (this.config.flutterShowEmulators === "local" && !isRunningLocally)
return [];

const emulators: PickableDevice[] = (await this.getEmulators())
.filter((e) => this.isSupported(supportedTypes, e))
.map((e) => ({
const pickableEmulators: PickableDevice[] = [];

const supportedEmulators = (await this.getEmulators()).filter((e) => this.isSupported(supportedTypes, e));

for (const e of supportedEmulators) {
const pickableEmulator = {
alwaysShow: false,
coldBoot: false,
description: showAsEmulators ? `${e.category || "mobile"} ${this.emulatorLabel(e.platformType)}` : e.platformType || undefined,
device: e,
label: showAsEmulators ? "$(play) " + `Start ${e.name}` : e.name,
}));

// Add a cold boot option for each android based emulator
if (this.daemon.capabilities.supportsAvdColdBootLaunch) {
const androidEmulators = emulators.filter((e) => e.device.platformType && e.device.platformType === "android");
androidEmulators.forEach((e) => emulators.push({
alwaysShow: e.alwaysShow,
coldBoot: true,
description: `${e.description} (cold boot)`,
device: e.device,
label: e.label,
}));
};
pickableEmulators.push(pickableEmulator);

// Add a cold boot option for each android based emulator
if (pickableEmulator.device.platformType && pickableEmulator.device.platformType === "android" && this.daemon.capabilities.supportsAvdColdBootLaunch) {
pickableEmulators.push({
alwaysShow: pickableEmulator.alwaysShow,
coldBoot: true,
description: `${pickableEmulator.description} (cold boot)`,
device: pickableEmulator.device,
label: pickableEmulator.label,
});
}
}

// Add an option to create a new emulator if the daemon supports it.
if (this.daemon.capabilities.canCreateEmulators && this.isSupported(supportedTypes, { platformType: "android" })) {
emulators.push({
pickableEmulators.push({
alwaysShow: true,
device: { type: "emulator-creator", platformType: "android", name: "Create Android emulator" } as EmulatorCreator,
label: "$(plus) " + "Create Android emulator",
});
}
return emulators;
return pickableEmulators;
}

private async launchEmulator(emulator: f.FlutterEmulator, coldBoot: boolean): Promise<boolean> {
Expand Down

0 comments on commit 8574536

Please sign in to comment.