Skip to content

Android Client Architecture ​

Last updated

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 FileResponsibility & Implementation Notes
ServerRepository.kt · ChirpHttp.ktDiscovery, policy checks, Chrome Custom Tabs Passkey callbacks (cn.youzifeile.chirp.android://auth/callback), and redirect-blocking HTTP client.
IdentityVault.ktEncrypts 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.ktSeals 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.ktVerifies APK assets/AuthorizationTrust.json signatures; requires both a valid snapshot signature and a successful blacklist refresh before extending authorization deadlines.
NetworkClock.ktEnforces reliable clock verification prior to sign-in or device approval (NETWORK_TIME_REQUIRED).
CallController.kt · CallService.ktIntegrates 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.ktCoroutine-driven group state machine and 3s media lease tracker backed by SystemClock.elapsedRealtime() (deep-sleep aware).
RoomChat.kt · RoomAttachments.ktEncrypted data-channel chat plus chirp-attachments encrypted cache, bandwidth throttling (AttachmentBandwidth.kt), and prefix-verified resume.
ChirpApp.kt · LockedLoginScreen.kt · TaskPreview.ktAdaptive 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):

  1. Rust OpenMLS JNI bridge (mls_jni.c + MlsNative.kt): Links Rust OpenMLS .so using CLOCK_BOOTTIME for 90s/120s key-age enforcement and clears native handles inside NonCancellable coroutine blocks.
  2. Audio preprocessing & RNNoise (rnnoise_jni.c + RNNoiseProcessor.kt): Plugs into WebRTC JavaAudioDeviceModule supporting WebRTC AEC + RNNoise (Default), WebRTC Built-in NS, and AEC Only with −45 dBFS default VAD.
  3. Outgoing self-check & incoming pre-Opus verifier (voice_receiver.cpp + VoiceKeys.kt):
    • Outbound double-check: VoiceKeys.authenticatesOutgoing validates active SSRC, slot, decryption self-test, and < 65,536 nonce ceiling prior to releasing any encrypted RTP frame;
    • Inbound replay guard: C++ voice_receiver.cpp verifies AES/GCM/NoPadding before Opus decoding and tracks seen 96-bit IVs per sender/key up to 65,536 frames;
    • Dual-ABI vtable testing: Because WebRTC 150.7871.08 C++ vtables differ between arm64-v8a and x86_64, VoiceTransportTest runs separately on both ABIs.

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:...).