Skip to content

fix(android): open emulators reliably in the panel - #11

Merged
lauridskern merged 3 commits into
mainfrom
fix/android-emulator-auth
Oct 8, 2026
Merged

lauridskern merged 3 commits into
mainfrom
fix/android-emulator-auth

Conversation

@lauridskern

Copy link
Copy Markdown
Collaborator

Summary

Fixes two problems that stopped the Android emulator from opening in the panel.

  • Emulator stuck as unauthorized: an emulator restored from a quick-boot snapshot can come up with adb marking it unauthorized, and adb never checks again. The panel waited out the two-minute boot limit without showing a usable device. Because the AVD name was only read for authorized devices, the dropdown also listed a bare emulator-5554 next to the same AVD shown as stopped. Selecting that entry failed straight away.
    • Emulators are now named through the emulator console in every adb state, so they appear once under their AVD name.
    • While an AVD boots, or after selecting a running emulator, the plugin runs adb reconnect for an unauthorized emulator, at most every 5 s. Selecting a running emulator waits up to 15 s and then explains how to recover.
    • Booting and selecting now share one readiness check: adb authorized the device and sys.boot_completed is 1.
  • Package without ws: the build copies runtimes/serve-emu/node_modules into the package. A checkout that last ran npm run vendor:serve-emu before the Node.js runtime change (740a6ea) packaged a stale folder without ws, and the Android backend exited on start with ERR_MODULE_NOT_FOUND. The build now compares npm's record of installed packages with package-lock.json and stops with a vendor:serve-emu hint when they differ.

The final commit bumps the version to 0.1.140.

Telemetry

New android.emulator.adb_reconnects count with a fixed trigger (boot or selection), on the simulator surface with Android emulator context. It sends no serials, AVD names or adb output. Documented in docs/telemetry.md. Existing Android startup diagnostics and MCP tool errors still cover boot outcomes.

Testing

  • New test: an unauthorized emulator keeps its AVD name, is not listed again as a stopped AVD, and becomes ready after one reconnect once boot completes.
  • The build check passes with a fresh vendor:serve-emu install and fails on a stale installed lockfile with the hint.
  • npm test: 612 of 614 pass. The Android CLI tests that failed locally before now pass, since they needed ws. tests/public-release.test.ts fails because this checkout's root node_modules lacks @commitlint/cli.
  • Live on a Play Store API 36.1 emulator:
    • adb reconnect fixed a real stuck unauthorized state.
    • Selecting it through the new code returned Medium_Phone_API_36.1 as running.
    • A packaged serve-emu with fresh dependencies started and streamed through scrcpy.
  • Restarting from the snapshot did not reproduce the stuck state on demand; that run authorized within 2.5 s.

An emulator restored from a quick-boot snapshot can stay unauthorized
because adb does not repeat the key exchange, so the panel waited out
the boot timeout and listed the bare serial next to the stopped AVD.
Name emulators through the console in every adb state, and reconnect
the adb transport at most every 5 seconds while an AVD boots or after
selecting a running emulator. Both paths share one readiness check that
waits for authorization and sys.boot_completed. Count reconnects.
The build copies runtimes/serve-emu/node_modules into the package. A
checkout that last ran vendor:serve-emu before the Node.js runtime
change shipped without ws, so the Android backend exited on start.
Compare npm's installed lockfile with package-lock.json and stop with
a vendor:serve-emu hint when they differ.
@lauridskern
lauridskern merged commit f0e14ae into main Oct 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant