watch: phone conduit app, sole Bluetooth holder on the phone
- Commit
02e319e758b758dcc5a525af6e00a87b0aca417e- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 19:11 UTC (4 days ago)
- Parents
150c6e0
New :watch app (applicationId com.vayunmathur.watch, shared with :watch:wear): ConduitService is a foreground (connectedDevice) service hosting the one WearLinkNode via ConduitHost, exported only under the signature permission com.vayunmathur.watch.permissions.CONDUIT which this manifest declares. BLUETOOTH_CONNECT plus BLUETOOTH/BLUETOOTH_ADMIN (maxSdk 30), foreground-service and boot permissions are declared only here on the phone side. BootReceiver restarts the service on boot/replacement; the first bind also promotes it to foreground. The single AppScaffold status route shows link state, registered apps, cached data items and per-app traffic counters, with the Bluetooth permission grant action, and it has a screenshot capture (metadata_data/photos/watch). No app pair migrates yet and wearlink's manifest permissions stay (later stage). Verified: :watch:assembleDev, :watch:testDevUnitTest, :watch:lint, :watch:detekt and :watch:metadata pass; the merged manifest shows BLUETOOTH_CONNECT, the signature permission declaration and the permission-guarded ConduitService.
Diff
AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex c42f2971ad..ea388f868a 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,7 +49,7 @@ Monorepo: ~100 Gradle modules + Rust workspace. Do scoped work only. ### Apps (Gradle key → dir) Reference: `backup/` satisfies every rule; `notes/` second + `intents/` demo. `camera` + `games/voxels` hand-commit screenshots. Full canonical index (Gradle key → dir + group + notes): `.llms/repo-map.md`.-`appstore→appstore/` `astronomy→astronomy/` `auto→auto/,auto/protocol/` `backup→backup/` `calculator→calculator/` `calendar→calendar/` `camera→camera/` `cast→cast/,cast/protocol/,cast/tv/` `clock→clock/` `code→code/` `communicate→communicate/` `contacts→contacts/` `education→education/` `email→email/` `emergency→emergency/` `euicc→euicc/` `everysync→everysync/` `files→files/` `findfamily→findfamily/` `findfamily-ios→apple/FindFamily/` (SwiftPM/xtool, not Gradle) `flashcards→flashcards/` `fooddelivery→fooddelivery/` `health→health/` `keyboard→keyboard/` `launcher→launcher/` `logviewer→logviewer/` `maps→maps/` `measure→measure/` `music→music/` `networklocation→networklocation/` `news→news/` `notes→notes/` `office→office/` `openassistant→openassistant/` `passwords→passwords/` `pdf→pdf/` `photos→photos/` `parentalcontrols→parentalcontrols/` `screentime→screentime/` `setupwizard→setupwizard/` `share→share/` `speech→speech/` `taxi→taxi/` `things→things/` `todo→todo/` `translate→translate/` `travel→travel/` `tuner→tuner/` `updater→updater/` `vpn→vpn/` `weather→weather/` `web→web/` `youpipe→youpipe/,youpipe/extractor/` `games-hub→games/hub/` `games-arrows→games/arrows/` `games-chess→games/chess/` `games-logicgate→games/logicgate/` `games-minesweeper→games/minesweeper/` `games-nonogram→games/nonogram/` `games-pipes→games/pipes/` `games-solitaire→games/solitaire/` `games-sudoku→games/sudoku/` `games-unblockjam→games/unblockjam/` `games-voxels→games/voxels/` `games-wordmaker→games/wordmaker/`+`appstore→appstore/` `astronomy→astronomy/` `auto→auto/,auto/protocol/` `backup→backup/` `calculator→calculator/` `calendar→calendar/` `camera→camera/` `cast→cast/,cast/protocol/,cast/tv/` `clock→clock/` `code→code/` `communicate→communicate/` `contacts→contacts/` `education→education/` `email→email/` `emergency→emergency/` `euicc→euicc/` `everysync→everysync/` `files→files/` `findfamily→findfamily/` `findfamily-ios→apple/FindFamily/` (SwiftPM/xtool, not Gradle) `flashcards→flashcards/` `fooddelivery→fooddelivery/` `health→health/` `keyboard→keyboard/` `launcher→launcher/` `logviewer→logviewer/` `maps→maps/` `measure→measure/` `music→music/` `networklocation→networklocation/` `news→news/` `notes→notes/` `office→office/` `openassistant→openassistant/` `passwords→passwords/` `pdf→pdf/` `photos→photos/` `parentalcontrols→parentalcontrols/` `screentime→screentime/` `setupwizard→setupwizard/` `share→share/` `speech→speech/` `taxi→taxi/` `things→things/` `todo→todo/` `translate→translate/` `travel→travel/` `tuner→tuner/` `updater→updater/` `vpn→vpn/` `weather→weather/` `watch→watch/,watch-wear/` `web→web/` `youpipe→youpipe/,youpipe/extractor/` `games-hub→games/hub/` `games-arrows→games/arrows/` `games-chess→games/chess/` `games-logicgate→games/logicgate/` `games-minesweeper→games/minesweeper/` `games-nonogram→games/nonogram/` `games-pipes→games/pipes/` `games-solitaire→games/solitaire/` `games-sudoku→games/sudoku/` `games-unblockjam→games/unblockjam/` `games-voxels→games/voxels/` `games-wordmaker→games/wordmaker/` Slash == colon for Gradle (`games/voxels` == `games:voxels`). ### Never scan
library/wearlink/AGENTS.md
diff --git a/library/wearlink/AGENTS.md b/library/wearlink/AGENTS.mdindex f8a9b63c04..3bb07d81ee 100644--- a/library/wearlink/AGENTS.md+++ b/library/wearlink/AGENTS.md@@ -5,7 +5,9 @@ - Gradle: :library:wearlink / dir: library/wearlink/ - Package: `com.vayunmathur.library.wearlink` for the transport, plus one per-app protocol subpackage (e.g. `com.vayunmathur.library.wearlink.clock`)-- Entry: `WearLinkNode.kt` (Android), `WearLinkProtocol.kt` (pure wire)+- Entry: `WearLinkNode.kt` (Android), `WearLinkProtocol.kt` (pure wire),+ `conduit/WearLinkClientNode.kt` (Messenger client used by every app+ except the Watch apps) - Wear entry shell: `WearShellActivity.kt` — every wear companion's main activity extends `WearShellActivity<route, store>` (permission request, `createStore()` warm-up, Wear Material theme + route state held in the@@ -25,6 +27,16 @@ tests stay in each app module and pin the shared code's wire format. Migrated: clock, launcher, calendar, weather, music, notes, maps, appstore, contacts, findfamily, todo, communicate, camera. Remaining pairs are listed in `docs/structure/wear-protocol-pairs.tsv`. +The `conduit/` package is the Watch conduit contract and core:+`ConduitProtocol` (Messenger codes/keys), `ConduitRouter` (pure+routing: registrations, latest-data replay, bounded queue for+unregistered apps, status fan-out, counters), `WearLinkClientNode`+(drop-in `WearLinkNode` replacement over the conduit binding; reports+`NotInstalled`/`Unavailable` when the Watch app is absent), and+`ConduitHost`/`ConduitRuntime` used by the two Watch apps'+`ConduitService`s. No app pair has migrated to the client yet, and+this module's manifest Bluetooth permissions stay until they do.+ ## Verify ``` ./gradlew :library:wearlink:testDebugUnitTest
metadata_data/photos/watch/phone/1.png
diff --git a/metadata_data/photos/watch/phone/1.png b/metadata_data/photos/watch/phone/1.pngnew file mode 100644index 0000000000..3a247342cbBinary files /dev/null and b/metadata_data/photos/watch/phone/1.png differ
metadata_data/watch.md
diff --git a/metadata_data/watch.md b/metadata_data/watch.mdnew file mode 100644index 0000000000..868ffbce74--- /dev/null+++ b/metadata_data/watch.md@@ -0,0 +1,8 @@+The Watch conduit: the one app that carries messages between your phone and your watch++Features:+- Single Bluetooth link for every watch companion app, instead of one link per app+- Apps on the phone and watch talk to the conduit locally; only Watch holds Bluetooth permissions+- Status screen with link state, registered apps, and per-app traffic++Offline: no internet is used at all
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 7a1817cfdb..7c241207f3 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -83,6 +83,9 @@ include(":library:media") include(":library:log") include(":library:format") include(":library:wearlink")+include(":watch")+include(":watch:wear")+project(":watch:wear").projectDir = file("watch-wear") include(":library:carhost") include(":calendar") include(":calendar:wear")
watch/AGENTS.md
diff --git a/watch/AGENTS.md b/watch/AGENTS.mdnew file mode 100644index 0000000000..1910b8d68e--- /dev/null+++ b/watch/AGENTS.md@@ -0,0 +1,56 @@+# AGENTS.md — watch/ (':watch')++> Scoped supplement. Global rules in root `AGENTS.md` apply.++- Gradle: :watch / dir: watch/+- Package roots present: ui, platform, service+- Entry files: MainActivity.kt, Route.kt, Navigation.kt+- Deps: :library:wearlink+- Metadata: metadata_data/watch.md (present)+- Rust: no / screenshotTest: yes++## Overview+**Purpose:** Phone half of the Watch conduit — the sole phone<->watch+messaging app on the phone. It is the only phone app that holds+Bluetooth permissions and the only one that owns a real+`WearLinkNode` (appId `watch_conduit`, in `service/ConduitService`+via `ConduitHost` in `:library:wearlink`). Every other app reaches+the watch through `WearLinkClientNode` bound to this app's conduit+service.+**Architecture / data-flow:** `service/ConduitService` (foreground,+`connectedDevice`) hosts `ConduitHost` -> `ConduitRouter`, which+routes by first path segment between local Messenger clients and+the peer. `platform/BootReceiver` restarts it on boot/replacement.+The single status screen renders `ConduitRuntime.state` (link state,+registered apps, per-app counters) and offers the Bluetooth+permission grant.+**Entry points + reading order:** `Route` (`Status`) → `MainActivity.kt`+→ `Navigation.kt` → `ui/WatchStatusScreen.kt`; service side:+`service/ConduitService.kt` → `:library:wearlink` conduit package.+**Gotchas:**+- `applicationId com.vayunmathur.watch` and the signing key are shared+ with `:watch:wear` on purpose: the handshake token and the+ `com.vayunmathur.watch.permissions.CONDUIT` signature permission+ both require one identity.+- Do not add Bluetooth permissions anywhere else; do not strip+ wearlink's manifest permissions until every app pair has migrated+ to the client node (a later stage).++## Key files+### Root — entry + navigation+- com/vayunmathur/watch/MainActivity.kt+- com/vayunmathur/watch/Navigation.kt+- com/vayunmathur/watch/Route.kt+### service/ — conduit host+- com/vayunmathur/watch/service/ConduitService.kt+### platform/ — boot restart+- com/vayunmathur/watch/platform/BootReceiver.kt+### ui/ — status screen+- com/vayunmathur/watch/ui/WatchStatusScreen.kt++## Verify (this module only)+```+./gradlew :watch:compileDevKotlin+./gradlew :watch:lint+./gradlew :watch:checkMetadata+```
watch/build.gradle.kts
diff --git a/watch/build.gradle.kts b/watch/build.gradle.ktsnew file mode 100644index 0000000000..f225531a3b--- /dev/null+++ b/watch/build.gradle.kts@@ -0,0 +1,21 @@+plugins {+ id("common-conventions-app")+ id("common-conventions-preview-metadata")+}++launcherIcon {+ symbol = "watch"+}++android {+ defaultConfig {+ applicationId = "com.vayunmathur.watch"+ }+}++dependencies {+ // The single WearLinkNode lives in the conduit service; the shared+ // conduit protocol/router/host live in :library:wearlink.+ implementation(project(":library:wearlink"))+ implementation(libs.kotlinx.coroutines.android)+}
watch/src/main/AndroidManifest.xml
diff --git a/watch/src/main/AndroidManifest.xml b/watch/src/main/AndroidManifest.xmlnew file mode 100644index 0000000000..192879ddaa--- /dev/null+++ b/watch/src/main/AndroidManifest.xml@@ -0,0 +1,59 @@+<?xml version="1.0" encoding="utf-8"?>+<manifest xmlns:android="http://schemas.android.com/apk/res/android">++ <!-- Sole Bluetooth holder on the phone: RFCOMM to the bonded watch. -->+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />+ <uses-permission+ android:name="android.permission.BLUETOOTH"+ android:maxSdkVersion="30" />+ <uses-permission+ android:name="android.permission.BLUETOOTH_ADMIN"+ android:maxSdkVersion="30" />+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />+ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />++ <permission+ android:name="com.vayunmathur.watch.permissions.CONDUIT"+ android:protectionLevel="signature" />++ <application+ android:allowBackup="true"+ android:icon="@mipmap/ic_launcher"+ android:label="@string/app_name"+ android:roundIcon="@mipmap/ic_launcher"+ android:supportsRtl="true"+ android:theme="@style/Theme.General">++ <activity+ android:name=".MainActivity"+ android:exported="true"+ android:theme="@style/Theme.General">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LAUNCHER" />+ </intent-filter>+ </activity>++ <service+ android:name=".service.ConduitService"+ android:exported="true"+ android:foregroundServiceType="connectedDevice"+ android:permission="com.vayunmathur.watch.permissions.CONDUIT">+ <intent-filter>+ <action android:name="com.vayunmathur.watch.action.CONDUIT" />+ </intent-filter>+ </service>++ <receiver+ android:name=".platform.BootReceiver"+ android:enabled="true"+ android:exported="true">+ <intent-filter>+ <action android:name="android.intent.action.BOOT_COMPLETED" />+ <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />+ </intent-filter>+ </receiver>+ </application>+</manifest>
watch/src/main/java/com/vayunmathur/watch/MainActivity.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/MainActivity.kt b/watch/src/main/java/com/vayunmathur/watch/MainActivity.ktnew file mode 100644index 0000000000..cccc2dbf1f--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/MainActivity.kt@@ -0,0 +1,17 @@+package com.vayunmathur.watch++import androidx.compose.runtime.Composable+import com.vayunmathur.library.ui.MaActivity+import com.vayunmathur.watch.service.ConduitService++/** Entry activity: starts the conduit service, then shows link status. */+class MainActivity : MaActivity() {+ override fun onCreateBeforeContent() {+ ConduitService.start(this)+ }++ @Composable+ override fun Content() {+ Navigation()+ }+}
watch/src/main/java/com/vayunmathur/watch/Navigation.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/Navigation.kt b/watch/src/main/java/com/vayunmathur/watch/Navigation.ktnew file mode 100644index 0000000000..b6515cf847--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/Navigation.kt@@ -0,0 +1,27 @@+package com.vayunmathur.watch++import android.Manifest+import androidx.activity.compose.rememberLauncherForActivityResult+import androidx.activity.result.contract.ActivityResultContracts+import androidx.compose.runtime.Composable+import com.vayunmathur.library.util.MainNavigation+import com.vayunmathur.library.util.rememberNavBackStack+import com.vayunmathur.watch.ui.WatchStatusScreen++@Composable+fun Navigation() {+ val backStack = rememberNavBackStack<Route>(Route.Status)+ val permissionLauncher =+ rememberLauncherForActivityResult(+ ActivityResultContracts.RequestPermission(),+ ) { }+ MainNavigation(backStack) {+ entry<Route.Status> {+ WatchStatusScreen(+ onGrantPermission = {+ permissionLauncher.launch(Manifest.permission.BLUETOOTH_CONNECT)+ },+ )+ }+ }+}
watch/src/main/java/com/vayunmathur/watch/Route.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/Route.kt b/watch/src/main/java/com/vayunmathur/watch/Route.ktnew file mode 100644index 0000000000..3dd420015d--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/Route.kt@@ -0,0 +1,12 @@+package com.vayunmathur.watch++import com.vayunmathur.library.util.NavKey+import kotlinx.serialization.Serializable++/** Navigation destinations for the Watch (phone) app. */+@Serializable+sealed interface Route : NavKey {+ /** Conduit link status, registered apps and per-app traffic. */+ @Serializable+ data object Status : Route+}
watch/src/main/java/com/vayunmathur/watch/platform/BootReceiver.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/platform/BootReceiver.kt b/watch/src/main/java/com/vayunmathur/watch/platform/BootReceiver.ktnew file mode 100644index 0000000000..ce0e9cfb34--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/platform/BootReceiver.kt@@ -0,0 +1,20 @@+package com.vayunmathur.watch.platform++import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import com.vayunmathur.watch.service.ConduitService++/** Starts the conduit foreground service after boot or app replacement. */+class BootReceiver : BroadcastReceiver() {+ override fun onReceive(+ context: Context,+ intent: Intent,+ ) {+ when (intent.action) {+ Intent.ACTION_BOOT_COMPLETED,+ Intent.ACTION_MY_PACKAGE_REPLACED,+ -> ConduitService.start(context)+ }+ }+}
watch/src/main/java/com/vayunmathur/watch/service/ConduitService.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/service/ConduitService.kt b/watch/src/main/java/com/vayunmathur/watch/service/ConduitService.ktnew file mode 100644index 0000000000..ab7c615b15--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/service/ConduitService.kt@@ -0,0 +1,107 @@+package com.vayunmathur.watch.service++import android.app.Notification+import android.app.NotificationChannel+import android.app.NotificationManager+import android.app.Service+import android.content.Context+import android.content.Intent+import android.content.pm.ServiceInfo+import android.os.IBinder+import androidx.core.app.NotificationCompat+import androidx.core.content.ContextCompat+import com.vayunmathur.library.wearlink.conduit.ConduitHost++/**+ * Foreground host for the one WearLink conduit on this device.+ *+ * Exported but bound only under the signature permission+ * com.vayunmathur.watch.permissions.CONDUIT (declared in this app's+ * manifest; the peer Watch app declares the same permission so the+ * platform signature check is symmetric). Started on boot by+ * BootReceiver and on first bind; the foreground notification keeps+ * the RFCOMM link alive while any client is bound.+ */+class ConduitService : Service() {+ private lateinit var host: ConduitHost+ private var foregroundStarted = false++ override fun onCreate() {+ super.onCreate()+ host = ConduitHost(applicationContext)+ createChannel()+ }++ override fun onStartCommand(+ intent: Intent?,+ flags: Int,+ startId: Int,+ ): Int {+ startForegroundNow()+ if (!foregroundStarted) return START_NOT_STICKY+ host.start()+ return START_STICKY+ }++ override fun onBind(intent: Intent?): IBinder {+ ContextCompat.startForegroundService(+ this,+ Intent(this, ConduitService::class.java),+ )+ return host.messenger.binder+ }++ override fun onUnbind(intent: Intent?): Boolean {+ host.clearClients()+ return false+ }++ override fun onDestroy() {+ host.stop()+ super.onDestroy()+ }++ private fun startForegroundNow() {+ if (foregroundStarted) return+ val notification = buildNotification()+ try {+ startForeground(+ NOTIFICATION_ID,+ notification,+ ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE,+ )+ foregroundStarted = true+ } catch (_: Exception) {+ stopSelf()+ }+ }++ private fun buildNotification(): Notification =+ NotificationCompat+ .Builder(this, CHANNEL_ID)+ .setContentTitle("Watch link")+ .setContentText("Phone and watch messaging is running")+ .setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)+ .setOngoing(true)+ .build()++ private fun createChannel() {+ val manager = getSystemService(NotificationManager::class.java) ?: return+ manager.createNotificationChannel(+ NotificationChannel(CHANNEL_ID, "Watch link", NotificationManager.IMPORTANCE_LOW),+ )+ }++ companion object {+ private const val CHANNEL_ID = "watch_conduit"+ private const val NOTIFICATION_ID = 0x5743++ /** Start the conduit foreground service (boot / first use). */+ fun start(context: Context) {+ ContextCompat.startForegroundService(+ context.applicationContext,+ Intent(context.applicationContext, ConduitService::class.java),+ )+ }+ }+}
watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusContent.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusContent.kt b/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusContent.ktnew file mode 100644index 0000000000..01ba1360dd--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusContent.kt@@ -0,0 +1,89 @@+package com.vayunmathur.watch.ui++import androidx.compose.foundation.layout.Arrangement+import androidx.compose.foundation.layout.Column+import androidx.compose.foundation.layout.fillMaxWidth+import androidx.compose.foundation.layout.padding+import androidx.compose.foundation.rememberScrollState+import androidx.compose.foundation.verticalScroll+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.res.stringResource+import androidx.compose.ui.unit.dp+import com.vayunmathur.library.ui.AppScaffold+import com.vayunmathur.library.ui.Button+import com.vayunmathur.library.ui.Card+import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.wearlink.conduit.ConduitProtocol+import com.vayunmathur.library.wearlink.conduit.ConduitSnapshot+import com.vayunmathur.watch.R++/** Pure rendering of a conduit snapshot (also the screenshot fixture surface). */+@Composable+fun WatchStatusContent(+ snapshot: ConduitSnapshot,+ onGrantPermission: () -> Unit,+) {+ AppScaffold(title = stringResource(R.string.app_name)) { padding ->+ Column(+ modifier =+ Modifier+ .padding(padding)+ .fillMaxWidth()+ .padding(16.dp)+ .verticalScroll(rememberScrollState()),+ verticalArrangement = Arrangement.spacedBy(16.dp),+ ) {+ Card(modifier = Modifier.fillMaxWidth()) {+ Column(+ modifier = Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(stringResource(R.string.link_state, snapshot.linkState))+ snapshot.peerLabel?.let { Text(stringResource(R.string.peer_label, it)) }+ snapshot.reason?.let { Text(it) }+ if (snapshot.linkState == ConduitProtocol.STATUS_PERMISSION_MISSING) {+ Button(onClick = onGrantPermission) {+ Text(stringResource(R.string.grant_permission))+ }+ }+ }+ }+ Card(modifier = Modifier.fillMaxWidth()) {+ Column(+ modifier = Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(stringResource(R.string.registered_apps))+ if (snapshot.registeredApps.isEmpty()) {+ Text(stringResource(R.string.no_apps))+ } else {+ snapshot.registeredApps.sorted().forEach { appId -> Text(appId) }+ }+ Text(stringResource(R.string.cached_items, snapshot.cachedDataItems))+ }+ }+ snapshot.counters.toSortedMap().forEach { (appId, counters) ->+ Card(modifier = Modifier.fillMaxWidth()) {+ Column(+ modifier = Modifier.padding(16.dp),+ verticalArrangement = Arrangement.spacedBy(8.dp),+ ) {+ Text(appId)+ Text(+ stringResource(+ R.string.traffic,+ counters.messagesOut,+ counters.messagesIn,+ counters.dataOut,+ counters.dataIn,+ counters.streamsOut,+ counters.streamsIn,+ ),+ )+ }+ }+ }+ }+ }+}
watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusScreen.kt
diff --git a/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusScreen.kt b/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusScreen.ktnew file mode 100644index 0000000000..d552239799--- /dev/null+++ b/watch/src/main/java/com/vayunmathur/watch/ui/WatchStatusScreen.kt@@ -0,0 +1,13 @@+package com.vayunmathur.watch.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.collectAsState+import androidx.compose.runtime.getValue+import com.vayunmathur.library.wearlink.conduit.ConduitRuntime++/** Status screen: link state, registered apps, per-app traffic, permission action. */+@Composable+fun WatchStatusScreen(onGrantPermission: () -> Unit) {+ val snapshot by ConduitRuntime.state.collectAsState()+ WatchStatusContent(snapshot = snapshot, onGrantPermission = onGrantPermission)+}
watch/src/main/res/values/strings.xml
diff --git a/watch/src/main/res/values/strings.xml b/watch/src/main/res/values/strings.xmlnew file mode 100644index 0000000000..4a92985aff--- /dev/null+++ b/watch/src/main/res/values/strings.xml@@ -0,0 +1,10 @@+<resources>+ <string name="app_name">Watch</string>+ <string name="link_state">Link: %1$s</string>+ <string name="peer_label">Peer: %1$s</string>+ <string name="grant_permission">Grant Bluetooth permission</string>+ <string name="registered_apps">Registered apps</string>+ <string name="no_apps">No app has registered yet</string>+ <string name="cached_items">Cached data items: %1$d</string>+ <string name="traffic">Messages out %1$d, in %2$d; data out %3$d, in %4$d; streams out %5$d, in %6$d</string>+</resources>
watch/src/screenshotTest/kotlin/com/vayunmathur/watch/ui/MetadataPreviews.kt
diff --git a/watch/src/screenshotTest/kotlin/com/vayunmathur/watch/ui/MetadataPreviews.kt b/watch/src/screenshotTest/kotlin/com/vayunmathur/watch/ui/MetadataPreviews.ktnew file mode 100644index 0000000000..33e6c9a238--- /dev/null+++ b/watch/src/screenshotTest/kotlin/com/vayunmathur/watch/ui/MetadataPreviews.kt@@ -0,0 +1,37 @@+package com.vayunmathur.watch.ui++import androidx.compose.runtime.Composable+import androidx.compose.ui.tooling.preview.Preview+import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.wearlink.conduit.ConduitCounters+import com.vayunmathur.library.wearlink.conduit.ConduitProtocol+import com.vayunmathur.library.wearlink.conduit.ConduitSnapshot++private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"++/** Store-listing images for the Watch phone app, rendered from previews. */+class MetadataPreviews {+ @PreviewTest+ @Preview(name = "1-status", device = PHONE, group = "phone", showSystemUi = true)+ @Composable+ fun Preview1Status() {+ DynamicTheme(darkTheme = true) {+ WatchStatusContent(+ snapshot =+ ConduitSnapshot(+ linkState = ConduitProtocol.STATUS_CONNECTED,+ peerLabel = "Pixel Watch",+ registeredApps = setOf("clock", "notes"),+ counters =+ mapOf(+ "clock" to ConduitCounters(messagesOut = 2, messagesIn = 1, dataOut = 1, dataIn = 1),+ "notes" to ConduitCounters(messagesOut = 0, messagesIn = 3, dataOut = 1, dataIn = 0),+ ),+ cachedDataItems = 2,+ ),+ onGrantPermission = {},+ )+ }+ }+}
watch/src/test/java/com/vayunmathur/watch/RouteTest.kt
diff --git a/watch/src/test/java/com/vayunmathur/watch/RouteTest.kt b/watch/src/test/java/com/vayunmathur/watch/RouteTest.ktnew file mode 100644index 0000000000..7259982be6--- /dev/null+++ b/watch/src/test/java/com/vayunmathur/watch/RouteTest.kt@@ -0,0 +1,12 @@+package com.vayunmathur.watch++import com.vayunmathur.library.util.NavKey+import kotlin.test.Test+import kotlin.test.assertTrue++class RouteTest {+ @Test+ fun `status route is a nav key`() {+ assertTrue(Route.Status is NavKey)+ }+}