()
| 579 | } |
| 580 | |
| 581 | private async getEmulators(): Promise<Emulator[]> { |
| 582 | try { |
| 583 | const emus = await this.daemon.getEmulators(); |
| 584 | |
| 585 | const allEmulatorsByID: Record<string, Emulator> = {}; |
| 586 | loop1: |
| 587 | for (const e of emus) { |
| 588 | // Exclude any bogus-looking emulators until a Flutter fix ships. |
| 589 | for (const field of [e.name, e.id]) { |
| 590 | const mayBeBogusEmulator = field?.includes("|") |
| 591 | && (field?.startsWith("INFO") || field?.startsWith("WARN") || field?.startsWith("ERR")); |
| 592 | if (mayBeBogusEmulator) |
| 593 | continue loop1; |
| 594 | } |
| 595 | |
| 596 | allEmulatorsByID[e.id] = { |
| 597 | category: e.category, |
| 598 | id: e.id, |
| 599 | name: e.name || e.id, |
| 600 | platformType: e.platformType, |
| 601 | type: "emulator", |
| 602 | }; |
| 603 | } |
| 604 | |
| 605 | // Add/update any custom emulators. |
| 606 | for (const e of this.config.flutterCustomEmulators) { |
| 607 | const existing = allEmulatorsByID[e.id]; |
| 608 | allEmulatorsByID[e.id] = { |
| 609 | category: "custom", |
| 610 | ...existing, |
| 611 | ...e, |
| 612 | type: "custom-emulator", |
| 613 | } as Emulator; |
| 614 | } |
| 615 | |
| 616 | const emulators = Object.values(allEmulatorsByID); |
| 617 | this.emulators = emulators; |
| 618 | |
| 619 | // Whenever we see emulators, record all their names. |
| 620 | for (const e of emulators) |
| 621 | this.knownEmulatorNames[e.id] = e.name; |
| 622 | |
| 623 | return emulators; |
| 624 | } catch (e) { |
| 625 | this.logger.error({ message: e }); |
| 626 | return []; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | public async promptForAndLaunchEmulator(allowAutomaticSelection = false): Promise<boolean> { |
| 631 | const emulators = await this.getPickableEmulators(false); |
no test coverage detected