# 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 FIRST_PARTY pins). Server checkout: `../location_share_server` (sibling of this repo root, `C:\Users\Vayun\Documents\code\location_share_server`). Live SSH: `ssh root@87.86.80.39`. 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/` invites with key-fingerprint check, 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` / sheets / `AddPersonDialog` / `AddLinkDialog` / `AddTrackerDialog` / `MissingFeaturesDialog` / `SecurityCodeDialog` / `NoShowAlertDialog` / `PermissionUpgradeDialog` / `UwbRangingPage`, all `DialogPage()` except the two full screens) → `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/` (or the sheet content) unconditionally; `PersonDetailSheet` only requests the no-show dialog via its `onShowNoShowAlert` callback. Every route has a deterministic capture in `src/screenshotTest` (`MetadataPreviews`, `-`). **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. ## 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 (sheets + dialog routes + UWB screen) - com/vayunmathur/findfamily/Navigation.kt — `MainNavigation` entries for every route ### 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 - com/vayunmathur/findfamily/ui/FamilyListSheet.kt - com/vayunmathur/findfamily/ui/PersonDetailSheet.kt - 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 - com/vayunmathur/findfamily/ui/dialogs/SecurityCodeDialog.kt — stateless `SecurityCodeContent` for previews ### 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 ```