also looking at this
feat(maps): add key-free native Android maps and shared map controls
#363
28 files
+1857
-481
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -12,8 +12,6 @@ export interface AndroidEmulatorOptions { | ||
| 12 | 12 | temporaryDirectory?: string |
| 13 | 13 | port?: number |
| 14 | 14 | acceptLicenses?: boolean |
| 15 | /** Readiness budget in milliseconds, from 1 second to 30 minutes; defaults to 10 minutes. */ | |
| 16 | bootTimeoutMs?: number | |
| 17 | 15 | env?: Record<string, string | undefined> |
| 18 | 16 | } |
| 19 | 17 | |
| @@ -35,9 +33,6 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 35 | 33 | throw new Error('The Android system image must match the host architecture') |
| 36 | 34 | if (options.acceleration === 'software' && process.arch !== 'x64') |
| 37 | 35 | throw new Error('Android software emulation requires an x86_64 host and system image') |
| 38 | const bootTimeoutMs = options.bootTimeoutMs ?? 600_000 | |
| 39 | if (!Number.isSafeInteger(bootTimeoutMs) || bootTimeoutMs < 1000 || bootTimeoutMs > 1_800_000) | |
| 40 | throw new Error('Android bootTimeoutMs must be between 1000 and 1800000 milliseconds') | |
| 41 | 36 | const port = options.port ?? 5558 |
| 42 | 37 | if (!Number.isInteger(port) || port < 5554 || port > 5682 || port % 2 !== 0) throw new Error('Android console ports must be even and between 5554 and 5682') |
| 43 | 38 | const sdk = resolve(options.sdkRoot) |
| @@ -108,9 +103,9 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 108 | 103 | created = true |
| 109 | 104 | log = openSync(join(artifacts, 'emulator.log'), 'w') |
| 110 | 105 | child = Bun.spawn([executable, '-avd', name, '-port', String(port), '-no-window', '-no-snapshot', '-no-audio', '-no-boot-anim', '-gpu', 'software', '-memory', '2048', '-cores', '2', '-accel', options.acceleration === 'software' ? 'off' : 'on'], { env, stdout: log, stderr: log }) |
| 111 | const identity = { image: options.image, acceleration: options.acceleration, bootTimeoutMs, accelerationProbeExitCode: acceleration.code, serial, avdDirectory: env.ANDROID_AVD_HOME, emulatorPid: child.pid } | |
| 106 | const identity = { image: options.image, acceleration: options.acceleration, accelerationProbeExitCode: acceleration.code, serial, avdDirectory: env.ANDROID_AVD_HOME, emulatorPid: child.pid } | |
| 112 | 107 | await Bun.write(join(artifacts, 'android-emulator.json'), JSON.stringify(identity, null, 2) + '\n') |
| 113 | const deadline = Date.now() + bootTimeoutMs | |
| 108 | const deadline = Date.now() + 600_000 | |
| 114 | 109 | while (Date.now() < deadline && child.exitCode === null) { |
| 115 | 110 | let booted = false |
| 116 | 111 | // Nonzero ADB exits are expected while services initialize. Filesystem, |
| @@ -137,7 +132,7 @@ export async function createAndroidEmulator(options: AndroidEmulatorOptions): Pr | ||
| 137 | 132 | } |
| 138 | 133 | await Bun.sleep(2000) |
| 139 | 134 | } |
| 140 | throw new Error(`The owned Android emulator did not boot within ${bootTimeoutMs}ms; inspect ${artifacts}`) | |
| 135 | throw new Error(`The owned Android emulator did not boot; inspect ${artifacts}`) | |
| 141 | 136 | } |
| 142 | 137 | catch (error) { |
| 143 | 138 | if (child) { |