# AGENTS.md — communicate/ (':communicate') > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `communicate/` + allowed shared modules. Do not root-scan. _Install: ./install communicate (dev by default)._ - Gradle: :communicate / dir: communicate/ - Package roots present: ui, data, domain, intents, service, telephony, notifications, sync - Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt, ui/WearMainActivity.kt - Deps: :library:network, :library:image, :library:aosp-stubs (compileOnly), :library:wearlink, :library:log, Wear Compose (material + foundation) - Metadata: metadata_data/communicate.md (present) - Rust: no (both crates live in `:communicate-dev`) / screenshotTest: yes ## Overview **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. **Key features:** - 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) - In-app calling over WebRTC/RingRTC for the internet lines; framework `InCallService`/`ConnectionService` for SIM + Google Voice telecom integration - Android Auto car templates (`service/car/`), assistant send/read intents, voicemail tab with plain ExoPlayer playback **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. **Entry points + reading order:** `Route` (`Messages` / `Dialer` / `CallLogs` / `Accounts` / `Conversation(threadId, …)` / `Call` / registration wizards) → `MainActivity.kt` → `Navigation.kt` → `ui/MessagesScreen.kt` → `data/CommunicateRepository.kt`. ## One APK, two form factors (phone + watch) This module is the single Communicate APK for phones and watches: same `applicationId = "com.vayunmathur.communicate"` 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. `ui/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 tab UI. The phone telephony receivers (`telephony/SmsDeliverReceiver`, `telephony/MmsDeliverReceiver`) early-return on a watch — a watch has no default-SMS role and receives its messages over the Watch conduit. ## Wear sync (Watch conduit client) **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. - Snapshot + watch-state sync: conduit data items (`/communicate/snapshot` phone -> watch, `/communicate/watch-state` watch -> phone) - Thread pages, new-message/incoming-call alerts, and watch ops with phone verdicts (quick reply, mark-read, voicemail-read, decline-call, delete-thread): conduit messages (see the protocol file for paths and caps) - **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. The watch keeps ops pending and resends on reconnect. - **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 `WearCommunicateSync.syncNow()` — 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 (`//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`) 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). - Watch state persists in `data/WearCommunicateStore` (snapshot, thread-page and pending-op JSON files). - Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:communicate:metadata` into `metadata_data/photos/communicate/wear/`. **Gotchas:** - 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). - 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. - 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. - `:library:aosp-stubs` is `compileOnly` only (framework `@SystemApi` RCS/backup transport stubs) — it must never be packaged. - 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. - Car code (`service/car/`) is the only car-app-library consumer here; phone UI, sync services and crypto paths must stay car-free. ## Key files ### Root — entry + navigation - com/vayunmathur/communicate/MainActivity.kt - com/vayunmathur/communicate/Navigation.kt - com/vayunmathur/communicate/Route.kt ### data/ — unified repository (per-line splits) - com/vayunmathur/communicate/data/CommunicateModels.kt - com/vayunmathur/communicate/data/CommunicateRepository.kt - com/vayunmathur/communicate/data/CommunicateRepositoryMerged.kt — plus per-line splits (`Sim`, `Send`, `Rcs`, `Signal`, `WhatsApp`) - com/vayunmathur/communicate/data/SimManager.kt - com/vayunmathur/communicate/data/SecretSealer.kt - 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) - com/vayunmathur/communicate/data/WearCommunicateStore.kt — watch-side snapshot/thread-page/pending-op store - com/vayunmathur/communicate/sync/WearLinkBridge.kt — watch conduit client node; snapshot/pages/alerts in, ops/requests out ### data/googlevoice/ — Voice line (RPC + SIP calls) - com/vayunmathur/communicate/data/googlevoice/GoogleVoiceClient.kt - com/vayunmathur/communicate/data/googlevoice/GoogleVoiceSession.kt - com/vayunmathur/communicate/data/googlevoice/call/SipClient.kt - com/vayunmathur/communicate/data/googlevoice/call/GoogleVoiceCallManager.kt ### Dev-only lines — in `:communicate-dev` (see its AGENTS.md) - data/whatsapp, data/signal, data/rcs (transports, Room DBs, E2E) + src/main/proto + both Rust crates - 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` - 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 ### telephony/ — framework call/SMS services - com/vayunmathur/communicate/telephony/CommunicateInCallService.kt - com/vayunmathur/communicate/telephony/GoogleVoiceConnectionService.kt - com/vayunmathur/communicate/telephony/SmsDeliverReceiver.kt - (WhatsApp/Signal/RCS sync services live in `src/dev/telephony/`, declared in `:communicate-dev`'s manifest) ### service/car/ + intents/ + ui/ - com/vayunmathur/communicate/service/car/CommunicateCarAppService.kt - com/vayunmathur/communicate/intents/SendMessageIntent.kt - com/vayunmathur/communicate/intents/GetMessagesIntent.kt - com/vayunmathur/communicate/ui/MessagesScreen.kt - com/vayunmathur/communicate/ui/ConversationScreen.kt - com/vayunmathur/communicate/ui/DialerScreen.kt ### Watch experience (ui/ + data/ + sync/) - com/vayunmathur/communicate/ui/WearMainActivity.kt — watch entry (WearShellActivity, exported=false; reached only via MainActivity's watch routing) - com/vayunmathur/communicate/ui/WearRoute.kt, WearConversationListScreen.kt, WearThreadScreen.kt, WearReplyScreen.kt, WearCallLogScreen.kt, WearVoicemailScreen.kt, WearIncomingCallScreen.kt, WearPhoneOnlyScreen.kt - com/vayunmathur/communicate/ui/FormFactor.kt — watch detection (`FEATURE_WATCH`) ## Screenshot coverage + dialog routes Dialogs 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 `-`; 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`. ## Verify (this module only) ``` ./gradlew :communicate:compileDevKotlin ./gradlew :communicate:lint ./gradlew :communicate:lintVitalRelease ./gradlew :communicate:testDevUnitTest ./gradlew :communicate:checkMetadata ```