.docs/android-app.md
Docs/android-app.md

Android Companion

Monarch.android is a native Kotlin + Jetpack Compose companion app (Android 8.0 / API 26+) styled with the same dark #000000 / #0b0b0c surfaces and metric accents as Monarch.panel.

Features

  • Overview: Lists every managed node with CPU, memory, and disk usage, temperatures, VM counts, optional ClyoCloud status, and VMs nested directly under their host node.
  • Node detail: Live 3-minute CPU and memory charts, network interfaces, filesystems, failing dm-cache SSD warnings, and VM actions (start, shut down, reboot, force off) with confirmation dialogs.
  • Background alerts: AlertWorker polls /api/mobile/alerts roughly every 15 minutes via Android WorkManager — no Google FCM or third-party push relay required — and raises local notifications for offline nodes, crashed VMs, failing cache SSDs, and configured panel alert rules.

Pairing & security

  1. In Monarch.panel, open Settings → Phone app.
  2. Select a permission scope:
    • Monitor (read-only telemetry, VMs, alerts)
    • Monitor + start/stop VMs (adds confirmed VM power actions)
  3. Verify the panel URL the phone should connect to (LAN IP, domain, or Netmaker address) and generate a pairing QR code.
  4. In the Android app, tap Scan QR code (uses Google Play services' code scanner without requiring camera permission), verify the panel's SHA-256 certificate fingerprint, and tap Pair.

Pairing codes are single-use and expire after 10 minutes.

  • Pinned TLS (PinnedTls.kt): The app pins the panel's SHA-256 certificate fingerprint from the QR code so it only communicates with that specific panel instance.
  • Keystore-backed tokens (SecureStore.kt): Each paired phone receives its own revocable bearer token scoped to /api/mobile/*, encrypted via Android Keystore and excluded from cloud/device backups.
  • Device protection: Supports optional biometric or screen-lock unlock, and blocks screenshots (FLAG_SECURE). Revoking a phone in Settings → Phone app invalidates its access immediately.

Building the APK

Prebuilt debug APKs are produced on every push by the Monarch Android CI job on code.weexnes.dev/monarch/android.

To build locally (requires JDK 17+ and Android SDK platform 35, Gradle 9.1 / AGP 9):

git clone https://code.weexnes.dev/monarch/android.git
cd android
export ANDROID_HOME=/opt/android-sdk
./gradlew assembleDebug

The output APK is written to app/build/outputs/apk/debug/app-debug.apk. For a release build, configure a signing config in app/build.gradle.kts and run ./gradlew assembleRelease.