Files
irisandClaude Opus 5 5d77599f3f Collect the emulator tooling into one repo
ui-trace, the adb wrapper and its device recorder were loose files under
~/.local, and each Android checkout carried its own copy of the same
emulator boot sequence. This puts them together, with an install script that
symlinks them back so editing the repo is editing what runs.

Two things are new rather than moved. `emu` is the emulator lifecycle --
name, serial, list, up, down -- keyed on the AVD named after the enclosing
checkout, which is the rule that lets several sessions work here at once;
and `adb` now fills in `-s` from that same rule, because with two emulators
attached a bare `adb shell pm list packages` comes back empty rather than
failing, which reads as the app being uninstalled rather than the question
being ambiguous.

`emu up` refuses when the machine has no room. On 2026-08-30 an emulator
started with 2.8 GB available invoked the OOM killer, and what it took was
not the emulator that had just started: it walked the user slice and killed
pipewire, dbus-broker and another session's emulator first.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-30 13:06:17 -04:00

29 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Builds uitrace.jar from UiTrace.java. Run after editing the recorder; ui-trace
# also runs this by itself when the jar is missing or older than the source.
set -euo pipefail
cd "$(dirname "$0")"
# The ambient ANDROID_HOME on this machine points at a root-owned SDK that has
# no build-tools under it, so an SDK is only accepted once d8 is confirmed in it.
d8=""
for root in "$HOME/Android/Sdk" "${ANDROID_SDK_ROOT:-}" "${ANDROID_HOME:-}"; do
[ -n "$root" ] || continue
found=$(ls -d "$root"/build-tools/*/d8 2>/dev/null | sort -V | tail -1)
if [ -n "$found" ]; then
d8=$found
platform=$(ls -d "$root"/platforms/android-* 2>/dev/null | sort -V | tail -1)
break
fi
done
if [ -z "$d8" ] || [ -z "${platform:-}" ]; then
echo "ui-trace: no Android SDK with both build-tools and a platform" >&2
exit 1
fi
rm -rf classes && mkdir -p classes
javac --release 17 -Xlint:all -Werror -cp "$platform/android.jar" -d classes UiTrace.java
"$d8" --min-api 30 --output . classes/UiTrace.class
python3 -c 'import zipfile,sys; z=zipfile.ZipFile("uitrace.jar","w",zipfile.ZIP_DEFLATED); z.write("classes.dex"); z.close()'
rm -rf classes classes.dex
echo "built $(pwd)/uitrace.jar"