How bitfireat/davx5-ose works
Purpose and Runtime
DAVx⁵ is a native Android/Kotlin application for CalDAV/CardDAV synchronization, task sync, and live WebDAV file access through Android’s Storage Access Framework. The main product module is core; app-ose supplies open-source-edition application/flavor wiring. Gradle builds the multi-module Android project via settings.gradle.kts and build.gradle.kts.
Application Entry and Composition
Android starts the app from manifests, then application classes initialize the shared core and OSE-specific layer. Dependency injection modules bind application variants, sync infrastructure, startup plugins, logging, and security integrations.
• core/src/main/AndroidManifest.xml
• core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt
• app-ose/src/main/kotlin/com/davx5/ose/App.kt
UI, Account Setup, and Authentication
Compose-based Activities/ViewModels expose account management, setup, collection selection, settings, push, and WebDAV mount screens. Login supports conventional URL/email discovery plus provider-specific Nextcloud, Google, and Fastmail OAuth flows. UI is a boundary over repositories and Android account/sync services.
• core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt
• core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginScreenViewModel.kt
• core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt
Remote Discovery, Network, and Security
Service detection discovers DAV principals, home sets, and collections, persisting discovered server topology for account setup and later refresh. HTTP construction, DNS resolution, OAuth, client certificates, certificate security contexts, and Conscrypt integration form the network/security boundary to remote DAV servers.
• core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt
• core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt
• core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt
Persistent Account and Service State
Room-backed AppDatabase stores DAV accounts, services, principals, home sets, collections, sync statistics, and WebDAV mount/document metadata. DAO-backed repositories insulate UI, discovery, sync, and provider code from storage. Schema history makes database migrations a compatibility boundary.
• core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt
• core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt
• core/schemas/at.bitfire.davdroid.db.AppDatabase/20.json
Synchronization Orchestration
Android AccountManager/SyncAdapter and WorkManager entry points schedule and execute periodic or one-time sync. SyncManager selects domain-specific syncers for calendars, contacts, tasks, and JTX notes; these reconcile remote DAV resources with local Android provider state, validate conditions, record results, and notify users. Push registrations/messages can trigger or complement refresh behavior.
• core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt
• core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt
• core/src/main/kotlin/at/bitfire/davdroid/sync/worker/SyncWorkerManager.kt
Local Data and Format Translation
resource adapts app sync logic to local calendar, contacts, tasks, and JTX stores. The separate synctools Android library performs iCalendar/vCard parsing/generation and maps protocol objects to Android content-provider entities, including recurrence and provider-specific task/JTX contracts.
• core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt
• synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt
• synctools/src/main/kotlin/at/bitfire/synctools/mapping/contacts/ContactWriter.kt
WebDAV Documents Provider
A distinct Storage Access Framework path exposes configured WebDAV mounts as Android documents. DavDocumentsProvider delegates browse/read/write/move operations to WebDAV operations, maintains database metadata, and uses disk/thumbnail caches for file access.
• core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt
• core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt
• core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.kt
Main entry points: HttpClientBuilder.kt HTTP and security client · SyncManager.kt Sync manager · DavResourceFinder.kt DAV resource discovery · CoreApp.kt Core application
Components 19
Android app
- Android manifest entry
core/src/main/AndroidManifest.xml - Core application · Initializes shared core services.
core/src/main/kotlin/at/bitfire/davdroid/CoreApp.kt - OSE application layer
app-ose/src/main/kotlin/com/davx5/ose/App.kt - Login setup UI
core/src/main/kotlin/at/bitfire/davdroid/ui/setup/LoginActivity.kt - OAuth integrations · Provider-specific login flows.
core/src/main/kotlin/at/bitfire/davdroid/network/OAuthIntegration.kt
DAV services
- DAV resource discovery · Finds principals, home sets, and collections.
core/src/main/kotlin/at/bitfire/davdroid/servicedetection/DavResourceFinder.kt - Service refresher
core/src/main/kotlin/at/bitfire/davdroid/servicedetection/ServiceRefresher.kt - HTTP and security client · Builds authenticated secure DAV clients.
core/src/main/kotlin/at/bitfire/davdroid/network/HttpClientBuilder.kt - Remote DAV servers
Sync pipeline
- Android sync scheduling · Runs periodic and one-time synchronization.
core/src/main/kotlin/at/bitfire/davdroid/sync/adapter/SyncAdapterImpl.kt - Sync manager · Selects calendar, contacts, tasks, and JTX syncers.
core/src/main/kotlin/at/bitfire/davdroid/sync/SyncManager.kt - Android local stores
core/src/main/kotlin/at/bitfire/davdroid/resource/LocalCalendarStore.kt - Format mapping library · Maps DAV objects to Android provider entities.
synctools/src/main/kotlin/at/bitfire/synctools/icalendar/ICalendarParser.kt
Local storage
- App database · Accounts, DAV topology, sync state, and mount metadata.
core/src/main/kotlin/at/bitfire/davdroid/db/AppDatabase.kt - Account repository
core/src/main/kotlin/at/bitfire/davdroid/repository/AccountRepository.kt
WebDAV documents
- DAV documents provider · Exposes configured WebDAV mounts as Android documents.
core/src/main/kotlin/at/bitfire/davdroid/webdav/DavDocumentsProvider.kt - WebDAV mount repository
core/src/main/kotlin/at/bitfire/davdroid/webdav/WebDavMountRepository.kt - WebDAV document operations · Browses, reads, writes, and moves remote files.
core/src/main/kotlin/at/bitfire/davdroid/webdav/operation/OpenDocumentOperation.kt
Other components
- Gradle multi-module build
settings.gradle.kts
Connections 23
- Gradle multi-module build → Core application: builds
- Gradle multi-module build → OSE application layer: builds
- Android manifest entry → Core application: starts
- OSE application layer → Core application: extends core
- Core application → Account repository: initializes
- Login setup UI → OAuth integrations: authenticates through
- Login setup UI → DAV resource discovery: starts setup discovery
- Login setup UI → Account repository: manages accounts
- OAuth integrations → HTTP and security client: configures auth
- DAV resource discovery → HTTP and security client: uses
- Service refresher → DAV resource discovery: reruns
- DAV resource discovery → App database: persists topology
- Account repository → App database: reads and writes
- HTTP and security client → Remote DAV servers: secure DAV requests
- Android sync scheduling → Sync manager: executes
- Sync manager → App database: loads state and records results
- Sync manager → HTTP and security client: syncs remotely
- Sync manager → Format mapping library: parses and maps
- Format mapping library → Android local stores: translates provider data
- DAV documents provider → WebDAV mount repository: loads mounts
- WebDAV mount repository → App database: stores metadata
- DAV documents provider → WebDAV document operations: delegates file access
- WebDAV document operations → HTTP and security client: uses WebDAV client