Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / watch / AGENTS.md
| 1 | # AGENTS.md — watch/ (':watch') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. |
| 4 | |
| 5 | - Gradle: :watch / dir: watch/ |
| 6 | - Package roots present: ui, platform, service |
| 7 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt |
| 8 | - Deps: :library:wearlink |
| 9 | - Metadata: metadata_data/watch.md (present) |
| 10 | - Rust: no / screenshotTest: yes |
| 11 | |
| 12 | ## Overview |
| 13 | **Purpose:** Phone half of the Watch conduit — the sole phone<->watch |
| 14 | messaging app on the phone. It is the only phone app that holds |
| 15 | Bluetooth permissions and the only one that owns a real |
| 16 | `WearLinkNode` (appId `watch_conduit`, in `service/ConduitService` |
| 17 | via `ConduitHost` in `:library:wearlink`). Every other app reaches |
| 18 | the watch through `WearLinkClientNode` bound to this app's conduit |
| 19 | service. |
| 20 | **Architecture / data-flow:** `service/ConduitService` (foreground, |
| 21 | `connectedDevice`) hosts `ConduitHost` -> `ConduitRouter`, which |
| 22 | routes by first path segment between local Messenger clients and |
| 23 | the peer. `platform/BootReceiver` restarts it on boot/replacement. |
| 24 | The single status screen renders `ConduitRuntime.state` (link state, |
| 25 | registered apps, per-app counters) and offers the Bluetooth |
| 26 | permission grant. |
| 27 | **Scheduled push sync:** `service/ConduitSyncScheduler` (started by |
| 28 | `ConduitService`) discovers sync-capable apps from the package |
| 29 | manager (broadcast receivers answering `ConduitSync.ACTION` under |
| 30 | the `CONDUIT` signature permission, via the manifest `<queries>` |
| 31 | entry for that action), merged with the persisted registration |
| 32 | registry (`ConduitSyncRegistry`, a supplement naming appIds for |
| 33 | registered packages), and fires the `ConduitSync.ACTION` intent at |
| 34 | each app on three triggers: the RFCOMM link connecting, a phone app |
| 35 | registering, and `service/ConduitSyncWorker`'s 15-minute WorkManager |
| 36 | period. Manifest receivers wake apps that have never run since |
| 37 | install/reboot. Absent apps are tolerated; the intent carries only |
| 38 | the appId. |
| 39 | **Entry points + reading order:** `Route` (`Status`) → `MainActivity.kt` |
| 40 | → `Navigation.kt` → `ui/WatchStatusScreen.kt`; service side: |
| 41 | `service/ConduitService.kt` → `:library:wearlink` conduit package. |
| 42 | **Gotchas:** |
| 43 | - `applicationId com.vayunmathur.watch` and the signing key are shared |
| 44 | with `:watch:wear` on purpose: the handshake token and the |
| 45 | `com.vayunmathur.watch.permissions.CONDUIT` signature permission |
| 46 | both require one identity. |
| 47 | - Do not add Bluetooth permissions anywhere else. wearlink declares |
| 48 | none; this app and :watch:wear are the only Bluetooth holders. |
| 49 | |
| 50 | ## Key files |
| 51 | ### Root — entry + navigation |
| 52 | - com/vayunmathur/watch/MainActivity.kt |
| 53 | - com/vayunmathur/watch/Navigation.kt |
| 54 | - com/vayunmathur/watch/Route.kt |
| 55 | ### service/ — conduit host |
| 56 | - com/vayunmathur/watch/service/ConduitService.kt |
| 57 | ### platform/ — boot restart |
| 58 | - com/vayunmathur/watch/platform/BootReceiver.kt |
| 59 | ### ui/ — status screen |
| 60 | - com/vayunmathur/watch/ui/WatchStatusScreen.kt |
| 61 | |
| 62 | ## Verify (this module only) |
| 63 | ``` |
| 64 | ./gradlew :watch:compileDevKotlin |
| 65 | ./gradlew :watch:lint |
| 66 | ./gradlew :watch:checkMetadata |
| 67 | ``` |