Android Client Architecture
Built with Kotlin + Jetpack Compose + Material 3, supporting Android 15+ (API 35) (targetSdk = 37) with universal APKs bundling arm64-v8a and x86_64. Matches Apple's identity, group, and E2EE semantics while integrating natively with Android Keystore, Core-Telecom, and foreground call services.
Design Philosophy & Module Layout
Uses unidirectional state (MainViewModel + Repositories + CallService) separating encrypted storage, network coordination, and live media execution:
| Module / Core File | Responsibility & Implementation Notes |
|---|---|
ServerRepository.kt · ChirpHttp.kt | Discovery, policy checks, Chrome Custom Tabs Passkey callbacks (cn.youzifeile.chirp.android://auth/callback), and redirect-blocking HTTP client. |
IdentityVault.kt | Encrypts device keys and checkpoints in noBackupFilesDir/identity-v5 using Android Keystore AES-256-GCM (alias chirp-identity-v5, AAD bound to origin|account) via AtomicFile. |
BiometricLoginVault.kt · LoginResumption.kt | Seals resumption records with random AES-GCM wrapped by an Android Keystore RSA key under noBackupFilesDir/login-resumption-v1; binds RSA unwrapping to BIOMETRIC_STRONG BiometricPrompt.CryptoObject (invalidated on biometric changes) and signs Chirp login resumption v1 proofs. |
AccountIdentity.kt · Authorization.kt | Verifies APK assets/AuthorizationTrust.json signatures; requires both a valid snapshot signature and a successful blacklist refresh before extending authorization deadlines. |
NetworkClock.kt | Enforces reliable clock verification prior to sign-in or device approval (NETWORK_TIME_REQUIRED). |
CallController.kt · CallService.kt | Integrates Core-Telecom and foreground notifications to sustain calls across screen locks and Bluetooth route switches; swiping out of Recents tears down calls and RAM tokens cleanly (relaunch triggers biometric unlock if a valid resumption record exists; explicit sign-out wipes it). |
SecureGroup.kt · MediaPermit.kt | Coroutine-driven group state machine and 3s media lease tracker backed by SystemClock.elapsedRealtime() (deep-sleep aware). |
RoomChat.kt · RoomAttachments.kt | Encrypted data-channel chat plus chirp-attachments encrypted cache, bandwidth throttling (AttachmentBandwidth.kt), and prefix-verified resume. |
ChirpApp.kt · LockedLoginScreen.kt · TaskPreview.kt | Adaptive phone/foldable/tablet UI (AdaptivePane.kt), biometric lock screen, Recents preview redaction, Android 17 LAN permission prompt, and ZXing camera/gallery QR pairing. |
Android E2EE Pipeline & C++ JNI Hooks
Gradle patches LiveKit Android (Client/android/patches/livekit-2.30.0.patch) and compiles four CMake native targets (CMakeLists.txt):
- Rust OpenMLS JNI bridge (
mls_jni.c+MlsNative.kt): Links Rust OpenMLS.sousingCLOCK_BOOTTIMEfor 90s/120s key-age enforcement and clears native handles insideNonCancellablecoroutine blocks. - Audio preprocessing & RNNoise (
rnnoise_jni.c+RNNoiseProcessor.kt): Plugs into WebRTCJavaAudioDeviceModulesupporting WebRTC AEC + RNNoise (Default), WebRTC Built-in NS, and AEC Only with−45 dBFSdefault VAD. - Outgoing self-check & incoming pre-Opus verifier (
voice_receiver.cpp+VoiceKeys.kt):- Outbound double-check:
VoiceKeys.authenticatesOutgoingvalidates active SSRC, slot, decryption self-test, and< 65,536nonce ceiling prior to releasing any encrypted RTP frame; - Inbound replay guard: C++
voice_receiver.cppverifiesAES/GCM/NoPaddingbefore Opus decoding and tracks seen 96-bit IVs per sender/key up to 65,536 frames; - Dual-ABI vtable testing: Because WebRTC
150.7871.08C++ vtables differ betweenarm64-v8aandx86_64,VoiceTransportTestruns separately on both ABIs.
- Outbound double-check:
Building & Open-Source Release Signing
See Native Client Builds · Android for JDK/NDK toolchains, Gradle tasks, and the public release key fingerprint (FE:2C:66:...).
