How opencovidtrace/oextrace-android works
Purpose and Android entry points
OpenExposureTrace is a native Android exposure/contact-tracing application. The application bootstrap and user entry activities are:
• app/src/main/java/org/openexposuretrace/oextrace/OextraceApp.kt
• app/src/main/java/org/openexposuretrace/oextrace/OnboardingActivity.kt
• app/src/main/java/org/openexposuretrace/oextrace/MainActivity.kt
• app/src/main/AndroidManifest.xml
Onboarding likely gates access based on persisted setup state; MainActivity hosts the primary feature UI.
UI and presentation layer
The main UI is fragment-based, split into contacts, logs, QR-code exchange, and settings. Feature ViewModels isolate screen state and operations from fragment rendering:
• app/src/main/java/org/openexposuretrace/oextrace/ui/contacts/ContactsFragment.kt
• app/src/main/java/org/openexposuretrace/oextrace/ui/logs/LogsViewModel.kt
• app/src/main/java/org/openexposuretrace/oextrace/ui/qrcode/QrCodeFragment.kt
• app/src/main/java/org/openexposuretrace/oextrace/ui/settings/SettingsFragment.kt
Control flow is user interaction → ViewModel/manager → persisted or remote data → UI list/state refresh. Layouts confirm the four main feature surfaces under app/src/main/res/layout/.
Tracking and device-sensing pipeline
Background tracking is separated from Android service lifecycle and hardware/location integrations:
• app/src/main/java/org/openexposuretrace/oextrace/service/TrackingService.kt
• app/src/main/java/org/openexposuretrace/oextrace/service/BleUpdatesService.kt
• app/src/main/java/org/openexposuretrace/oextrace/bluetooth/DeviceManager.kt
• app/src/main/java/org/openexposuretrace/oextrace/location/LocationUpdateManager.kt
These form the device-data boundary: Bluetooth observations and location updates feed tracking/contact storage rather than being handled directly in UI. Location permission/access is isolated in location/LocationAccessManager.kt.
Domain, contacts, and local persistence
Shared domain types and events define data exchanged among sensing, storage, UI, and API layers:
• app/src/main/java/org/openexposuretrace/oextrace/data/Models.kt
• app/src/main/java/org/openexposuretrace/oextrace/data/Events.kt
• app/src/main/java/org/openexposuretrace/oextrace/data/Enums.kt
Room-style local persistence is centralized behind database/DAO classes:
• app/src/main/java/org/openexposuretrace/oextrace/db/Database.kt
• app/src/main/java/org/openexposuretrace/oextrace/db/OextraceDao.kt
• app/src/main/java/org/openexposuretrace/oextrace/db/DatabaseConverters.kt
Storage managers provide use-case-specific boundaries for Bluetooth and QR contacts, tracks, location indexing/borders, tracking state, and preferences:
• app/src/main/java/org/openexposuretrace/oextrace/storage/BtContactsManager.kt
• app/src/main/java/org/openexposuretrace/oextrace/storage/QrContactsManager.kt
• app/src/main/java/org/openexposuretrace/oextrace/storage/TracksManager.kt
Identity, keys, and security boundary
Key lifecycle and cryptographic operations are distinct from contact collection:
• app/src/main/java/org/openexposuretrace/oextrace/storage/KeysManager.kt
• app/src/main/java/org/openexposuretrace/oextrace/storage/EncryptionKeysManager.kt
• app/src/main/java/org/openexposuretrace/oextrace/utils/AESEncryptor.kt
This boundary likely protects identifiers/contact payloads before persistence or transmission. PreferencesHolder.kt and settings/onboarding managers retain application configuration and enrollment state.
Network and push integration
Remote interactions are abstracted through API client/endpoint pairs, including a contacts-specific API:
• app/src/main/java/org/openexposuretrace/oextrace/api/ApiClient.kt
• app/src/main/java/org/openexposuretrace/oextrace/api/ContactsApiClient.kt
• app/src/main/java/org/openexposuretrace/oextrace/api/ContactsApiEndpoint.kt
Firebase Cloud Messaging is integrated through:
• app/src/main/java/org/openexposuretrace/oextrace/fcm/MyFirebaseMessagingService.kt
• app/google-services.json
The expected external boundaries are an HTTP backend for API/contact exchange, Firebase for push delivery, Android Bluetooth/location services, and local SQLite/Room persistence.
Dependency composition and runtime
A lightweight provider-based dependency layer assembles Android context, database, Bluetooth, JSON mapping, and HTTP/API clients:
• app/src/main/java/org/openexposuretrace/oextrace/di/Provider.kt
• app/src/main/java/org/openexposuretrace/oextrace/di/DatabaseProvider.kt
• app/src/main/java/org/openexposuretrace/oextrace/di/api/HttpClientProvider.kt
The runtime is Kotlin on Android, built as the app Gradle module (app/build.gradle), with Android services handling work that must survive outside the foreground UI.
Main entry points: BtContactsManager.kt Contact storage · Provider.kt Dependency providers · DeviceManager.kt Bluetooth sensing · ContactsApiClient.kt Contacts API client
Components 21
Android runtime
- App manifest
app/src/main/AndroidManifest.xml - Application bootstrap
app/src/main/java/org/openexposuretrace/oextrace/OextraceApp.kt - Dependency providers · Assembles database, device, JSON, and HTTP dependencies.
app/src/main/java/org/openexposuretrace/oextrace/di/Provider.kt
Presentation
- Onboarding · Gates initial setup and enrollment.
app/src/main/java/org/openexposuretrace/oextrace/OnboardingActivity.kt - Main activity · Hosts the primary fragment UI.
app/src/main/java/org/openexposuretrace/oextrace/MainActivity.kt - Feature fragments · Contacts, QR exchange, and settings surfaces.
app/src/main/java/org/openexposuretrace/oextrace/ui/contacts/ContactsFragment.kt - Logs state
app/src/main/java/org/openexposuretrace/oextrace/ui/logs/LogsViewModel.kt
Tracking pipeline
- Tracking service · Runs tracking outside the foreground UI.
app/src/main/java/org/openexposuretrace/oextrace/service/TrackingService.kt - BLE updates service
app/src/main/java/org/openexposuretrace/oextrace/service/BleUpdatesService.kt - Bluetooth sensing
app/src/main/java/org/openexposuretrace/oextrace/bluetooth/DeviceManager.kt - Location updates
app/src/main/java/org/openexposuretrace/oextrace/location/LocationUpdateManager.kt
Data and security
- Domain models and events · Shared contact, tracking, and event data contracts.
app/src/main/java/org/openexposuretrace/oextrace/data/Models.kt - Contact storage · Persists Bluetooth and QR contact records.
app/src/main/java/org/openexposuretrace/oextrace/storage/BtContactsManager.kt - Track storage
app/src/main/java/org/openexposuretrace/oextrace/storage/TracksManager.kt - Room database and DAO · Central SQLite/Room persistence boundary.
app/src/main/java/org/openexposuretrace/oextrace/db/Database.kt - Keys and encryption · Manages key lifecycle and protected payloads.
app/src/main/java/org/openexposuretrace/oextrace/storage/KeysManager.kt
Remote integration
- Contacts API client
app/src/main/java/org/openexposuretrace/oextrace/api/ContactsApiClient.kt - FCM message service
app/src/main/java/org/openexposuretrace/oextrace/fcm/MyFirebaseMessagingService.kt
Other components
- Android Bluetooth and location
- Contact exchange backend
- Firebase Cloud Messaging
Connections 27
- App manifest → Application bootstrap: starts
- App manifest → Onboarding: declares
- App manifest → Main activity: declares
- Application bootstrap → Dependency providers: initializes
- Onboarding → Main activity: setup complete
- Main activity → Feature fragments: hosts
- Feature fragments → Logs state: reads screen state
- Feature fragments → Contact storage: queries contacts
- Logs state → Track storage: loads logs
- Tracking service → BLE updates service: coordinates
- BLE updates service → Bluetooth sensing: collects observations
- Tracking service → Location updates: collects location
- Bluetooth sensing → Android Bluetooth and location: uses Bluetooth
- Location updates → Android Bluetooth and location: uses location
- Bluetooth sensing → Contact storage: stores encounters
- Location updates → Track storage: stores tracks
- Contact storage → Room database and DAO: persists
- Track storage → Room database and DAO: persists
- Contact storage → Domain models and events: uses
- Keys and encryption → Contact storage: protects payloads
- Contacts API client → Contact exchange backend: exchanges contacts
- Contacts API client → Keys and encryption: uses protected data
- FCM message service → Firebase Cloud Messaging: receives push
- FCM message service → Contacts API client: triggers sync
- Dependency providers → Room database and DAO: provides
- Dependency providers → Contacts API client: provides HTTP client
- Dependency providers → Bluetooth sensing: provides