4a87cef98c
Bring the Android client to parity with Apple's gamepad experience and finish Wake-on-LAN. - Console/gamepad home: host carousel, aurora chrome, mTLS game-library coverflow, and an input-aware legend that switches between gamepad face buttons and a TV-remote select-ring + arrows based on the last-used input. - Wake-on-LAN: the fire-and-forget send is upgraded to wait-until-up (WakeController/WakeOverlay: resend + mDNS poll, 90s timeout, cancel/retry, fingerprint-matched so a host that cold-boots onto a new DHCP IP still connects), plus host edit (touch dialog + console form) with an auto-filled MAC. - Android TV: brand banner (android:banner), density-aware console scaling, D-pad/ remote nav (Up = Settings, Down or the pad Select button = host Options), emergency stream-exit chord, and 120Hz console refresh. - Touch UI: settings split into subpages with a tablet NavigationRail, axis-aware tab animation (horizontal on phones, vertical on the tablet rail), animated settings navigation, and a licenses screen with a back button + the real workspace version (read from Cargo.toml). - Vector Lock/controller icons (no emoji); bundled Geist font. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
118 lines
6.0 KiB
Kotlin
118 lines
6.0 KiB
Kotlin
import java.io.File
|
|
import java.util.Properties
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
// AGP 9 built-in Kotlin compiles this module's Kotlin (NativeBridge) — no kotlin.android plugin.
|
|
id("com.android.library")
|
|
}
|
|
|
|
val ndkVer = "30.0.14904198" // r30-beta1 — matches the SDK NDK installed for cargo-ndk
|
|
|
|
android {
|
|
namespace = "io.unom.punktfunk.kit"
|
|
compileSdk = 37 // Android 17 — align with :app (androidx.core 1.19.0 requires it)
|
|
ndkVersion = ndkVer
|
|
|
|
defaultConfig {
|
|
minSdk = 28 // Android 9 — reaches older TV boxes; API 31+ features are runtime-gated.
|
|
// Keep in lockstep with :app — 32-bit armeabi-v7a for the many 32-bit Google TV / Android TV
|
|
// boxes, 64-bit arm64-v8a for phones + modern TV, x86_64 for the emulator.
|
|
ndk { abiFilters += listOf("arm64-v8a", "armeabi-v7a", "x86_64") }
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_21
|
|
targetCompatibility = JavaVersion.VERSION_21
|
|
}
|
|
packaging { jniLibs { useLegacyPackaging = false } } // 16 KB-page friendly
|
|
}
|
|
|
|
kotlin { compilerOptions { jvmTarget.set(JvmTarget.JVM_21) } }
|
|
|
|
dependencies {
|
|
// mTLS HTTPS client for the host's management API (the game-library fetch + cover-art loads).
|
|
// OkHttp lets us present the paired client cert and pin the host's self-signed cert by SHA-256.
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
testImplementation("junit:junit:4.13.2") // JVM unit test for the pure TXT parser
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// cargo-ndk: cross-compile clients/android/native (punktfunk-client-android) into this module's jniLibs/<abi>/ so the
|
|
// resulting libpunktfunk_android.so is packaged into the app (and any AAR this module produces).
|
|
// NDK r28+ aligns to 16 KB pages by default — no extra linker flags. Prereqs (see clients/android
|
|
// /README.md): `cargo install cargo-ndk` + `rustup target add aarch64-linux-android x86_64-linux-android`.
|
|
// ------------------------------------------------------------------------------------------------
|
|
val repoRoot = rootDir.parentFile.parentFile // clients/android -> clients -> repo root
|
|
val cargoBin = "${System.getProperty("user.home")}/.cargo/bin"
|
|
|
|
// SDK location without depending on AGP's DSL (sdkDirectory isn't in AGP 9's library extension):
|
|
// env first (set by Android Studio and by our CLI shell), then local.properties, then the default.
|
|
fun androidSdkDir(): String {
|
|
System.getenv("ANDROID_HOME")?.let { return it }
|
|
System.getenv("ANDROID_SDK_ROOT")?.let { return it }
|
|
val lp = rootProject.file("local.properties")
|
|
if (lp.exists()) {
|
|
val props = Properties()
|
|
lp.inputStream().use { props.load(it) }
|
|
props.getProperty("sdk.dir")?.let { return it }
|
|
}
|
|
return "${System.getProperty("user.home")}/Library/Android/sdk"
|
|
}
|
|
|
|
fun registerCargoNdk(taskName: String, release: Boolean) =
|
|
tasks.register<Exec>(taskName) {
|
|
group = "rust"
|
|
description = "cargo-ndk build of punktfunk-client-android (${if (release) "release" else "debug"})"
|
|
workingDir = repoRoot
|
|
val sdk = androidSdkDir()
|
|
// A GUI Android Studio launch does not source the login shell, so make cargo, the NDK, and
|
|
// cmake (libopus builds via the cmake crate) discoverable explicitly — same as a bare CLI.
|
|
val cmakeBin = "$sdk/cmake/3.22.1/bin"
|
|
environment(
|
|
"PATH",
|
|
cargoBin + File.pathSeparator + cmakeBin + File.pathSeparator + System.getenv("PATH"),
|
|
)
|
|
environment("ANDROID_HOME", sdk)
|
|
environment("ANDROID_NDK_HOME", "$sdk/ndk/$ndkVer")
|
|
// CMake's built-in Android support (used by the cmake crate for libopus) finds the NDK via
|
|
// these, and uses Ninja (bundled next to the SDK cmake) since there's no `make`.
|
|
environment("ANDROID_NDK_ROOT", "$sdk/ndk/$ndkVer")
|
|
environment("ANDROID_NDK", "$sdk/ndk/$ndkVer")
|
|
environment("CMAKE_GENERATOR", "Ninja")
|
|
// audiopus_sys picks static-vs-dynamic by HOST not target — force the bundled static libopus
|
|
// (pure C) so the android .so links it instead of looking for the host's libopus.so.
|
|
environment("LIBOPUS_STATIC", "1")
|
|
environment("LIBOPUS_NO_PKG", "1")
|
|
// Resolve cargo by ABSOLUTE path: Gradle's Exec resolves command[0] via the JVM's
|
|
// inherited PATH, NOT the environment("PATH", …) set above (that only reaches the spawned
|
|
// child). A GUI Android Studio launch (and any daemon it started) has no ~/.cargo/bin on
|
|
// its PATH, so a bare "cargo" fails to start. The env PATH above still lets cargo/cargo-ndk
|
|
// find their subtools.
|
|
val cmd = mutableListOf(
|
|
"$cargoBin/cargo", "ndk",
|
|
"-t", "arm64-v8a", "-t", "armeabi-v7a", "-t", "x86_64",
|
|
// Link against the minSdk-28 sysroot: libaaudio (API 26) is present, and building at the
|
|
// floor makes the linker reject any accidental >28 hard import (the one API-30 call we
|
|
// make, ANativeWindow_setFrameRate, is dlsym-resolved — see decode::try_set_frame_rate).
|
|
"--platform", "28",
|
|
"-o", file("src/main/jniLibs").absolutePath,
|
|
"build", "-p", "punktfunk-client-android",
|
|
)
|
|
if (release) cmd += "--release"
|
|
commandLine(cmd)
|
|
}
|
|
|
|
val cargoNdkDebug = registerCargoNdk("cargoNdkDebug", release = false)
|
|
val cargoNdkRelease = registerCargoNdk("cargoNdkRelease", release = true)
|
|
|
|
afterEvaluate {
|
|
// `-PskipRustBuild` skips the cargo-ndk native build — for JVM-only tasks (the Roborazzi
|
|
// screenshot unit tests render Compose on the JVM and never load libpunktfunk_android.so), so
|
|
// CI/local screenshot runs don't need the Rust toolchain or NDK. The native build stays wired
|
|
// for every normal APK/AAR build.
|
|
if (!project.hasProperty("skipRustBuild")) {
|
|
tasks.named("preDebugBuild").configure { dependsOn(cargoNdkDebug) }
|
|
tasks.named("preReleaseBuild").configure { dependsOn(cargoNdkRelease) }
|
|
}
|
|
}
|