Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / appstore / AGENTS.md

AGENTS.md13.3 KiBRenderedCodeRaw

AGENTS.md — appstore/ (':appstore')

Scoped supplement. Global rules in root AGENTS.md apply. Stay inside appstore/ + allowed shared modules. Do not root-scan.

Install: ./install appstore (dev by default).

  • Gradle: :appstore / dir: appstore/
  • Package roots present: ui, data, domain, platform, intents, sync
  • Entry files: MainActivity.kt (sole phone/TV launcher; routes watches to WearMainActivity), Route.kt (home/library/search/sources/trust/updates tabs + Detail/Browse/Screenshots/UninstallDialog pushed routes), ui/WearMainActivity.kt
  • Deps: :library:room, :library:network, :library:work, :library:image, :library:tv, :library:wearlink, :library:log, Wear Compose (material + foundation)
  • Metadata: metadata_data/appstore.md (present)
  • Rust: yes / screenshotTest: yes

Overview

Purpose: Security-first app store — six sources (own repo, curated mirror, F-Droid, GrapheneOS, Accrescent, Play) with every download signature-checked and a plain-language security tier per app (who could push a malicious update). Key features:

  • Multi-source catalogs: F-Droid (developer-signed reproducible builds only — apps signed with an F-Droid-held per-app key are never imported), Accrescent (Signify trust), anonymous Play (no Google account), GrapheneOS bundle one-tap
  • Top filters filter by source (search/library) or category (home); there is no TV filter chip — catalogue results are limited to TV-compatible apps only when the device itself is a TV (DeviceAttributesProvider.isTv, applied by CatalogRepository on every read)
  • Install pipeline: InstallCoordinator → SessionInstaller → InstallStatusReceiver, verified by InstallVerifier (APK certs, signed-jar index, source stamps) before the system installer sees anything
  • UpdateCheckWorker background checks; outdated-target-API apps refused, not hidden
  • OpenAssistant tools (read-only, in intents/ behind the signature ACCESS_APPSTORE permission): appstore_search_apps searches the local catalogue (query, limit clamped to 10, summary capped at 120 chars) and appstore_get_updates returns an update count plus at most 10 app names; no install/update/uninstall action is exposed

Architecture / data-flow: ui/ home/search/detail/library/updates/sources/trust (+ ui/dialogs/ stateless dialog contents for the Route.UninstallDialog / TV UninstallDialog routes) → platform/AppStoreViewModel (+ per-area *Ops, AppStoreUiContract) → data/ providers per source (*Repository, Play/F-Droid/Accrescent clients) + data/installer/ + data/security/; domain/SearchRanking is pure ranking. The F-Droid provider additionally downloads the same repo's signed index-v1.jar (FDroidAllowedSigners in data/FDroidVerification.kt, verified against the descriptor's pinned fingerprint and streamed, not loaded whole) and drops every F-Droid app whose advertised version signer is not one of that package's allowedAPKSigningKeys before any row is written — index-v2 alone cannot tell a developer key from an F-Droid-generated per-app key. That gate is F-Droid-only; the other F-Droid-format repos keep their own trust rules. Repo addresses: our own F-Droid-format repos are consumed from the static R2 bucket — DefaultRepos.MODERN_APPS = https://static.maproj.org/fdroid/repo, DefaultRepos.PROPRIETARY = https://static.maproj.org/proprietary/repo (same signed indexes/APKs the server publishes on every build; signing fingerprint pinned as before). The legacy origin addresses (maproj.org/fdroid/repo, maproj.org/proprietary/repo) keep serving external F-Droid clients and are named only as LEGACY_*_ORIGIN_URL constants: stored repo records and cached rows are keyed by URL, so CatalogRepository.ensureDefaultRepos prunes rows written under the old addresses and the next sync re-imports under the static ones (no double-added repos). Entry points + reading order: MainActivity.kt → Route.kt → ui/AppRoot.kt → ui/HomePage.kt → platform/AppStoreViewModel.kt → data/CatalogRepository.kt → data/installer/InstallCoordinator.kt → data/security/InstallVerifier.kt.

One APK, three form factors (phone + TV + watch)

This module is the single App Store APK for phones, TVs and watches: same applicationId = "com.vayunmathur.appstore" and signing on all three, as the conduit signature check requires. The manifest deliberately declares no android.hardware.type.watch feature (required=true would block phones; required=false is disallowed for this feature), plus leanback/touchscreen not-required and com.google.android.wearable.standalone=false; distribution is sideload/F-Droid, not Play's watch channel, so the APK installs on phones, TVs and watches alike. platform/FormFactor.kt reads PackageManager.FEATURE_WATCH at runtime: MainActivity (the sole phone/TV launcher entry) forwards watches to ui/WearMainActivity before any phone state loads; phones/TVs get the store UI (TV via ui/tv/TvMainActivity). Form-factor receivers gate the same way — data/installer/InstallStatusReceiver (phone/TV) and platform/InstallResultReceiver (watch) each early-return on the wrong form factor.

Wear sync (Watch conduit client)

Protocol: shared wire types live in :library:wearlink at com.vayunmathur.library.wearlink.appstore.WearSyncProtocol; the golden-JSON test in domain/WearSyncProtocolTest pins the shared code's wire format.

  • Catalog + watch-state sync: conduit data items (/appstore/catalog, /appstore/watch-state)
  • Offers / install requests / results: conduit messages; APK bytes: conduit stream (/appstore/apk/<package>), verified size+SHA-256 against the preceding offer before PackageInstaller ever sees them
  • Transport: Watch conduit client — phone side sync/WearSyncManager and watch side sync/WearLinkBridge both use WearLinkClientNode (Messenger to the Watch app's watch_conduit service, appId appstore); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reports NotInstalled/Unavailable and the sync stays idle; the catalog and watch state republish on conduit Connected. Delivery is app-lifecycle-bound — no system listener wakes a dead process. FormFactor picks the side at runtime.

Watch experience (in this module)

  • ui/WearMainActivity (a WearShellActivity, exported=false, entered only via MainActivity's watch routing) is the whole watch store: one scrolling catalog/install list reading only the watch's persisted state, so it works standalone with whatever has already been downloaded.
  • Watch state persists in data/WearStore (wear-catalog.json / wear-phases.json, verified APKs under wear-apks/); platform/WearInstaller hands a verified APK to PackageInstaller and platform/InstallResultReceiver forwards the system prompt and reports the verdict.
  • A normal Wear OS app cannot silently install: verified APKs wait in app-private storage until the wearer taps Install and confirms the system PackageInstaller prompt. No state may claim otherwise.
  • Watch listing screenshots are the group = "wear" previews in src/screenshotTest/.../ui/WearMetadataPreviews.kt, collected by :appstore:metadata into metadata_data/photos/appstore/wear/; phone shots use the phone bucket.

Gotchas:

  • Signature verification is the product — never shortcut it for UX; trust-profile changes need adversarial review
  • Anonymous Play auth sessions are fragile by nature; isolate Play failures from other sources
  • Upgrades from app versions before v2.6.0 start fresh: the AppDatabase floor is DB v3 (the first AppStore database shipped, in app v2.6.4, so no released pre-v2.6.0 database exists), pre-floor DB v1–v2 opens destructively (no data carried over), and DB v3 onward migrates normally

Key files

Root — entry

  • com/vayunmathur/appstore/MainActivity.kt
  • com/vayunmathur/appstore/Route.kt

data/ — catalog, providers, installer, security

  • com/vayunmathur/appstore/data/CatalogRepository.kt
  • com/vayunmathur/appstore/data/AppProvider.kt
  • com/vayunmathur/appstore/data/AppModels.kt
  • com/vayunmathur/appstore/data/AppDatabase.kt
  • com/vayunmathur/appstore/data/AppStoreDatabaseRepository.kt
  • com/vayunmathur/appstore/data/AppStoreDbBackupCodec.kt — backup codec: SQLCipher plaintext round-trip with the re-derivable CachedAppEntity catalogue stripped (repos, stamp pins and Accrescent allowlist survive)
  • com/vayunmathur/appstore/platform/AppBackupAgent.kt — key/value BackupAgent (DB via the codec + appstore-settings/accrescentrepodata DataStores; playauth, all SharedPreferences and wear files excluded); raw DB excluded in res/xml/dataextractionrules.xml on both channels
  • com/vayunmathur/appstore/data/InstalledAppsRepository.kt
  • com/vayunmathur/appstore/data/SettingsRepository.kt
  • com/vayunmathur/appstore/data/UpdateCheckWorker.kt
  • com/vayunmathur/appstore/data/FDroidRepository.kt
  • com/vayunmathur/appstore/data/FDroidAppProvider.kt
  • com/vayunmathur/appstore/data/FDroidVerification.kt
  • com/vayunmathur/appstore/data/accrescent/AccrescentRepository.kt
  • com/vayunmathur/appstore/data/accrescent/AccrescentRepo.kt
  • com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.kt
  • com/vayunmathur/appstore/data/accrescent/AccrescentApi.kt
  • com/vayunmathur/appstore/data/accrescent/AccrescentTrustStore.kt
  • com/vayunmathur/appstore/data/accrescent/DeviceAttributesProvider.kt
  • com/vayunmathur/appstore/data/accrescent/SignifyNative.kt — Rust Signify bridge
  • com/vayunmathur/appstore/data/play/PlayRepository.kt
  • com/vayunmathur/appstore/data/play/PlayStoreApi.kt
  • com/vayunmathur/appstore/data/play/PlayHttpClient.kt
  • com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt
  • com/vayunmathur/appstore/data/play/DeviceInfoProvider.kt
  • com/vayunmathur/appstore/data/play/GsfVersionProvider.kt
  • com/vayunmathur/appstore/data/play/EglExtensionProvider.kt
  • com/vayunmathur/appstore/data/play/CertUtil.kt
  • com/vayunmathur/appstore/data/play/PlayDownloader.kt
  • com/vayunmathur/appstore/data/installer/InstallCoordinator.kt
  • com/vayunmathur/appstore/data/installer/SessionInstaller.kt
  • com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt
  • com/vayunmathur/appstore/data/security/InstallVerifier.kt
  • com/vayunmathur/appstore/data/security/ApkCertificates.kt
  • com/vayunmathur/appstore/data/security/SignedJarIndex.kt
  • com/vayunmathur/appstore/data/security/SourceStamp.kt
  • com/vayunmathur/appstore/data/security/TrustProfile.kt
  • com/vayunmathur/appstore/data/security/Signify.kt
  • com/vayunmathur/appstore/data/PlayStoreLinks.kt
  • com/vayunmathur/appstore/data/RestrictedPackages.kt

intents/ — validated OpenAssistant contracts (read-only)

  • com/vayunmathur/appstore/intents/SearchAppsIntent.kt
  • com/vayunmathur/appstore/intents/GetUpdatesIntent.kt
  • com/vayunmathur/appstore/intents/AppStoreAssistantBackend.kt — backend seam over CatalogRepository.searchLocal/updatesFor + the provider-side caps

domain/ — pure ranking (no Android)

  • com/vayunmathur/appstore/domain/SearchRanking.kt

sync/ — wear sync (both sides)

  • com/vayunmathur/appstore/sync/WearSyncManager.kt — phone side: catalog publish, APK offer/stream, install requests
  • com/vayunmathur/appstore/sync/WearLinkBridge.kt — watch side: catalog/offer/stream receive, watch-state publish, install results

platform/ — ViewModel + per-area ops

  • com/vayunmathur/appstore/platform/FormFactor.kt — watch detection (FEATURE_WATCH)
  • com/vayunmathur/appstore/platform/AppStoreViewModel.kt
  • com/vayunmathur/appstore/platform/AppStoreUiContract.kt
  • com/vayunmathur/appstore/platform/AppStoreHomeOps.kt
  • com/vayunmathur/appstore/platform/AppStoreSearchOps.kt
  • com/vayunmathur/appstore/platform/AppStoreDetailOps.kt
  • com/vayunmathur/appstore/platform/AppStoreUpdateOps.kt
  • com/vayunmathur/appstore/platform/AppStoreActionOps.kt

ui/ — store pages

  • com/vayunmathur/appstore/ui/HomePage.kt
  • com/vayunmathur/appstore/ui/SearchPage.kt
  • com/vayunmathur/appstore/ui/AppDetailPage.kt
  • com/vayunmathur/appstore/ui/AppDetailHeader.kt
  • com/vayunmathur/appstore/ui/AppDetailSections.kt
  • com/vayunmathur/appstore/ui/ScreenshotViewerScreen.kt — full-screen swipe/zoom screenshot viewer (Route.Screenshots)
  • com/vayunmathur/appstore/ui/AppTile.kt
  • com/vayunmathur/appstore/ui/AppComponents.kt
  • com/vayunmathur/appstore/ui/AppMeta.kt
  • com/vayunmathur/appstore/ui/LibraryPage.kt
  • com/vayunmathur/appstore/ui/UpdatesPage.kt
  • com/vayunmathur/appstore/ui/SourcesPage.kt
  • com/vayunmathur/appstore/ui/SourcesScreen.kt — stateless sources screen (previews/tests)
  • com/vayunmathur/appstore/ui/TrustPage.kt
  • com/vayunmathur/appstore/ui/dialogs/UninstallDialog.kt — Route.UninstallDialog content
  • com/vayunmathur/appstore/ui/dialogs/TvUninstallDialog.kt — TV UninstallDialog content

Watch experience (ui/ + platform/ + data/)

  • com/vayunmathur/appstore/ui/WearMainActivity.kt — watch entry (WearShellActivity, exported=false)
  • com/vayunmathur/appstore/platform/WearInstaller.kt — verified-APK PackageInstaller handoff (user confirmation required)
  • com/vayunmathur/appstore/platform/InstallResultReceiver.kt — watch PackageInstaller verdicts (gated to watches)
  • com/vayunmathur/appstore/data/WearStore.kt — watch catalog/phases/APK store

Verify (this module only)

./gradlew :appstore:compileDevKotlin
./gradlew :appstore:lint
./gradlew :appstore:checkMetadata