Say that Gradle had the same hole the adb wrapper closed

Gradle's install and connected-test tasks never went through that wrapper,
so they reached every attached emulator. emulator-tools now guards them with
a Gradle init script; this records what that means here, and how to name a
device without exporting a serial that goes stale.

Also stop naming one checkout's AVD in a file that is the same in every
clone -- it read as a suggestion to target ai-app-2 from ai-app.
This commit is contained in:
iris committed 2026-08-31 15:41:16 -04:00
1 parent 93ce66c5f0
commit 1c3cfc868b
1 file changed
+16 -5
+16 -5
View File
@@ -258,11 +258,12 @@ first if a remote spawn ever mangles an argument.
`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).
- **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.
`emu up` creates and boots the AVD named after this checkout — whatever
`emu name` prints, never a name typed out here, since this file is the same
in every clone — 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
@@ -270,6 +271,16 @@ first if a remote spawn ever mangles an argument.
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.
**Gradle does not go through that wrapper**, so it had the same hole until
2026-08-31: `installDebug`, `uninstallDebug` and `connectedAndroidTest` ask
the adb server for every attached device and act on all of them, which is
how one session's debug build landed on another's emulator. A Gradle init
script from `emulator-tools` now runs `emu check` before those tasks and
fails the build rather than fanning out. When it refuses, say which device
you mean at the moment you use it — `ANDROID_SERIAL=$(emu serial)
./gradlew …` — rather than exporting a serial into the shell, which goes
stale the next time an emulator restarts and another checkout's takes the
port.
## Where things run (host vs this VM)