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

Modern-Apps.git / findfamily / AGENTS.md

AGENTS.md17.7 KiBRenderedCodeRaw

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

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

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

  • Gradle: :findfamily / dir: findfamily/
  • Package roots present: ui, data, domain, platform, intents, service, sync
  • Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity) + Route.kt + Navigation.kt + ui/WearMainActivity.kt
  • Deps: :library:network, :library:e2ee-p2p, :library:room, :library:work, :library:image, :library:map, :library:aosp-stubs, :library:wearlink, Wear Compose (material + foundation)
  • Metadata: metadata_data/findfamily.md (present)
  • Rust: no / screenshotTest: yes

Relay server (backend, outside this repo)

WebSocket relay host: wss://api.maproj.org/api/ws (Cloudflare FIRSTPARTY pins). Server checkout: `../locationshareserver (sibling of this repo root, C:\Users\Vayun\Documents\code\locationshare_server). Live SSH: ssh [email protected]. Full details: root AGENTS.md` → "Backend server (outside this repo)".

Overview

Purpose: End-to-end encrypted location sharing for family and friends — no emails, phone numbers, or personal info required. Requires internet. Key features:

  • findfamily://add/<base26> invites (pairing performs no security-code or invite-fingerprint verification; a legacy k= query is ignored), and temporary links; the people page offers no per-person hide/sharing toggle, no delete-person action, and no overflow menu icon (pause sharing via the Quick Settings tile)
  • Saved places (waypoints) with enter/leave notifications plus no-show alerts driven by domain/NoShowPolicy
  • Live battery, speed, and dwell-time per person; UWB precision ranging where hardware supports it
  • Powered-off finding (BLE beacons) and a Quick Settings tile to stop sharing instantly

Architecture / data-flow: Single MainPage UI + platform/FindFamilyViewModel over data/FindFamilyRepository (Room: users, waypoints, links, no-show alerts); live location flows through util/LocationTracking* foreground service + tracker/ BLE protocol and uwb/ ranging, relayed E2EE via :library:e2ee-p2p (util/Networking*). onCreateBeforeContent: parse the add-invite deep link, then NetworkClient.init(FIRST_PARTY). Entry points + reading order: Route (MainPage / PersonSheet / WaypointSheet / PersonHistory / FirstRunSheet / AddPersonDialog / AddLinkDialog / AddTrackerDialog / MissingFeaturesDialog / NoShowAlertDialog / PermissionUpgradeDialog / UwbRangingPage) → Navigation.kt → ui/MainPage.kt → platform/FindFamilyViewModel.kt → data/FindFamilyRepository.kt. Dialogs are routes: screens push Route.…Dialog and the entry renders the stateless …Content under ui/dialogs/ unconditionally (all DialogPage()); PersonDetailSheet only requests the no-show dialog via its onShowNoShowAlert callback. Person/waypoint selection is also route-driven but is not a dialog: PersonSheet / WaypointSheet entries render MainPage, whose bottom panel (phone sheet in the repo's FreeHeightBottomSheetScaffold, expanded side panel) swaps from the family list to that route's person/waypoint content, so the map stays reachable to move a saved place by dragging it; back returns the panel to the family list. History is not a panel mode: Route.PersonHistory is a separate full screen with its own map and the history scrubber, pushed by the map's history FAB and popped by back to the live map page. Every route has a deterministic capture in src/screenshotTest (MetadataPreviews, <n>-<route-kebab>). Gotchas:

  • Location permission spec must request fine AND coarse together (Android 12+ Precise/Approximate choice; fine alone is ignored), plus background location and BLUETOOTH_SCAN — the powered-off-finder scanner starts then dies without it
  • singleTop warm-start invites/UWB taps arrive via onNewIntent, not a fresh onCreate
  • AddTrackerDialog is dev-only (DEV_BUILD custom UWB tracker binding); don't expose it in release flows
  • Extra non-conforming dirs (ipc/, tracker/, uwb/, util/) hold real code — like camera's util/, a closed-roots migration is pending
  • Upgrades from app versions before v2.6.0 start fresh: the FFDatabase floor is DB v5, pre-floor DB v1–v4 opens destructively (no data carried over), and DB v5 onward migrates normally

One APK, two form factors (phone + watch)

This module is the single FindFamily APK for phones and watches: same applicationId = "com.vayunmathur.findfamily" and signing on both, as the WearLink handshake requires. The manifest deliberately declares no android.hardware.type.watch feature (required=true would block phones; required=false is disallowed for this feature), plus 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 and watches alike. platform/FormFactor.kt reads PackageManager.FEATURE_WATCH at runtime: MainActivity (the sole launcher entry) forwards watches to ui/WearMainActivity before any phone state loads; phones get the map UI. Phone-only receivers gate on the same signal — platform/BootReceiver and platform/FixCeilingReceiver return early on a watch, so phone location sharing never starts there.

Wear sync (Watch conduit client)

Protocol: shared wire types live in :library:wearlink at com.vayunmathur.library.wearlink.findfamily.WearFindFamilyProtocol; the golden-JSON tests in this module pin the shared code's wire format. The phone stays the only E2EE endpoint: peer reports are decrypted into Room by the existing pipeline, and only the already-decrypted all-people summaries cross the conduit.

  • Snapshot + watch-state sync: conduit data items (/findfamily/snapshot phone -> watch, /findfamily/watch-state watch -> phone)
  • Ops + sync request: conduit messages (/findfamily/op stop-sharing / request-refresh, /findfamily/request-sync), watch -> phone only
  • Transport: Watch conduit client — phone side sync/WearFindFamilySync.kt and watch side sync/WearLinkBridge.kt both use WearLinkClientNode (Messenger to the Watch app's watch_conduit service, appId findfamily); 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; snapshots republish on conduit Connected and on Room changes. FormFactor picks the side at runtime, so only one of the two nodes runs on a given device.
  • Push triggers: the publish also runs on the phone Watch app's scheduled sync-trigger intent (sync/ConduitSyncTriggerReceiver, exported only under the CONDUIT signature permission, invoking WearFindFamilySync.triggerPush() — no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration.
  • Open on phone: the watch request (/<appId>/open-on-phone conduit message; camera: OPEN_ON_PHONE op) is handled live by the sync message listener when this app is registered, and otherwise the phone conduit host broadcasts OpenOnPhoneContract.ACTION (package-addressed, CONDUIT signature permission) to sync/OpenOnPhoneReceiver, which launches the main activity as a new task — no phone process needs to be running first.

Watch experience (in this module)

  • ui/WearMainActivity (a WearShellActivity, exported=false, no

launcher filter) routes ui/WearRoute over people home (every person, most-recent first) / per-person detail (precise fix age/accuracy/place + relative view) / the all-people relative map centred on the phone-supplied region. There is no vector basemap: markers plot relative to the centre, stale fixes are labelled by age, and precision is never faked.

  • Watch state persists in data/WearFindFamilyStore

(wear-findfamily-snapshot.json); presentation helpers live in domain/WearRelative.kt; the watch sync side is sync/WearLinkBridge.kt.

  • Watch listing screenshots are the group = "wear" previews in

src/screenshotTest/.../ui/WearMetadataPreviews.kt, collected by :findfamily:metadata into metadata_data/photos/findfamily/wear/; phone shots use the phone bucket.

Key files

Root — entry + navigation

  • com/vayunmathur/findfamily/MainActivity.kt — deep-link parsing, permission spec, permission-upgrade trigger
  • com/vayunmathur/findfamily/Route.kt — sealed Route destinations (bottom-panel person/waypoint routes + full-screen history and UWB screens + dialog routes)
  • com/vayunmathur/findfamily/Navigation.kt — MainNavigation entries for every route; PersonSheet/WaypointSheet render MainPage (bottom-panel host), PersonHistory renders PersonHistoryPage, the …Dialog routes use DialogPage()

data/ — Room entities + repository

  • com/vayunmathur/findfamily/data/FindFamilyRepository.kt
  • com/vayunmathur/findfamily/data/FFDatabase.kt
  • com/vayunmathur/findfamily/data/User.kt
  • com/vayunmathur/findfamily/data/Waypoint.kt
  • com/vayunmathur/findfamily/data/TemporaryLink.kt
  • com/vayunmathur/findfamily/data/NoShowAlert.kt
  • com/vayunmathur/findfamily/data/NoShowAlertDao.kt
  • com/vayunmathur/findfamily/data/Coord.kt
  • com/vayunmathur/findfamily/data/LocationValue.kt
  • com/vayunmathur/findfamily/data/DirectBootStore.kt
  • com/vayunmathur/findfamily/data/FindFamilyDbBackupCodec.kt — platform-backup codec: SqlCipherDbCodec export/import plus plaintext-export sanitization (see domain/PlatformBackup.kt)

domain/ — pairing auth, no-show policy, sender movement policy (pure logic)

  • com/vayunmathur/findfamily/domain/PlatformBackup.kt — stock-OS backup contract (FindFamilyPlatformBackup): sanitized DB-only agent payload, identity/pairing/link secrets never backed up, restored people re-pair via Add Person
  • com/vayunmathur/findfamily/domain/PairAuth.kt
  • com/vayunmathur/findfamily/domain/NoShowPolicy.kt
  • com/vayunmathur/findfamily/domain/MovementDetector.kt — sender moving/still state machine (acceleration + fix speed + displacement)
  • com/vayunmathur/findfamily/domain/ForcedFixPolicy.kt — when a "still" sender forces a one-off fix

sync/ — wear companion (both sides in this APK)

  • com/vayunmathur/findfamily/sync/WearFindFamilySync.kt — phone conduit client node; all-people snapshot publish from decrypted Room state, watch-state receive, request-sync + op handling
  • com/vayunmathur/findfamily/sync/WearLinkBridge.kt — watch conduit client node; snapshot receive into data/WearFindFamilyStore, watch-state publish, stop-sharing/refresh/request-sync messages to the phone

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

  • com/vayunmathur/findfamily/ui/WearMainActivity.kt — watch entry (WearShellActivity, exported=false)
  • com/vayunmathur/findfamily/ui/WearRoute.kt, WearPeopleScreen.kt, WearPersonScreen.kt, WearAllMapScreen.kt, WearRelativeCanvas.kt
  • com/vayunmathur/findfamily/data/WearFindFamilyStore.kt
  • com/vayunmathur/findfamily/domain/WearRelative.kt

intents/ — assistant IPC

  • com/vayunmathur/findfamily/intents/GetIntent.kt
  • com/vayunmathur/findfamily/intents/CreateLinkIntent.kt

ipc/ — cross-app family-location protocol

  • com/vayunmathur/findfamily/ipc/FamilyLocationProtocol.kt
  • com/vayunmathur/findfamily/ipc/FamilyLocationService.kt

platform/ — reporters + schedulers

  • com/vayunmathur/findfamily/platform/AppBackupAgent.kt — stock-OS backup agent (manifest backupAgent): sanitized passwords-db only via data/FindFamilyDbBackupCodec; no DataStore/prefs/files; raw DB + secure_prefs + identity DataStore excluded by res/xml/data_extraction_rules.xml on both channels
  • com/vayunmathur/findfamily/platform/FormFactor.kt — watch detection (FEATURE_WATCH) for the single merged APK
  • com/vayunmathur/findfamily/platform/FinalLocationReporter.kt
  • com/vayunmathur/findfamily/platform/NoShowCheckScheduler.kt
  • com/vayunmathur/findfamily/platform/PoweredOffBeacon.kt
  • com/vayunmathur/findfamily/platform/LocationKeepAlive.kt — sender keep-alive: single fix intake, low-power/passive requests, forced fix

service/ — Quick Settings tile

  • com/vayunmathur/findfamily/service/SharingTileService.kt

tracker/ — BLE tracker protocol + powered-off finding

  • com/vayunmathur/findfamily/tracker/TrackerProtocol.kt
  • com/vayunmathur/findfamily/tracker/TrackerBle.kt
  • com/vayunmathur/findfamily/tracker/TrackerProvisioner.kt
  • com/vayunmathur/findfamily/tracker/TrackerStore.kt
  • com/vayunmathur/findfamily/tracker/TrackerReporting.kt
  • com/vayunmathur/findfamily/tracker/TrackerFeature.kt
  • com/vayunmathur/findfamily/tracker/TrackerBeaconScanner.kt
  • com/vayunmathur/findfamily/tracker/TrackerBinder.kt
  • com/vayunmathur/findfamily/tracker/TrackerUwbGatt.kt
  • com/vayunmathur/findfamily/tracker/TrackerUwbKeys.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffProtocol.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffBle.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffScanner.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffReporting.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffRecovery.kt
  • com/vayunmathur/findfamily/tracker/PoweredOffKeyStore.kt

uwb/ — UWB ranging stack

  • com/vayunmathur/findfamily/uwb/UwbController.kt
  • com/vayunmathur/findfamily/uwb/UwbEnvelope.kt
  • com/vayunmathur/findfamily/uwb/UwbInbox.kt
  • com/vayunmathur/findfamily/uwb/UwbAccessoryProtocol.kt

ui/ — main page + dialogs + UWB screen

  • com/vayunmathur/findfamily/ui/MainPage.kt
  • com/vayunmathur/findfamily/ui/MainPageContent.kt
  • com/vayunmathur/findfamily/ui/MainPageActions.kt
  • com/vayunmathur/findfamily/ui/MainPageCards.kt
  • com/vayunmathur/findfamily/ui/MainPageEffects.kt
  • com/vayunmathur/findfamily/ui/MainPageOverlays.kt
  • com/vayunmathur/findfamily/ui/MainMapSlot.kt
  • com/vayunmathur/findfamily/ui/MainSheetContent.kt
  • com/vayunmathur/findfamily/ui/MapView.kt
  • com/vayunmathur/findfamily/ui/MainFabOverlay.kt — history FAB over the map (selected person only; pushes Route.PersonHistory; the history screen itself shows no FAB)
  • com/vayunmathur/findfamily/ui/MainPageOverlays.kt — transparent TopAppBarOverlay over the map: back button for a selection plus the Find Nearby action for a selected non-self UWB person and the GPS warning
  • com/vayunmathur/findfamily/ui/FamilyListSheet.kt
  • com/vayunmathur/findfamily/ui/PersonDetailSheet.kt
  • com/vayunmathur/findfamily/ui/PersonSheet.kt — bottom-panel person detail content for Route.PersonSheet, hosted by MainPage's panel, not a dialog; Find Nearby is an action in the map's transparent top bar and entering history is the history FAB over the map
  • com/vayunmathur/findfamily/ui/PersonHistoryPage.kt — full-screen history for Route.PersonHistory: its own pannable map centred on the scrubbed position plus the history scrubber; back pops to the live map
  • com/vayunmathur/findfamily/ui/PersonHistoryContent.kt — stateless history page layout (scaffold + map/scrubber slots) for previews
  • com/vayunmathur/findfamily/ui/WaypointSheet.kt — bottom-panel saved-place editor for Route.WaypointSheet (name/range/delete; place moves with the map centre), hosted by MainPage's panel, not a dialog
  • com/vayunmathur/findfamily/ui/UserCard.kt
  • com/vayunmathur/findfamily/ui/UserPicture.kt — face icons via peopleFaceRequest: stable SHA-256 memory+disk cache keys and explicit decode size through :library:image, so scrolling the people list does not refetch/re-decode faces
  • com/vayunmathur/findfamily/ui/AutoToggleRow.kt
  • com/vayunmathur/findfamily/ui/FindFamilyWideLayout.kt
  • com/vayunmathur/findfamily/ui/UwbRangingScreen.kt
  • com/vayunmathur/findfamily/ui/dialogs/AddPersonDialog.kt — also hosts decodeBase26; stateless AddPersonContent for previews
  • com/vayunmathur/findfamily/ui/dialogs/AddLinkDialog.kt — stateless AddLinkContent for previews
  • com/vayunmathur/findfamily/ui/dialogs/AddTrackerDialog.kt — dev-only; stateless AddTrackerContent for previews
  • com/vayunmathur/findfamily/ui/dialogs/NoShowAlertDialog.kt — stateless NoShowAlertContent for previews
  • com/vayunmathur/findfamily/ui/dialogs/GpsFallbackWarningDialog.kt
  • com/vayunmathur/findfamily/ui/dialogs/KeyMismatchDialog.kt
  • com/vayunmathur/findfamily/ui/dialogs/OutdatedPeerDialog.kt

util/ — ViewModel, tracking service, networking

  • com/vayunmathur/findfamily/util/FindFamilyViewModel.kt
  • com/vayunmathur/findfamily/util/FindFamilyUiContract.kt
  • com/vayunmathur/findfamily/util/MapPageState.kt
  • com/vayunmathur/findfamily/util/LocationTrackingService.kt
  • com/vayunmathur/findfamily/util/LocationServiceController.kt
  • com/vayunmathur/findfamily/util/LocationTrackingHeartbeat.kt
  • com/vayunmathur/findfamily/util/LocationTrackingInbound.kt
  • com/vayunmathur/findfamily/util/LocationTrackingDirectBoot.kt
  • com/vayunmathur/findfamily/util/LocationTrackingCrowdFinding.kt
  • com/vayunmathur/findfamily/util/LocationTrackingNotifications.kt
  • com/vayunmathur/findfamily/util/LocationProviderStatus.kt
  • com/vayunmathur/findfamily/util/Networking.kt
  • com/vayunmathur/findfamily/util/NetworkingLive.kt
  • com/vayunmathur/findfamily/util/NetworkingHelper.kt
  • com/vayunmathur/findfamily/util/NetworkingTracker.kt
  • com/vayunmathur/findfamily/util/UwbSessionManager.kt
  • com/vayunmathur/findfamily/util/Platform.kt
  • com/vayunmathur/findfamily/util/FindFamilyNotificationChannels.kt
  • com/vayunmathur/findfamily/util/TrackingTileService.kt
  • com/vayunmathur/findfamily/util/BootReceiver.kt

Verify (this module only)

./gradlew :findfamily:compileDevKotlin
./gradlew :findfamily:lint
./gradlew :findfamily:checkMetadata
  • Wear Tile: service/FindFamilyTileService (a MaTileService in :library:weartiles) renders the nearest person's distance from self (freshest person when no self fix) from WearFindFamilyStore; the store requests a tile update on every new snapshot, plus 15-minute freshness. Tap opens WearMainActivity.