From a6cb9a9082b040882f5190c8f99613b9fe2ad385 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sat, 5 Sep 2026 21:03:44 -0400 Subject: [PATCH] app: a `bench` build type for P0's benchmark gate Own application id (.bench suffix) and label ("AI Sessions bench" via a build-type resValue over the new @string/app_name), release optimisations, signed with the same key build-apk.sh already generates, FIXTURE_MODE=true wired through BuildConfig. Its asset source set points straight at app/bench-fixture/assets rather than a copy under androidApp, so there is one file to keep in sync with the generator, not two. build-apk.sh bench builds it; the CA-pinning step is untouched and still requires a real ca.pem to exist, even though this build never connects -- simplest to let it pin whatever is there rather than special-casing it. Co-Authored-By: Claude Fable 5.1 --- app/androidApp/build.gradle.kts | 39 +++++++++++++++++++ app/androidApp/src/main/AndroidManifest.xml | 2 +- .../src/main/res/values/strings.xml | 6 +++ app/build-apk.sh | 12 ++++-- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 app/androidApp/src/main/res/values/strings.xml diff --git a/app/androidApp/build.gradle.kts b/app/androidApp/build.gradle.kts index 9b5d6c9..9473785 100644 --- a/app/androidApp/build.gradle.kts +++ b/app/androidApp/build.gradle.kts @@ -102,6 +102,16 @@ android { targetSdk = 37 versionCode = 1 versionName = "1.0" + // Read by MainActivity to decide, at startup, whether this is the P0 benchmark build + // (docs/RUST.md's P0 box) rather than the app somebody enrolled. False everywhere except + // the `bench` build type below, which overrides it. + buildConfigField("boolean", "FIXTURE_MODE", "false") + } + buildFeatures { + // Only for FIXTURE_MODE above; nothing else here reaches for generated BuildConfig fields. + buildConfig = true + // Only for the bench build type's resValue("string", "app_name", ...) below. + resValues = true } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } @@ -131,6 +141,35 @@ android { isMinifyEnabled = false if (keystore != null) signingConfig = signingConfigs.getByName("release") } + // P0's benchmark build (docs/RUST.md, docs/DECISIONS.md's 2026-09-05 entry): release + // optimisations so a frame time measured here means what release means everywhere else in + // this project, its own application id so it installs beside a real enrollment rather than + // replacing it, and FIXTURE_MODE so MainActivity opens straight onto the fixture session + // instead of asking to be enrolled. Signed with the same key as release -- it never talks + // to a real backend, so there is no CA of its own to mismatch, and a second keystore would + // be one more secret to keep off this machine's shared mount for no benefit. + create("bench") { + initWith(getByName("release")) + // :link (wg-app-link) has no "bench" build type of its own -- it is a library shared + // with dev-updater and has no reason to know this project invented one -- so this says + // which of its build types to link against instead. + matchingFallbacks += listOf("release") + applicationIdSuffix = ".bench" + // "AI Sessions bench" everywhere the OS shows the app's name (launcher, recents, + // Settings): this resValue overrides res/values/strings.xml's app_name for this + // build type alone, and AndroidManifest.xml's android:label reads @string/app_name + // rather than a literal so a build type can override it without touching the + // manifest. + resValue("string", "app_name", "AI Sessions bench") + buildConfigField("boolean", "FIXTURE_MODE", "true") + if (keystore != null) signingConfig = signingConfigs.getByName("release") + } + } + sourceSets { + // The fixture both bench builds (this one and iris's) open with; see + // app/bench-fixture/README.md. Read directly from its own directory rather than copied + // into androidApp/src -- one file to keep in sync with the generator, not two. + getByName("bench").assets.directories.add("../bench-fixture/assets") } compileOptions { sourceCompatibility = JavaVersion.VERSION_21 diff --git a/app/androidApp/src/main/AndroidManifest.xml b/app/androidApp/src/main/AndroidManifest.xml index cb94924..36ce31d 100644 --- a/app/androidApp/src/main/AndroidManifest.xml +++ b/app/androidApp/src/main/AndroidManifest.xml @@ -25,7 +25,7 @@ the fix is a judgement about how this app should look. Drop this suppression when a real icon lands. --> diff --git a/app/androidApp/src/main/res/values/strings.xml b/app/androidApp/src/main/res/values/strings.xml new file mode 100644 index 0000000..ca0d2bb --- /dev/null +++ b/app/androidApp/src/main/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + AI Sessions + diff --git a/app/build-apk.sh b/app/build-apk.sh index 2c49697..66e1ce0 100755 --- a/app/build-apk.sh +++ b/app/build-apk.sh @@ -4,6 +4,11 @@ # ./build-apk.sh the release build, signed (what the phone runs) # ./build-apk.sh debug the debug build, for reproducing something the # emulator scripts would build anyway +# ./build-apk.sh bench P0's benchmark build (own app id, "AI Sessions +# bench" label, opens straight onto the fixture +# session -- see docs/RUST.md's P0 box and +# app/bench-fixture/README.md). Signed the same +# as release; never touches the CA it pins. # # Dev Updater's `.dev-updater.ron` at the checkout root spells these out as # build modes, one command line each; it passes nothing else, so the word @@ -25,8 +30,9 @@ VARIANT=${1:-release} case "$VARIANT" in release) TASK=assembleRelease ;; debug) TASK=assembleDebug ;; +bench) TASK=assembleBench ;; *) - echo "build-apk.sh: unknown variant '$VARIANT' (release, debug)" >&2 + echo "build-apk.sh: unknown variant '$VARIANT' (release, debug, bench)" >&2 exit 2 ;; esac @@ -81,7 +87,7 @@ fi # uninstalling it first: the signatures differ, and Android refuses to # update across them. KEYSTORE="${AI_APP_KEYSTORE:-${XDG_CONFIG_HOME:-$HOME/.config}/ai-app/release.jks}" -if [ "$VARIANT" = release ] && [ ! -f "$KEYSTORE" ]; then +if { [ "$VARIANT" = release ] || [ "$VARIANT" = bench ]; } && [ ! -f "$KEYSTORE" ]; then KEYTOOL="${JAVA_HOME:+$JAVA_HOME/bin/keytool}" KEYTOOL="${KEYTOOL:-keytool}" if ! command -v "$KEYTOOL" >/dev/null 2>&1; then @@ -97,7 +103,7 @@ if [ "$VARIANT" = release ] && [ ! -f "$KEYSTORE" ]; then -keyalg RSA -keysize 2048 -validity 10000 \ -storepass "$PASSWORD" -keypass "$PASSWORD" -dname "CN=ai-app" >/dev/null 2>&1) fi -if [ "$VARIANT" = release ]; then +if [ "$VARIANT" = release ] || [ "$VARIANT" = bench ]; then AI_APP_KEYSTORE="$KEYSTORE" AI_APP_KEYSTORE_PASSWORD=$(cat "$KEYSTORE.password") export AI_APP_KEYSTORE AI_APP_KEYSTORE_PASSWORD