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

Modern-Apps.git / watch / AGENTS.md

AGENTS.md2.9 KiBRenderedCodeRaw
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
14messaging app on the phone. It is the only phone app that holds
15Bluetooth permissions and the only one that owns a real
16`WearLinkNode` (appId `watch_conduit`, in `service/ConduitService`
17via `ConduitHost` in `:library:wearlink`). Every other app reaches
18the watch through `WearLinkClientNode` bound to this app's conduit
19service.
20**Architecture / data-flow:** `service/ConduitService` (foreground,
21`connectedDevice`) hosts `ConduitHost` -> `ConduitRouter`, which
22routes by first path segment between local Messenger clients and
23the peer. `platform/BootReceiver` restarts it on boot/replacement.
24The single status screen renders `ConduitRuntime.state` (link state,
25registered apps, per-app counters) and offers the Bluetooth
26permission grant.
27**Scheduled push sync:** `service/ConduitSyncScheduler` (started by
28`ConduitService`) discovers sync-capable apps from the package
29manager (broadcast receivers answering `ConduitSync.ACTION` under
30the `CONDUIT` signature permission, via the manifest `<queries>`
31entry for that action), merged with the persisted registration
32registry (`ConduitSyncRegistry`, a supplement naming appIds for
33registered packages), and fires the `ConduitSync.ACTION` intent at
34each app on three triggers: the RFCOMM link connecting, a phone app
35registering, and `service/ConduitSyncWorker`'s 15-minute WorkManager
36period. Manifest receivers wake apps that have never run since
37install/reboot. Absent apps are tolerated; the intent carries only
38the 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```