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

Modern-Apps.git / communicate / AGENTS.md

AGENTS.md11.5 KiBRenderedCodeRaw
1# AGENTS.md — communicate/ (':communicate')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `communicate/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install communicate (dev by default)._
6- Gradle: :communicate / dir: communicate/
7- Package roots present: ui, data, domain, intents, service, telephony, notifications, sync
8- Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt, ui/WearMainActivity.kt
9- Deps: :library:network, :library:image, :library:room, :library:aosp-stubs (compileOnly), :library:wearlink, :library:log, Wear Compose (material + foundation)
10- Metadata: metadata_data/communicate.md (present)
11- Rust: no (both crates live in `:communicate-dev`) / screenshotTest: yes
12
13## Overview
14**Purpose:** Multi-line messenger + dialer: SIM (SMS/MMS/calls), Google Voice, WhatsApp, Signal and RCS lines unified in one conversation list, with E2EE on the closed-loop lines. Requires internet + telephony permissions.
15**Key features:**
16- Five lines behind one `CommunicateLine` model: SIM via framework telephony, Google Voice (protojson RPC + SIP-over-WSS), WhatsApp primary client (Noise + Double Ratchet), Signal (libsignal + Rust protocol), RCS (SIP/MSRP + MLS E2EE)
17- In-app calling over WebRTC/RingRTC for the internet lines; framework `InCallService`/`ConnectionService` for SIM + Google Voice telecom integration
18- Android Auto car templates (`service/car/`), assistant send/read intents, voicemail tab with plain ExoPlayer playback
19**Architecture / data-flow:** `ui/` tabs + conversation screens → `data/CommunicateRepository*` (per-line splits: `Sim`, `Send`, `Merged` in `src/main`; `Rcs`, `RcsGroup`, `Signal`, `WhatsApp`, `WhatsAppCalls` in `src/dev` over `:communicate-dev`, with no-op counterparts in `src/release`) over the SIM/GV providers; WhatsApp/Signal/RCS data, transports, Room DBs, protos, and Rust crates live in `:communicate-dev` (linked `devImplementation` only). `telephony/` in `src/main` owns SIM/GV framework services; the WA/Signal/RCS sync services and in-app Telecom glue live in `src/dev/telephony/` with their manifest entries in `:communicate-dev`. Shared-code line dispatch goes through the variant seam files (`data/LineRepositorySeam.kt`, `ui/LineUiSeam.kt` plus its one-composable-per-file splits `ui/rememberSignalSignedIn.kt`, `ui/remember{WhatsApp,Signal}Account.kt`, `ui/rememberRcsStatusText.kt`, `ui/rememberDevLineChoices.kt`, `ui/LineSyncEffects.kt`, and `ui/AppTelecomEffects.kt`, each in `src/dev` + `src/release`). There is no `platform/` or `network/` root in this module; don't create those roots here.
20**Entry points + reading order:** `Route` (`Messages` / `Dialer` / `CallLogs` / `Accounts` / `Conversation(threadId, …)` / `Call` / registration wizards) → `MainActivity.kt` → `Navigation.kt` → `ui/MessagesScreen.kt` → `data/CommunicateRepository.kt`.
21
22## One APK, two form factors (phone + watch)
23This module is the single Communicate APK for phones and watches: same
24`applicationId = "com.vayunmathur.communicate"` and signing on both, as
25the WearLink handshake requires. The manifest deliberately declares no
26`android.hardware.type.watch` feature (required=true would block
27phones; required=false is disallowed for this feature), plus
28touchscreen not-required and
29`com.google.android.wearable.standalone=false`; distribution is
30sideload/F-Droid, not Play's watch channel, so the APK installs on
31phones and watches alike. `ui/FormFactor.kt` reads
32`PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the sole
33launcher entry) forwards watches to `ui/WearMainActivity` before any
34phone state loads; phones get the tab UI. The phone telephony
35receivers (`telephony/SmsDeliverReceiver`, `telephony/MmsDeliverReceiver`)
36early-return on a watch — a watch has no default-SMS role and receives
37its messages over the Watch conduit.
38
39## Wear sync (Watch conduit client)
40**Protocol:** shared wire types live in `:library:wearlink` at `com.vayunmathur.library.wearlink.communicate.WearCommunicateProtocol`; this module's golden-JSON test pins the shared code's wire format.
41- Snapshot + watch-state sync: conduit data items (`/communicate/snapshot` phone -> watch, `/communicate/watch-state` watch -> phone)
42- Thread pages, new-message/incoming-call alerts, and watch ops with phone verdicts: conduit messages (see the protocol file for paths and caps)
43- **Transport: Watch conduit client** — phone side `data/WearCommunicateSync.kt` and watch side `sync/WearLinkBridge.kt` both use `WearLinkClientNode` (Messenger to the Watch app's `watch_conduit` service, appId `communicate`); 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`. `FormFactor` picks the side at runtime, so only one of the two nodes runs on a given device. Delivery is app-lifecycle-bound; the watch keeps ops pending and resends on reconnect.
44
45## Watch experience (in this module)
46- `ui/WearMainActivity` (a `WearShellActivity`) routes `ui/WearRoute` over the conversation list / thread (paged, cached offline) / quick reply / call log (read-only) / voicemail indicators / phone-only explanation; an incoming-call overlay offers Decline only (no answer-on-watch: watch audio routing is not guaranteed).
47- Watch state persists in `data/WearCommunicateStore` (snapshot, thread-page and pending-op JSON files).
48- Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:communicate:metadata` into `metadata_data/photos/communicate/wear/`.
49**Gotchas:**
50- Both Rust crates (`communicate_signal`, `communicate_mls`) and their guarded wrappers live in `:communicate-dev`; never call them unguarded and never merge the crates (own dependency trees).
51- Protobuf is hand-rolled in `:communicate-dev` (AGP 9 breaks both Wire and protobuf Gradle plugins): its `build.gradle.kts` resolves `protoc` from Maven and runs `GenerateProtoTask` over its `src/main/proto/` (11 Signal/WhatsApp protos) — don't add a proto plugin.
52- RingRTC is the ONLY WebRTC distribution allowed on the classpath (it bundles `org.webrtc` and binds it via JNI names); never add another WebRTC dep. libsignal desktop natives (`*.dylib`/`*.dll`) and `libsignal_jni_testing.so` are stripped in packaging — keep those excludes.
53- `:library:aosp-stubs` is `compileOnly` only (framework `@SystemApi` RCS/backup transport stubs) — it must never be packaged.
54- Registration wizards are route sub-stacks (`Route.WhatsAppRegistration`, `Route.SignalRegistration`) carrying cc/number in arguments; reaching `Done` replaces the sub-stack — keep step state in route args, not in held selection state.
55- Car code (`service/car/`) is the only car-app-library consumer here; phone UI, sync services and crypto paths must stay car-free.
56
57## Key files
58### Root — entry + navigation
59- com/vayunmathur/communicate/MainActivity.kt
60- com/vayunmathur/communicate/Navigation.kt
61- com/vayunmathur/communicate/Route.kt
62### data/ — unified repository (per-line splits)
63- com/vayunmathur/communicate/data/CommunicateModels.kt
64- com/vayunmathur/communicate/data/CommunicateRepository.kt
65- com/vayunmathur/communicate/data/CommunicateRepositoryMerged.kt — plus per-line splits (`Sim`, `Send`, `Rcs`, `Signal`, `WhatsApp`)
66- com/vayunmathur/communicate/data/SimManager.kt
67- com/vayunmathur/communicate/data/SecretSealer.kt
68- com/vayunmathur/communicate/data/WearCommunicateSync.kt — phone conduit client node; snapshot publish, watch-state receive, thread-page/op handling; wire protocol `com.vayunmathur.library.wearlink.communicate.WearCommunicateProtocol` in `:library:wearlink` (this module's `WearCommunicateProtocolTest` pins the golden JSON)
69- com/vayunmathur/communicate/data/WearCommunicateStore.kt — watch-side snapshot/thread-page/pending-op store
70- com/vayunmathur/communicate/sync/WearLinkBridge.kt — watch conduit client node; snapshot/pages/alerts in, ops/requests out
71### data/googlevoice/ — Voice line (RPC + SIP calls)
72- com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt
73- com/vayunmathur/communicate/data/googlevoice/GoogleVoiceSession.kt
74- com/vayunmathur/communicate/data/googlevoice/call/SipClient.kt
75- com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallManager.kt
76### Dev-only lines — in `:communicate-dev` (see its AGENTS.md)
77- data/whatsapp, data/signal, data/rcs (transports, Room DBs, E2E) + src/main/proto + both Rust crates
78- Host-side dev glue in `src/dev`: `data/CommunicateRepository{Rcs,RcsGroup,Signal,WhatsApp,WhatsAppCalls}.kt`, `data/LineRepositorySeam.kt`, `data/rcs/{RcsFileTransfer,RcsFileTransferHttp,RcsOutbox,RcsRepositoryTyping}.kt`, `telephony/{WhatsApp,Signal,Rcs}SyncService` + RCS inbound/telephony glue, `ui/{LineUiSeam,rememberSignalSignedIn,rememberWhatsAppAccount,rememberSignalAccount,rememberRcsStatusText,rememberDevLineChoices,LineSyncEffects,AppTelecomEffects,ConversationRcsExtras,ConversationEncryptionBanner}.kt`; `src/release` carries the no-op seam counterparts (same split files) + `data/RepositoryLineStubs.kt`
79- Shared frozen types (`data/SecretSealer.kt`, `data/CommunicateLine.kt`, `data/call/{InAppCall,WebRtcInit}.kt`) are canonical in `:communicate-dev`; byte-identical copies in `src/release` serve the release variant (Google Voice + host call UI) — keep the copies in sync; the KeyStore alias and `v1:` sealed format are frozen
80### telephony/ — framework call/SMS services
81- com/vayunmathur/communicate/telephony/CommunicateInCallService.kt
82- com/vayunmathur/communicate/telephony/GoogleVoiceConnectionService.kt
83- com/vayunmathur/communicate/telephony/SmsDeliverReceiver.kt
84- (WhatsApp/Signal/RCS sync services live in `src/dev/telephony/`, declared in `:communicate-dev`'s manifest)
85### service/car/ + intents/ + ui/
86- com/vayunmathur/communicate/service/car/CommunicateCarAppService.kt
87- com/vayunmathur/communicate/intents/SendMessageIntent.kt
88- com/vayunmathur/communicate/intents/GetMessagesIntent.kt
89- com/vayunmathur/communicate/ui/MessagesScreen.kt
90- com/vayunmathur/communicate/ui/ConversationScreen.kt
91- com/vayunmathur/communicate/ui/DialerScreen.kt
92### Watch experience (ui/ + data/ + sync/)
93- com/vayunmathur/communicate/ui/WearMainActivity.kt — watch entry (WearShellActivity, exported=false; reached only via MainActivity's watch routing)
94- com/vayunmathur/communicate/ui/WearRoute.kt, WearConversationListScreen.kt, WearThreadScreen.kt, WearReplyScreen.kt, WearCallLogScreen.kt, WearVoicemailScreen.kt, WearIncomingCallScreen.kt, WearPhoneOnlyScreen.kt
95- com/vayunmathur/communicate/ui/FormFactor.kt — watch detection (`FEATURE_WATCH`)
96
97## Screenshot coverage + dialog routes
98Dialogs are `Route` destinations (`NewMessageDialog`, `DeleteConversationDialog`, `DeleteCallLogDialog`, `PollComposerDialog` — `DialogPage()` entries in `ui/CommunicateDialogEntries.kt`, selection in route args, results via `RESULT_*` keys), never `pendingDelete`/`show…` state in a screen. Each has a capture in `src/screenshotTest` named `<n>-<route-key>`; the fatal `RouteScreenshotCoverage` lint enforces route→capture mapping, with session/WebView/call-bound routes exempted per route in `Route.kt`. Remaining embedded dialog: `VoicemailContent`'s delete confirm (`VoicemailScreen` is unrouted today). Convention: `docs/screenshot-coverage.md`.
99
100## Verify (this module only)
101```
102./gradlew :communicate:compileDevKotlin
103./gradlew :communicate:lint
104./gradlew :communicate:lintVitalRelease
105./gradlew :communicate:testDevUnitTest
106./gradlew :communicate:checkMetadata
107```