# Consumer Proguard rules for glasses-core.
#
# These ship inside the AAR and are applied automatically to every consuming
# app, so a customer needs no R8 configuration of their own. That is the whole
# contract: an app that turns on minification must keep working with no action.

# Keep all public API in the extentos.glasses package.
-keep class com.extentos.glasses.** { *; }

# --- JNA, reached transitively through uniffi ---
#
# Keeping only com.extentos.glasses.** is necessary and NOT sufficient. The SDK
# reaches its Rust core through uniffi, uniffi's Kotlin bindings reach it through
# JNA, and JNA resolves classes and fields BY NAME from native code. R8 is free
# to rename them, and did: a release build with `isMinifyEnabled = true` — what
# Android Studio's own release template writes — crashed on launch, 100% of the
# time, with
#
#   java.lang.UnsatisfiedLinkError: Can't obtain peer field ID for class
#   com.sun.jna.Pointer
#     at com.sun.jna.Native.initIDs(Native Method)
#     at com.sun.jna.X.<init>                    <-- renamed by R8
#     at com.extentos.glasses.core.UniffiRustCallStatus.<init>
#     at com.extentos.glasses.core.ExtentosGlasses$Companion.resolveAuto
#
# The SDK died in resolveAuto before doing anything at all, so this took out
# every Android app regardless of capability footprint.
#
# Debug builds do not minify, the simulator does not minify, and no test
# minifies — so validateIntegration, getProductionChecklist and the entire
# agent E2E loop were green on a build that could not launch. Found by the
# fresh-agent surface audit on 2026-08-13, which built an actual release AAB.
-keep class com.sun.jna.** { *; }
-keepclassmembers class * extends com.sun.jna.** { public *; }
-keepclassmembers class * implements com.sun.jna.Library { *; }
-keepclassmembers class * implements com.sun.jna.Callback { *; }
-dontwarn java.awt.**

# --- The CONSUMER's own BuildConfig, which the SDK reads by reflection ---
#
# `ExtentosGlasses` resolves the app's gateway credential and dev-loop session
# URL with
#
#   Class.forName("${ctx.packageName}.BuildConfig")
#     .getDeclaredField("EXTENTOS_PROJECT_KEY" / "EXTENTOS_SESSION_URL")
#
# Those fields live in the CONSUMER's package, not ours, so
# `-keep class com.extentos.glasses.**` does not reach them — and nothing in
# the generated bootstrap references them in code, so R8 correctly concludes
# they are unused and removes them. Confirmed by dumping a minified release:
# `Lcom/example/traillog/BuildConfig;` was absent entirely, the only surviving
# EXTENTOS_* symbol was the SDK's own EXTENTOS_VERSION, and no pk_ constant
# remained anywhere in the dex.
#
# The consequence is silent rather than loud: the app launches, the reflective
# lookup returns null, and it holds no gateway credential — failing exactly the
# way validateIntegration's own error text warns about, at runtime only, in
# release only.
-keep class **.BuildConfig {
    public static java.lang.String EXTENTOS_PROJECT_KEY;
    public static java.lang.String EXTENTOS_SESSION_URL;
}

# --- Vosk, the on-device wake-word/STT engine ---
#
# Same hazard, same mechanism, not hypothetical: vosk-android's classes
# (org/vosk/LibVosk, Model, Recognizer) reference com/sun/jna directly, so they
# are name-resolved too. This path is the system-audio baseline and real
# hardware rather than the simulator, which is precisely where a release-only
# break would surface last and cost most.
-keep class org.vosk.** { *; }
