Take the emulator half out of run-android.sh

Which AVD this checkout means, creating it, booting it headless and refusing
to start one the machine has no room for is the same sequence in ai-app,
ai-app-2 and dev-updater. It now lives once, in ~/repos/emulator-tools, and
this script is what is actually specific to this project: a build, an install
and a launch.

Three copies of "boot an emulator" was three places for the memory check none
of them had -- starting one at 2.8 GB available invoked the OOM killer, and
what it took first was another session's emulator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
irisandClaude Opus 5 committed 2026-08-30 13:09:36 -04:00
1 parent 1d843f20f2
commit 558095520d
2 files changed
+39 -101

No files matched your search

+13 -10
View File
@@ -225,16 +225,19 @@ first if a remote spawn ever mangles an argument.
The emulator app reaches it at `https://10.0.2.2:8443`; enroll it with
`adb -s "$SERIAL" shell "am start -a android.intent.action.VIEW -d 'aiapp://enroll?host=10.0.2.2&port=8443&token=…'"`
(quote so the device shell doesn't eat the `&`s).
- **Name the device on every `adb` call.** This checkout runs its own
emulator — `run-android.sh` derives the AVD name from the directory, so
a second clone gets a second AVD rather than queueing for one shared
machine-wide `tdep`. With more than one attached, a bare `adb shell` or
`adb get-state` fails with `more than one device/emulator` and a bare
`adb shell pm list packages` comes back **empty**, which reads as the app
having been uninstalled rather than as the question being ambiguous.
Get the serial the way `run-android.sh` does — match `adb -s <serial> emu
avd name` against the AVD — or export `ANDROID_SERIAL`, which every
`adb` call honours without `-s`.
- **The emulator is `~/repos/emulator-tools`' business, not this repo's.**
`emu up` creates and boots the AVD named after this checkout (`ai-app-2`),
refusing when the machine has no room for one; `emu list` says what is
attached and what it costs; `emu down` stops it. `run-android.sh` is that
plus a build and an install. Run that repo's `install.sh` once if `emu` is
missing.
The `adb` on `PATH` after sourcing `android-env.sh` is that repo's wrapper,
which fills in `-s` from the same rule — so a bare `adb shell` reaches this
checkout's emulator and refuses to reach another one's. That defaulting is
what makes the old advice unnecessary rather than wrong: with two attached
and no `-s`, a bare `adb shell pm list packages` comes back **empty**,
which reads as the app having been uninstalled rather than as the question
being ambiguous.
## Where things run (host vs this VM)