Modern Apps git

← Modern-Apps.git

various fixes

Commit
1c42f72c84921aa36c1db2c883c63601511d8795
Author
vayun-mathur <[email protected]>
When
2026-09-14 03:02 UTC (2 months ago)
Parents
5902326

Diff

Cargo.lock
diff --git a/Cargo.lock b/Cargo.lockindex 641e674d4c..97cded9a07 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2307,6 +2307,7 @@ dependencies = [  "flate2",  "jni",  "libc",+ "tilecodec", ]  [[package]]
auto/build.gradle.kts
diff --git a/auto/build.gradle.kts b/auto/build.gradle.ktsindex 181348bd7b..c067c5cdd1 100644--- a/auto/build.gradle.kts+++ b/auto/build.gradle.kts@@ -16,9 +16,10 @@ dependencies {     implementation(project(":auto:protocol"))     // Media3 controller for the Phase 4 now-playing feed from the on-device media session.     implementation(libs.androidx.media3.session)-    // Phase 6 maps mirror: CarMapsMirror draws the :library:map basemap-    // (SurfaceMapRenderer) into the car video path. No maps-app dependency ---    // the mirror reads the renderer only, and guidance arrives as plain-    // NavSnapshot data through NavGuidanceMonitor.-    implementation(project(":library:map"))+    // Car App Library host: CarAppHost binds the :maps car-app service and+    // implements the host binders (ICarHost/IAppHost/INavigationHost/+    // IConstraintHost) so the nav card renders whatever Maps publishes --+    // its own SurfaceContainer surface plus its NavigationTemplate -- instead+    // of MA Auto re-rendering a second map. Same 1.4.0 the maps app uses.+    implementation(libs.androidx.car.app) }
auto/docs/HANDOFF.md
diff --git a/auto/docs/HANDOFF.md b/auto/docs/HANDOFF.mdindex 51d31d6463..225cdd72d3 100644--- a/auto/docs/HANDOFF.md+++ b/auto/docs/HANDOFF.md@@ -61,85 +61,42 @@ protocol — nothing to do with the OS or with privileges.  --- -## 10. Phase 6 — Maps mirror + host-vs-mirror decision (maps-dev, task 9)--**Decision: MIRROR. The host stays a prototype.**--The head unit only ever sees our ch2 H.264, so the host path adds a second-renderer, a service bind and a template round-trip without changing a single-wire byte. `HostVsMirror.recommend` (pure, JVM-tested in-`HostVsMirrorTest`) says MIRROR whenever the `:library:map` renderer loads ---which is every arm64 build -- and only says HOST when the host is fully-ready (maps car-app service present, projection role held, `app-projected`-on the classpath) AND the mirror cannot draw at all (no renderer, no-location). `GearheadHostProbe.probe` gathers those facts on device without-hard-linking the host stack (`Class.forName`, never an import); its-one-line verdict feeds this report and the phone debug row, not a live-switch. Mirror is the session default regardless.--Side-by-side (prototype comparison, no DHU run in this environment):--| | Mirror (`CarMapsMirror`) | Host (`MapsCarAppService`) |-|---|---|---|-| Renderer | own `SurfaceMapRenderer`, same archive/tiles as the phone map | car-app host surface via `app-projected` |-| Wire cost | zero new bytes: pixels ride existing ch2 H.264 | same ch2 H.264 plus service bind + template round-trip |-| Latency | one Choreographer loop, on-demand frames | host surface callback + our encode on top |-| Fidelity | full basemap, puck, route, POI; heading-up flat (renderer has no tilt) | `NavigationTemplate` maneuvers + ETA for free |-| Needs role? | no (offscreen surface, no trusted display) | yes (`SYSTEM_AUTOMOTIVE_PROJECTION` for host bind) |-| Needs Maps app? | no (renderer only, `:library:map` dep) | yes (`com.vayunmathur.maps` installed with car service) |-| Fallback | is the fallback | mirror stays fallback even if host prototypes |--What landed (all new files; no other agent's in-flight file touched):--- `auto/protocol/.../MapsGuidance.kt` -- pure `NavSnapshot` shaping:-  `snapshotFromFix` (decimal degrees to e7), `toSensorEvents` (LOCATION /-  SPEED / DRIVING_STATUS always, NIGHT only when known so unknown keeps-  last-known), `toNavStatus` + `encodeNavStatus` (ch10 args + wire render-  through `NavStatusCodec`). Android-free, JVM-tested in-  `MapsGuidanceTest` (6 tests).-- `auto/protocol/.../HostVsMirror.kt` -- pure `HostFacts` / `MirrorFacts`-  / `recommend` (JVM-tested in `HostVsMirrorTest`, 6 tests).-- `platform/NavGuidanceMonitor.kt` -- GPS + network fixes into-  `NavSnapshot`s (last-known seed, motion-heuristic parked, GPS-course-  bearing above 1 m/s else null cone-off, phone-night read); route-  guidance overlays through the `RouteProvider` seam (null = idle map).-  Same "monitor owns its source" shape as `MediaPlaybackMonitor`.-- `platform/CarMapsMirror.kt` -- `SurfaceMapRenderer` into a caller-owned-  surface (own renderer beside the encoder's; composition is the-  bring-up owner's work). Route pushes gated by reference identity, like-  `NavMapScreen.pushedRoute`. Main-thread marshalled; `setDark` follows-  the system theme.-- `platform/GearheadHostProbe.kt` -- on-device fact gathering + one-line-  verdict (`describe()` / `log()`), no host hard-link.-- `auto/build.gradle.kts` -- `implementation(project(":library:map"))`-  for the mirror only.--Guidance hooks for sensors-dev (their channels, their files -- seams only):--- ch7 live values: fold `MapsGuidance.toSensorEvents(snapshot)` through-  `SensorChannel`'s `onValues` seam into `SensorSnapshot.withEvents`.-  The monitor's night read duplicates `ProjectionService.isNightNow`-  deliberately (that file is in-flight); pass the monitor's read in as-  the `NightSource` so the two agree, and dedup when the tree settles.-- ch10 turn updates: forward `MapsGuidance.toNavStatus(snapshot)` to-  `NavStatusChannel.postStatus` as the route advances; the grant-time-  inactive stub stays the no-guidance state.-- ch3 TTS: `GuidanceChannel.startStream` / `stopStream` stay audio-dev's;-  the monitor produces no audio, only the timing (guidanceActive flips)-  a TTS owner could cue on.-- ch8 map touches: route through `VideoSinkChannel` /-  `CarDisplay.injectTouch` like the media card tap -- the mirror draws-  into its own surface, so pan/zoom needs the service to forward scaled-  ch8 frames to the mirror's gesture path (not yet wired; the mirror-  exposes no gesture entry point on purpose until the service owns the-  composition).--Verdict status: Maps visible + pannable and the guidance stub stable are-**not yet shown** -- no DHU/ADB in this environment by hygiene rule. The-JVM leg is green (`:auto:protocol:testDebugUnitTest`); the live leg (DHU-shows the mirror, ch8 pans it, ch10 posts live turns) needs a DHU + Pixel-run and belongs to the task 4 (DHU live-verification) owner via the-`ma-auto-parity` team channel.+## 10. Phase 6 — Maps host (maps-dev, task 9; mirror deleted)++**Decision: HOST. The mirror was the wrong architecture and is deleted.**++Android car apps render through the host: the app (`MapsCarAppService` ->+`MapsSession` -> `NavMapScreen`) draws its own map into a host-owned+`Surface` (`AppManager.setSurfaceCallback` -> `CarMapRenderer`) and publishes+a `NavigationTemplate`. The old mirror re-rendered a second map in the auto+process from GPS scraps and missed everything `NavSnapshot` never carried+(lanes, ETA, arrival). `CarAppHost` is the host: it binds the maps service,+implements the host binders (`ICarHost`/`IAppHost`/`INavigationHost`/+`IConstraintHost`, all from the `app-1.4.0` contract), hands Maps the nav+card's `TextureView` surface as a `SurfaceContainer`, and renders the real+template (cue/road, distance, lane arrows, ETA, app action strip) into the+step header. Ch8 map touches forward into the app's `SurfaceCallback`.+Empty launch tile only when maps is missing or the bind fails.++What landed:++- `platform/CarAppHost.kt` -- the host (bind + handshake + lifecycle ++  template pull + surface supply + touch forwarding). Direct+  `androidx.car.app:app` dependency (same 1.4.0 the maps app uses).+- `platform/CarNavCardView` -- renders `HostNavState` (template fields,+  GONE-if-empty; actions through the app's `OnClickDelegate`); the+  `NavSnapshot` banner stays as the pre-host fallback.+- `service/CarAppHostSession.kt` -- session ownership split (800-line limit).+- `auto/protocol/.../HostVsMirror.kt` -- now `HostFacts` + `HostReadiness`+  (host-only readiness, no mirror comparison; `HostVsMirrorTest` rewritten).+- Deleted: `platform/CarMapsMirror.kt`, `platform/GearheadHostProbe.kt`;+  `:library:map` dep removed from `:auto` (which also unblocks the build).+- `auto/protocol/.../MapsGuidance.kt` -- unchanged wire role: `NavSnapshot`+  still feeds ch7/ch10 + the pre-host banner.++Verdict status: `:auto:assembleDev` + protocol tests + lint green; APK+installed on Pixel 44050DLJH001PC, Maps car service present. Live leg (DHU+shows the hosted map, ch8 pans it, template invalidates) needs a DHU run.  --- 
auto/docs/PARITY.md
diff --git a/auto/docs/PARITY.md b/auto/docs/PARITY.mdindex 4cefe89d8b..296d0ae368 100644--- a/auto/docs/PARITY.md+++ b/auto/docs/PARITY.md@@ -928,6 +928,17 @@ explicitly untinted, L728 comment). Constants: `MATCH` L1049, `WRAP` L1050,   (`GearheadHostProbe.kt:37-49,56-73`), session default mirror   (HANDOFF §10). Text format `"$turn · $road"` (`CarDisplay.kt:37-46`) vs   gearhead step/lanes/ETA views — no field mapping exists.+  - [x] RESOLVED (host rework): the mirror is deleted. `CarAppHost`+    binds `MapsCarAppService`, implements the host binders+    (`ICarHost`/`IAppHost`/`INavigationHost`/`IConstraintHost` per the+    `app-1.4.0` contract), hands Maps the nav card's `TextureView` surface+    as a `SurfaceContainer` (Maps draws its own map, same renderer/archive/+    tile cache as the phone), and renders the real `NavigationTemplate`+    into the step header: cue/road, distance, lane arrows from+    `Step.lanes`/`LaneDirection`, remaining-time ETA, and the app's own+    action strip through its `OnClickDelegate`. Ch8 map touches forward+    into the app's `SurfaceCallback` (tap = click, drag = scroll). Empty+    launch tile only when maps is missing or the bind fails. - [x] Nav banner typography is MA-invented. 18sp WHITE CENTER   (`CarDisplay.kt:826-828`) — no gearhead token matches (gearhead nav text   lives in unread `CarAppLayout`/template styles; see §9.1).
auto/protocol/src/main/java/com/vayunmathur/auto/protocol/HostVsMirror.kt
diff --git a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/HostVsMirror.kt b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/HostVsMirror.ktindex 5771e54f77..c0bc06c8f9 100644--- a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/HostVsMirror.kt+++ b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/HostVsMirror.kt@@ -1,67 +1,25 @@ package com.vayunmathur.auto.protocol  /**- * Facts the host-vs-mirror prototype compares (Phase 6, maps-dev).+ * Host readiness for the nav card (host-only, no mirror comparison).  *- * The two paths render the same drive two different ways:- *- * - MIRROR: MA Auto draws the `:library:map` basemap itself (own- *   `SurfaceMapRenderer`, camera, puck and route) into the ch2 video stream.- *   The pixels are ours end to end; the head unit only ever sees H.264.- * - HOST: the `:maps` car app (`MapsCarAppService`, a Car App Library- *   `NAVIGATION` service) renders through a car-app host, and MA Auto would- *   carry the host's surface into ch2 instead of drawing its own map.- *- * All fields are plain data gathered on the Android side by- * `GearheadHostProbe`; the recommendation itself is pure so it stays- * host-testable here.+ * The nav card renders whatever the `:maps` car app publishes through+ * `CarAppHost`: the app's own surface plus its `NavigationTemplate`. There is+ * no second render path to compare against, so this is a readiness record,+ * not a recommendation -- the card hosts when ready and shows the launch tile+ * otherwise.  */ data class HostFacts(     /** The `:maps` car-app service resolves through PackageManager. */     val mapsServicePresent: Boolean,     /** Our package holds `SYSTEM_AUTOMOTIVE_PROJECTION` (trusted display + injection). */     val holdsProjectionRole: Boolean,-    /** The car-app host connection (`app-projected`) is on the classpath. */+    /** The car-app host library (`androidx.car.app:app`) is on the classpath. */     val hostLibraryPresent: Boolean, ) -data class MirrorFacts(-    /** `:library:map`'s renderer class loads (native Vulkan still gates first frame). */-    val rendererPresent: Boolean,-    /** Phone GPS is available for the puck and camera. */-    val locationAvailable: Boolean,-    /** An active route is overlaid (guidance), or null when idle map only. */-    val routeActive: Boolean,-)--//** Which path the session should render maps through. */-enum class MapsPath {-    /** Draw our own basemap into ch2; host stays a prototype. */-    MIRROR,--    /** Carry the car-app host's surface into ch2 instead. */-    HOST,-}--/**- * Pure host-vs-mirror recommendation (Phase 6 prototype comparison).- *- * Mirror wins by default and host needs a measured win, per the plan:- * the head unit only ever sees our ch2 H.264, so the host path adds a- * second renderer, a service bind and a template round-trip without- * changing a single wire byte. Host is recommended only when every host- * fact holds AND the mirror cannot draw (no renderer, no location): a- * host surface with no position is still a map, while no renderer at all- * is a black card.- */-object HostVsMirror {--    fun recommend(host: HostFacts, mirror: MirrorFacts): MapsPath {-        if (mirror.rendererPresent) return MapsPath.MIRROR-        val hostReady = host.mapsServicePresent &&-            host.holdsProjectionRole &&-            host.hostLibraryPresent-        if (hostReady && !mirror.locationAvailable) return MapsPath.HOST-        return MapsPath.MIRROR-    }+/** Whether the nav card can host the maps app right now. */+object HostReadiness {+    fun ready(host: HostFacts): Boolean =+        host.mapsServicePresent && host.holdsProjectionRole && host.hostLibraryPresent }
auto/protocol/src/main/java/com/vayunmathur/auto/protocol/MapsGuidance.kt
diff --git a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/MapsGuidance.kt b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/MapsGuidance.ktindex d192292338..e9ac8e6a88 100644--- a/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/MapsGuidance.kt+++ b/auto/protocol/src/main/java/com/vayunmathur/auto/protocol/MapsGuidance.kt@@ -12,8 +12,8 @@ import kotlin.math.roundToLong  * One point of the active route polyline, in degrees.  *  * Own data class rather than `:library:map`'s `GeoPoint`: `auto/protocol`- * stays Android-free and must not take a renderer dependency. The car mirror- * (`CarMapsMirror`) maps these onto `GeoPoint` one for one.+ * stays Android-free and must not take a renderer dependency. The pre-host+ * nav banner reads road/maneuver/distance straight off the snapshot.  */ data class MapRoutePoint(     val longitude: Double,@@ -27,7 +27,9 @@ data class MapRoutePoint(  * maps-module route provider) and consumed three ways: folded into  * [SensorSnapshot] through [MapsGuidance.toSensorEvents] for the ch7 live  * values, posted onto ch10 through [NavStatusUpdate] for the cluster, and- * rendered by `CarMapsMirror` into the ch2 video stream.+ * shown on the pre-host nav banner until the hosted `NavigationTemplate`+ * takes over (the hosted map surface itself comes from the maps app, not+ * from this snapshot).  *  * Plain data, no Android types, so the whole mapping is host-testable. A  * snapshot with [guidanceActive] false and a null [route] is the idle map:
auto/protocol/src/test/java/com/vayunmathur/auto/protocol/HostVsMirrorTest.kt
diff --git a/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/HostVsMirrorTest.kt b/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/HostVsMirrorTest.ktindex e8986431da..3db22fd3a3 100644--- a/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/HostVsMirrorTest.kt+++ b/auto/protocol/src/test/java/com/vayunmathur/auto/protocol/HostVsMirrorTest.kt@@ -2,10 +2,13 @@ package com.vayunmathur.auto.protocol  import kotlin.test.Test import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue  /**- * Pins the host-vs-mirror default (Phase 6, maps-dev): mirror wins unless- * the host is fully ready AND the mirror cannot draw at all.+ * Pins host readiness for the nav card: hosting needs all three facts+ * (maps service, projection role, host library); anything less shows the+ * launch tile. No mirror path exists to fall back to.  */ class HostVsMirrorTest { @@ -14,70 +17,30 @@ class HostVsMirrorTest {         holdsProjectionRole = true,         hostLibraryPresent = true,     )-    private val fullMirror = MirrorFacts(-        rendererPresent = true,-        locationAvailable = true,-        routeActive = true,-    )--    @Test-    fun `mirror wins when it can draw, even with a ready host`() {-        assertEquals(MapsPath.MIRROR, HostVsMirror.recommend(readyHost, fullMirror))-    }--    @Test-    fun `mirror wins with no host at all`() {-        val noHost = HostFacts(-            mapsServicePresent = false,-            holdsProjectionRole = false,-            hostLibraryPresent = false,-        )-        assertEquals(MapsPath.MIRROR, HostVsMirror.recommend(noHost, fullMirror))-    }      @Test-    fun `host wins only when ready and the mirror has no renderer and no location`() {-        val deadMirror = MirrorFacts(-            rendererPresent = false,-            locationAvailable = false,-            routeActive = false,-        )-        assertEquals(MapsPath.HOST, HostVsMirror.recommend(readyHost, deadMirror))+    fun `host is ready when every fact holds`() {+        assertTrue(HostReadiness.ready(readyHost))     }      @Test-    fun `missing any one host fact keeps the mirror`() {-        val deadMirror = MirrorFacts(-            rendererPresent = false,-            locationAvailable = false,-            routeActive = false,-        )+    fun `missing any one host fact means not ready`() {         for (missing in listOf(             readyHost.copy(mapsServicePresent = false),             readyHost.copy(holdsProjectionRole = false),             readyHost.copy(hostLibraryPresent = false),         )) {-            assertEquals(MapsPath.MIRROR, HostVsMirror.recommend(missing, deadMirror))+            assertFalse(HostReadiness.ready(missing))         }     }      @Test-    fun `location alone keeps the mirror - last-known still draws a map`() {-        val noRendererButLocated = MirrorFacts(-            rendererPresent = false,-            locationAvailable = true,-            routeActive = false,-        )-        assertEquals(MapsPath.MIRROR, HostVsMirror.recommend(readyHost, noRendererButLocated))-    }--    @Test-    fun `route state never flips the decision`() {-        val idle = MirrorFacts(-            rendererPresent = true,-            locationAvailable = true,-            routeActive = false,+    fun `no host at all means not ready`() {+        val noHost = HostFacts(+            mapsServicePresent = false,+            holdsProjectionRole = false,+            hostLibraryPresent = false,         )-        assertEquals(MapsPath.MIRROR, HostVsMirror.recommend(readyHost, idle))+        assertFalse(HostReadiness.ready(noHost))     } }
auto/src/main/AndroidManifest.xml
diff --git a/auto/src/main/AndroidManifest.xml b/auto/src/main/AndroidManifest.xmlindex f4f3dd6ecd..c2590c967c 100644--- a/auto/src/main/AndroidManifest.xml+++ b/auto/src/main/AndroidManifest.xml@@ -20,6 +20,9 @@          (NEARBY_WIFI_DEVICES covers the WiFi half on S+). -->     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />+    <!-- Android 12+ requires COARSE alongside FINE; the guidance monitor+         degrades to last-known without either (fail-closed), never crashes. -->+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />     <uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" />     <!-- Restart the projection listener after a reboot; the session is bound to@@ -34,13 +37,14 @@          is mediaProjection. The capture runs only while consented in-app AND granted          here; either off means fail-closed silence on the head unit. -->     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />-    <!-- Background mic (ch6) and location (ch7) must survive without a visible-         activity on API 34+: the projection service declares the Chimera triple-         (microphone|connectedDevice|location) and each type needs its own-         foreground-service permission. Without these the platform kills the-         background mic/location legs and the channels starve. -->-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />+    <!-- Background survival on API 34+ without a visible activity: the+         projection service declares the connectedDevice type (permission+         declared up top with the base FOREGROUND_SERVICE). The old+         microphone/location types are gone (see the service declaration):+         nothing captures device audio or reads device location directly,+         and claiming them crashed cold start on fresh installs. The runtime+         RECORD_AUDIO / location grants still gate their own features (ch6+         retention, ch7 phone seed) and are requested in-app. -->     <!-- Wireless bring-up (BT_START -> RFCOMM -> TCP): discovery, association          and the socket all need the Bluetooth family. The CDM trigger          (CarCompanionDeviceService) additionally needs the association trio@@ -119,7 +123,7 @@          CHANGE_COMPONENT_ENABLED_STATE, MANAGE_USERS,          CAPTURE_SECURE_VIDEO_OUTPUT, BLUETOOTH_PRIVILEGED,          CONTROL_INCALL_EXPERIENCE and MODIFY_PHONE_STATE. Both halves are-         boot-fatal if wrong -- land one at a time. Gearhead's GMS-signed+         boot-fatal if wrong: land one at a time. Gearhead's GMS-signed          host permissions (NAVIGATION_TEMPLATES, ACCESS_SURFACE,          GEARHEAD_SERVICE, START_PROJECTED_ACTIVITY) are not declarable by          third parties and stay absent on purpose. -->@@ -170,10 +174,18 @@                 android:resource="@xml/usb_accessory_filter" />         </activity> +        <!-- No `microphone`/`location` types: the service never captures+             device audio or reads device location directly. The ch6 mic path+             reads GAL chunks off the socket (acked/counted permission-free;+             RECORD_AUDIO gates only in-memory retention), and the ch7 phone+             seed flows through `NavGuidanceMonitor` (all `runCatching`-+             guarded, degrades to last-known). Claiming either type crashes+             cold start on a fresh install (no grant yet) with+             SecurityException: that was the recurring crash. -->         <service             android:name=".service.ProjectionService"             android:exported="false"-            android:foregroundServiceType="microphone|connectedDevice|location" />+            android:foregroundServiceType="connectedDevice" />         <!-- Holds the media-projection token while music capture runs. Started              only after the user grants the consent dialog (see MusicCaptureGrant):              on API 34+ an FGS with type mediaProjection cannot start before the@@ -314,7 +326,7 @@         </service>          <!-- Head-unit compositor/decor bind targets (exported, like-             gearhead's): binds are safely rejected -- MA renders CarDisplay+             gearhead's): binds are safely rejected: MA renders CarDisplay              into ch2 video rather than hosting HU-composited windows. -->         <service             android:name=".platform.CarSystemUiControllerService"@@ -324,12 +336,13 @@             android:exported="true" />          <!-- Chimera entry point (GMS-compat car.service.START): funnels into-             the projection service. Triple foreground type for background-             mic/location survival. -->+             the projection service. Same single type as ProjectionService+             (no mic/location types: nothing here captures device audio or+             reads device location either). -->         <service             android:name=".platform.CarChimeraService"             android:exported="true"-            android:foregroundServiceType="microphone|connectedDevice|location">+            android:foregroundServiceType="connectedDevice">             <intent-filter>                 <action android:name="car.service.START" />             </intent-filter>
auto/src/main/java/com/vayunmathur/auto/notifications/MessageMirrorService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/notifications/MessageMirrorService.kt b/auto/src/main/java/com/vayunmathur/auto/notifications/MessageMirrorService.ktindex 4697ef8c70..c402a9856d 100644--- a/auto/src/main/java/com/vayunmathur/auto/notifications/MessageMirrorService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/notifications/MessageMirrorService.kt@@ -118,7 +118,7 @@ class MessageMirrorService : NotificationListenerService() {         return null     } -    private companion object {+    companion object {         const val TAG = "MaAuto.MsgMirror"          /**
auto/src/main/java/com/vayunmathur/auto/platform/AutoSessionState.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/AutoSessionState.kt b/auto/src/main/java/com/vayunmathur/auto/platform/AutoSessionState.ktindex 28edde2930..f004a7d388 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/AutoSessionState.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/AutoSessionState.kt@@ -228,6 +228,7 @@ object AutoSessionState {     val audioAcks: StateFlow<Long> = _audioAcks.asStateFlow()      /** TTS utterances that reached the car this session. */+    private val _ttsSpoken = MutableStateFlow(0L)     val ttsSpoken: StateFlow<Long> = _ttsSpoken.asStateFlow()      /** TTS utterances dropped (no sink, bad wav, dead engine) this session. */@@ -239,6 +240,7 @@ object AutoSessionState {     val micTurns: StateFlow<Long> = _micTurns.asStateFlow()      /** ch6 mic chunks acked upstream this session. */+    private val _micAcks = MutableStateFlow(0L)     val micAcks: StateFlow<Long> = _micAcks.asStateFlow()      /** Live telecom calls currently tracked by the InCall owners; 0 with none. */
auto/src/main/java/com/vayunmathur/auto/platform/CarAppHost.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarAppHost.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarAppHost.ktnew file mode 100644index 0000000000..1d23fccaaf--- /dev/null+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarAppHost.kt@@ -0,0 +1,583 @@+package com.vayunmathur.auto.platform++import android.content.ComponentName+import android.content.Context+import android.content.Intent+import android.content.ServiceConnection+import android.content.res.Configuration+import android.os.Handler+import android.os.IBinder+import android.os.Looper+import android.os.RemoteException+import android.util.Log+import android.view.MotionEvent+import android.view.Surface+import androidx.car.app.CarAppService+import androidx.car.app.CarContext+import androidx.car.app.HandshakeInfo+import androidx.car.app.IAppHost+import androidx.car.app.ICarApp+import androidx.car.app.ICarHost+import androidx.car.app.IOnDoneCallback+import androidx.car.app.ISurfaceCallback+import androidx.car.app.OnDoneCallback+import androidx.car.app.SessionInfo+import androidx.car.app.SessionInfoIntentEncoder+import androidx.car.app.SurfaceContainer+import androidx.car.app.constraints.IConstraintHost+import androidx.car.app.model.CarText+import androidx.car.app.model.Distance+import androidx.car.app.model.TemplateWrapper+import androidx.car.app.navigation.INavigationHost+import androidx.car.app.navigation.model.LaneDirection+import androidx.car.app.navigation.model.NavigationTemplate+import androidx.car.app.navigation.model.RoutingInfo+import androidx.car.app.navigation.model.TravelEstimate+import androidx.car.app.serialization.Bundleable+import java.security.InvalidParameterException+import java.util.concurrent.CountDownLatch+import java.util.concurrent.TimeUnit+import java.util.concurrent.atomic.AtomicReference+import kotlin.concurrent.thread++/**+ * The car-app host: binds the `:maps` car-app service and implements the host+ * binders so the nav card renders whatever Maps already publishes.+ *+ * How Android car apps actually work: the app (`MapsCarAppService` ->+ * `MapsSession` -> `NavMapScreen`) draws its own map into a **host-owned+ * [Surface]** (`AppManager.setSurfaceCallback` -> `CarMapRenderer.onSurfaceAvailable`)+ * and publishes a [NavigationTemplate] (maneuvers, lanes, ETA) through+ * `IAppManager.getTemplate`. The host supplies the surface, fetches the+ * template, and renders it. MA Auto is that host; the head unit only ever sees+ * our ch2 H.264, which composites the hosted surface like any other view.+ *+ * Binder contract (all from `app-1.4.0` bytecode: `CarAppService`,+ * `CarAppBinder`, `HostDispatcher`, `RemoteUtils`, `ScreenManager`):+ * - bind with `SERVICE_INTERFACE` + `SessionInfo(main, MAIN)` encoded; the+ *   service keys one `CarAppBinder` per session id.+ * - `onHandshakeCompleted(HandshakeInfo(pkg, 1))`: level 1 always passes the+ *   min/max gate (maps declares min 1), so the `ALLOW_ALL` validator and the+ *   range check both succeed.+ * - `onAppCreate(carHost, intent, config, cb)` -> `onAppStart` -> `onAppResume`,+ *   each acked through [IOnDoneCallback]; the app builds its session and screen+ *   off `onAppCreate` on its own main thread.+ * - `getManager("app")` returns the `IAppManager` binder inside the success+ *   `Bundleable` (binders ride `Bundle.putBinder`); `getTemplate` on it returns+ *   the `TemplateWrapper` for the top screen.+ * - the app pushes `setSurfaceCallback(ISurfaceCallback)` through our+ *   [IAppHost]; we answer with `onSurfaceAvailable(Bundleable(SurfaceContainer))`+ *   from the nav card's `TextureView`, and `onSurfaceDestroyed` on teardown.+ *   The service owns the `Surface`; the app never releases it.+ * - `invalidate()` means "template changed": re-pull via getManager/getTemplate+ *   and forward to [onTemplate].+ * - `getHost("navigation")` / `getHost("constraints")` serve the managers+ *   `MapsSession`/`NavMapScreen` actually request; anything else throws+ *   `InvalidParameterException` exactly like `HostDispatcher.getHost` does.+ *+ * Threading: `bind()` may be called from any thread; every blocking binder+ * round-trip runs on a background thread, never main. `setSurface` hops off+ * the caller (the `TextureView` callback is main, and the app's answer may+ * block); `clearSurface` stays synchronous so the service can release the+ * surface on return. Template callbacks post to main.+ */+class CarAppHost(+    context: Context,+    private val onTemplate: (HostNavState) -> Unit = {},+) {+    private val appContext = context.applicationContext+    private val mainHandler = Handler(Looper.getMainLooper())++    @Volatile private var carApp: ICarApp? = null+    @Volatile private var surfaceCallback: ISurfaceCallback? = null+    @Volatile private var bound = false+    @Volatile private var handshakeDone = false++    private var localSurface: Surface? = null+    private var localWidth = 0+    private var localHeight = 0+    private var localDpi = DEFAULT_DPI++    private var connection: ServiceConnection? = null++    /** Whether the maps car-app service resolves (empty tile when false). */+    fun hasMapsService(): Boolean = runCatching {+        val component = ComponentName(MAPS_PACKAGE, MAPS_CAR_SERVICE_CLASS)+        val info = appContext.packageManager.getServiceInfo(component, 0)+        info.enabled+    }.getOrDefault(false)++    /** Binds the maps service; no-op when already bound or when maps is missing. */+    fun bind() {+        if (bound) return+        if (!hasMapsService()) {+            Log.i(TAG, "maps car service missing; nav card stays a launch tile")+            mainHandler.post { onTemplate(HostNavState(mapsPresent = false)) }+            return+        }+        val intent = Intent(CarAppService.SERVICE_INTERFACE).apply {+            component = ComponentName(MAPS_PACKAGE, MAPS_CAR_SERVICE_CLASS)+            addCategory(CarAppService.CATEGORY_NAVIGATION_APP)+            SessionInfoIntentEncoder.encode(SessionInfo(SessionInfo.DISPLAY_TYPE_MAIN, SESSION_ID), this)+        }+        val conn = object : ServiceConnection {+            override fun onServiceConnected(name: ComponentName?, binder: IBinder?) {+                if (binder == null) return+                thread(name = "ma-auto-carhost", isDaemon = true) {+                    runHandshake(ICarApp.Stub.asInterface(binder))+                }+            }++            override fun onServiceDisconnected(name: ComponentName?) {+                carApp = null+                bound = false+                handshakeDone = false+                mainHandler.post { onTemplate(HostNavState(mapsPresent = true, connected = false)) }+            }+        }+        connection = conn+        val ok = runCatching {+            appContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)+        }.getOrDefault(false)+        bound = ok+        if (!ok) {+            Log.w(TAG, "bindService to maps failed; nav card stays a launch tile")+            mainHandler.post { onTemplate(HostNavState(mapsPresent = true, connected = false)) }+        }+    }++    /**+     * Hands the nav card's `TextureView` surface to the maps app.+     * Safe from any thread; the binder answer hops off the caller.+     */+    fun setSurface(surface: Surface, widthPx: Int, heightPx: Int) {+        localSurface = surface+        localWidth = widthPx+        localHeight = heightPx+        localDpi = appContext.resources.displayMetrics.densityDpi+        thread(name = "ma-auto-carhost-surface", isDaemon = true) { pushSurface() }+    }++    /**+     * The `TextureView` went away; tells the app synchronously so the service+     * can release the surface on return (same contract as `CarMapRenderer`:+     * the host releases the `Surface` as soon as this returns).+     */+    fun clearSurface() {+        val cb = surfaceCallback+        val last = localSurface+        localSurface = null+        if (cb != null && last != null) {+            runCatching {+                val container = SurfaceContainer(last, localWidth, localHeight, localDpi)+                bundleOf(container)?.let { cb.onSurfaceDestroyed(it, doneCallback()) }+            }.onFailure { Log.w(TAG, "onSurfaceDestroyed failed", it) }+        }+    }++    /** Pushes night as a configuration change; the app restyles its own map. */+    fun setNight(dark: Boolean) {+        val app = carApp ?: return+        if (!handshakeDone) return+        thread(name = "ma-auto-carhost-night", isDaemon = true) {+            runCatching {+                val config = Configuration(appContext.resources.configuration).apply {+                    uiMode = (uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()) or+                        if (dark) Configuration.UI_MODE_NIGHT_YES else Configuration.UI_MODE_NIGHT_NO+                }+                app.onConfigurationChanged(config, doneCallback())+            }.onFailure { Log.w(TAG, "onConfigurationChanged failed", it) }+        }+    }++    /**+     * Forwards one head-unit touch frame on the map surface to the app.+     * Main thread only (called from the nav card's touch listener).+     *+     * The car-app `SurfaceCallback` speaks gestures, not raw touches: a press+     * that moves beyond slop drags the map (`onScroll` with the delta), and a+     * press that releases without moving lands a click (`onClick`). Returns+     * whether the app consumed the frame (false with no surface callback+     * registered yet).+     */+    fun injectMapTouch(action: Int, xPx: Float, yPx: Float): Boolean {+        val cb = surfaceCallback ?: return false+        return runCatching {+            when (action) {+                MotionEvent.ACTION_DOWN -> {+                    lastTouchX = xPx+                    lastTouchY = yPx+                    touchMoved = false+                }+                MotionEvent.ACTION_MOVE -> {+                    val dx = xPx - lastTouchX+                    val dy = yPx - lastTouchY+                    if (!touchMoved && (dx * dx + dy * dy) < TOUCH_SLOP_PX_SQ) {+                        return true+                    }+                    touchMoved = true+                    lastTouchX = xPx+                    lastTouchY = yPx+                    cb.onScroll(dx, dy)+                }+                MotionEvent.ACTION_UP -> {+                    lastTouchX = xPx+                    lastTouchY = yPx+                    if (!touchMoved) cb.onClick(xPx, yPx)+                    touchMoved = false+                }+                MotionEvent.ACTION_CANCEL -> {+                    touchMoved = false+                }+                else -> return false+            }+            true+        }.getOrDefault(false)+    }++    @Volatile private var lastTouchX = 0f+    @Volatile private var lastTouchY = 0f+    @Volatile private var touchMoved = false++    /** Tears the session down; the service still owns the `Surface`. */+    fun unbind() {+        clearSurface()+        val app = carApp+        carApp = null+        handshakeDone = false+        if (app != null) {+            runCatching { app.onAppPause(doneCallback()) }+            runCatching { app.onAppStop(doneCallback()) }+        }+        connection?.let { runCatching { appContext.unbindService(it) } }+        connection = null+        bound = false+        surfaceCallback = null+    }++    // ----------------------------------------------------------------+    // Handshake (background thread only)+    // ----------------------------------------------------------------++    private fun runHandshake(app: ICarApp) {+        carApp = app+        val handshake = bundleOf(HandshakeInfo(appContext.packageName, HOST_API_LEVEL)) ?: return+        if (!roundTrip("onHandshakeCompleted") { cb -> app.onHandshakeCompleted(handshake, cb) }) return+        val config = Configuration(appContext.resources.configuration)+        val intent = Intent(Intent.ACTION_MAIN)+        if (!roundTrip("onAppCreate") { cb -> app.onAppCreate(carHostBinder, intent, config, cb) }) return+        if (!roundTrip("onAppStart") { cb -> app.onAppStart(cb) }) return+        if (!roundTrip("onAppResume") { cb -> app.onAppResume(cb) }) return+        handshakeDone = true+        mainHandler.post { onTemplate(HostNavState(mapsPresent = true, connected = true)) }+        fetchTemplate()+        // A surface that arrived before the app registered its callback still+        // needs its first push (already on this background thread).+        pushSurface()+    }++    /** Serializes one host object; null when the Bundler refuses it. */+    private fun bundleOf(value: Any): Bundleable? = runCatching {+        Bundleable.create(value)+    }.getOrNull()++    /** One blocking binder call with a 5s cap; false means the session is dead. */+    private fun roundTrip(name: String, call: (IOnDoneCallback) -> Unit): Boolean {+        val latch = CountDownLatch(1)+        val failure = AtomicReference<Throwable?>(null)+        val cb = object : IOnDoneCallback.Stub() {+            override fun onSuccess(response: Bundleable?) {+                latch.countDown()+            }++            override fun onFailure(response: Bundleable?) {+                failure.set(RuntimeException("$name failed: $response"))+                latch.countDown()+            }+        }+        runCatching { call(cb) }.onFailure {+            Log.w(TAG, "$name binder call threw", it)+            return false+        }+        val done = runCatching { latch.await(CALL_TIMEOUT_MS, TimeUnit.MILLISECONDS) }.getOrDefault(false)+        if (!done) Log.w(TAG, "$name timed out")+        failure.get()?.let { Log.w(TAG, "$name rejected", it) }+        return done && failure.get() == null+    }++    /** Pulls the current template and forwards the nav state. Background thread. */+    private fun fetchTemplate() {+        val app = carApp ?: return+        // The success payload deserializes through `Bundler`: the manager+        // stub is an `IInterface`, so `deserializeIInterface` returns the+        // `IAppManager` proxy itself (via `Stub.asInterface`), never a raw+        // `IBinder`. Cast to the interface, not the binder.+        val managerRef = AtomicReference<androidx.car.app.IAppManager?>(null)+        val latch = CountDownLatch(1)+        val managerCb = object : IOnDoneCallback.Stub() {+            override fun onSuccess(response: Bundleable?) {+                managerRef.set(runCatching { response?.get() as? androidx.car.app.IAppManager }.getOrNull())+                latch.countDown()+            }++            override fun onFailure(response: Bundleable?) {+                latch.countDown()+            }+        }+        runCatching { app.getManager(CarContext.APP_SERVICE, managerCb) }+            .onFailure { Log.w(TAG, "getManager threw", it); return }+        latch.await(CALL_TIMEOUT_MS, TimeUnit.MILLISECONDS)+        val manager = managerRef.get() ?: run {+            Log.w(TAG, "getManager returned no manager")+            return+        }+        val templateRef = AtomicReference<Any?>(null)+        val templateLatch = CountDownLatch(1)+        val templateCb = object : IOnDoneCallback.Stub() {+            override fun onSuccess(response: Bundleable?) {+                templateRef.set(runCatching { response?.get() }.getOrNull())+                templateLatch.countDown()+            }++            override fun onFailure(response: Bundleable?) {+                templateLatch.countDown()+            }+        }+        runCatching { manager.getTemplate(templateCb) }+            .onFailure { Log.w(TAG, "getTemplate threw", it); return }+        templateLatch.await(CALL_TIMEOUT_MS, TimeUnit.MILLISECONDS)+        val wrapper = templateRef.get() as? TemplateWrapper+        val state = wrapper?.let { parseTemplate(it) } ?: HostNavState(mapsPresent = true, connected = true)+        mainHandler.post { onTemplate(state) }+    }++    private fun parseTemplate(wrapper: TemplateWrapper): HostNavState {+        val template = runCatching { wrapper.template }.getOrNull()+            ?: return HostNavState(mapsPresent = true, connected = true)+        if (template !is NavigationTemplate) {+            return HostNavState(mapsPresent = true, connected = true)+        }+        val routing = runCatching { template.navigationInfo }.getOrNull() as? RoutingInfo+        val step = routing?.currentStep+        val loading = routing?.isLoading == true+        val navigating = routing != null && !loading+        val lanesText = step?.lanes+            ?.takeIf { it.isNotEmpty() }+            ?.joinToString("  ") { lane -> laneArrows(lane.directions) }+            ?.takeIf { it.isNotBlank() }+        val actions = runCatching { template.actionStrip?.actions }.getOrNull().orEmpty().mapNotNull { action ->+            val title = carText(runCatching { action.title }.getOrNull()) ?: return@mapNotNull null+            val delegate = runCatching { action.onClickDelegate }.getOrNull() ?: return@mapNotNull null+            HostAction(title) {+                thread(name = "ma-auto-carhost-click", isDaemon = true) {+                    // App-side callback, never the host binder one: the+                    // delegate reports back into the app's own dispatch.+                    runCatching { delegate.sendClick(object : OnDoneCallback {}) }+                        .onFailure { Log.w(TAG, "action click failed: $title", it) }+                }+            }+        }+        return HostNavState(+            mapsPresent = true,+            connected = true,+            navigating = navigating,+            loading = loading,+            cue = carText(step?.cue),+            road = carText(step?.road),+            distanceText = routing?.currentDistance?.let { formatDistance(it.displayDistance, it.displayUnit) },+            etaText = runCatching { template.destinationTravelEstimate }.getOrNull()?.let { formatEstimate(it) },+            lanesText = lanesText,+            actions = actions,+        )+    }++    private fun carText(text: CarText?): String? = runCatching {+        text?.toCharSequence()?.toString()?.takeIf { it.isNotBlank() }+    }.getOrNull()++    private fun laneArrows(directions: List<LaneDirection>): String = directions.joinToString("") { dir ->+        when (runCatching { dir.shape }.getOrNull()) {+            LaneDirection.SHAPE_STRAIGHT -> STRAIGHT_ARROW+            LaneDirection.SHAPE_SLIGHT_LEFT -> SLIGHT_LEFT_ARROW+            LaneDirection.SHAPE_SLIGHT_RIGHT -> SLIGHT_RIGHT_ARROW+            LaneDirection.SHAPE_NORMAL_LEFT -> LEFT_ARROW+            LaneDirection.SHAPE_NORMAL_RIGHT -> RIGHT_ARROW+            LaneDirection.SHAPE_SHARP_LEFT -> SHARP_LEFT_ARROW+            LaneDirection.SHAPE_SHARP_RIGHT -> SHARP_RIGHT_ARROW+            LaneDirection.SHAPE_U_TURN_LEFT -> UTURN_LEFT_ARROW+            LaneDirection.SHAPE_U_TURN_RIGHT -> UTURN_RIGHT_ARROW+            else -> UNKNOWN_ARROW+        }+    }++    private fun formatDistance(display: Double, unit: Int): String = when (unit) {+        Distance.UNIT_METERS -> "${display.toInt()} m"+        Distance.UNIT_KILOMETERS,+        Distance.UNIT_KILOMETERS_P1,+        -> "${((display * 10).toInt() / 10.0)} km"+        Distance.UNIT_MILES,+        Distance.UNIT_MILES_P1,+        -> "${((display * 10).toInt() / 10.0)} mi"+        Distance.UNIT_FEET -> "${display.toInt()} ft"+        else -> "${display.toInt()} m"+    }++    private fun formatEstimate(estimate: TravelEstimate): String? {+        val remaining = runCatching { estimate.remainingTimeSeconds }.getOrNull() ?: return null+        if (remaining <= 0 || remaining == Long.MAX_VALUE) return null+        val minutes = (remaining / 60).toInt()+        return if (minutes < 60) "$minutes min" else "${minutes / 60} h ${minutes % 60} min"+    }++    private fun pushSurface() {+        val cb = surfaceCallback ?: return+        val surface = localSurface ?: return+        if (localWidth <= 0 || localHeight <= 0) return+        runCatching {+            bundleOf(SurfaceContainer(surface, localWidth, localHeight, localDpi))+                ?.let { cb.onSurfaceAvailable(it, doneCallback()) }+        }.onFailure { Log.w(TAG, "onSurfaceAvailable failed", it) }+    }++    private fun doneCallback(): IOnDoneCallback = object : IOnDoneCallback.Stub() {+        override fun onSuccess(response: Bundleable?) = Unit+        override fun onFailure(response: Bundleable?) {+            Log.w(TAG, "host call rejected: $response")+        }+    }++    // ----------------------------------------------------------------+    // Host binders (these ARE the host the maps app talks to)+    // ----------------------------------------------------------------++    private val carHostBinder = object : ICarHost.Stub() {+        override fun startCarApp(intent: Intent?) {+            if (intent == null) return+            runCatching {+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)+                appContext.startActivity(intent)+            }.onFailure { Log.w(TAG, "startCarApp failed", it) }+        }++        override fun getHost(hostType: String?): IBinder {+            return when (hostType) {+                CarContext.APP_SERVICE -> appHostBinder.asBinder()+                CarContext.NAVIGATION_SERVICE -> navHostBinder.asBinder()+                CarContext.CONSTRAINT_SERVICE -> constraintHostBinder.asBinder()+                else -> throw InvalidParameterException("Invalid host type: $hostType")+            }+        }++        override fun finish() = Unit+    }++    private val appHostBinder = object : IAppHost.Stub() {+        override fun invalidate() {+            thread(name = "ma-auto-carhost-invalidate", isDaemon = true) { fetchTemplate() }+        }++        override fun showToast(text: CharSequence?, duration: Int) {+            Log.i(TAG, "car toast: $text")+        }++        override fun setSurfaceCallback(callback: ISurfaceCallback?) {+            surfaceCallback = callback+            thread(name = "ma-auto-carhost-surface", isDaemon = true) { pushSurface() }+        }++        override fun sendLocation(location: android.location.Location?) = Unit++        override fun showAlert(alert: Bundleable?) {+            Log.i(TAG, "car alert shown (not rendered)")+        }++        override fun dismissAlert(alertId: Int) = Unit++        override fun openMicrophone(request: Bundleable?): Bundleable {+            // Voice replies ride the ch6 mic source, not the car-app mic path.+            throw RemoteException("openMicrophone not supported")+        }+    }++    private val navHostBinder = object : INavigationHost.Stub() {+        override fun navigationStarted() {+            Log.i(TAG, "maps navigation started")+        }++        override fun navigationEnded() {+            Log.i(TAG, "maps navigation ended")+            mainHandler.post { onTemplate(HostNavState(mapsPresent = true, connected = true)) }+        }++        override fun updateTrip(trip: Bundleable?) = Unit+    }++    private val constraintHostBinder = object : IConstraintHost.Stub() {+        override fun getContentLimit(contentLimitType: Int): Int = CONTENT_LIMIT_DEFAULT++        override fun isAppDrivenRefreshEnabled(): Boolean = false+    }++    private companion object {+        const val TAG = "MaAuto.CarHost"+        const val MAPS_PACKAGE = "com.vayunmathur.maps"+        const val MAPS_CAR_SERVICE_CLASS = "com.vayunmathur.maps.car.MapsCarAppService"+        const val SESSION_ID = "main"+        const val DEFAULT_DPI = 160++        /**+         * Host API level 1: always within [min, max] (maps declares min 1),+         * so the `CarAppBinder` range gate passes on any app version.+         */+        const val HOST_API_LEVEL = 1++        const val CALL_TIMEOUT_MS = 5_000L+        const val CONTENT_LIMIT_DEFAULT = 6++        /**+         * Squared touch slop for tap-vs-drag on the hosted map: a press that+         * moves less than ~8dp is a click, anything more drags. Matches the+         * platform `ViewConfiguration` scaled-touch-slop order (8dp at mdpi).+         */+        const val TOUCH_SLOP_PX_SQ = 64f++        const val STRAIGHT_ARROW = "↑"+        const val SLIGHT_LEFT_ARROW = "⬉"+        const val SLIGHT_RIGHT_ARROW = "⬊"+        const val LEFT_ARROW = "←"+        const val RIGHT_ARROW = "→"+        const val SHARP_LEFT_ARROW = "↰"+        const val SHARP_RIGHT_ARROW = "↱"+        const val UTURN_LEFT_ARROW = "↩"+        const val UTURN_RIGHT_ARROW = "↪"+        const val UNKNOWN_ARROW = "•"+    }+}++/** One template action (Search, End navigation): title plus the app's own click. */+data class HostAction(+    val title: String,+    val onClick: () -> Unit,+)++/**+ * What the maps app is currently publishing, as the nav card renders it.+ *+ * `mapsPresent=false` means the service itself is missing (empty tile);+ * `connected=false` means the bind/handshake failed (tile until the next+ * session). Otherwise the card shows the app's map surface plus these fields,+ * every one GONE-if-empty like the template rows they come from. Actions ride+ * the app's own `OnClickDelegate`, so Search/End behave exactly as in Maps.+ */+data class HostNavState(+    val mapsPresent: Boolean = true,+    val connected: Boolean = true,+    val navigating: Boolean = false,+    val loading: Boolean = false,+    val cue: String? = null,+    val road: String? = null,+    val distanceText: String? = null,+    val etaText: String? = null,+    val lanesText: String? = null,+    val actions: List<HostAction> = emptyList(),+)
auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.ktindex beb7fbc0f6..919b67aa7f 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarDisplay.kt@@ -91,23 +91,34 @@ class CarDisplay(         }      /**-     * Optional night hook for the session's map mirror: invoked from-     * [setNight] on the calling thread (the mirror marshals to main itself).-     * The service sets this to `CarMapsMirror.setDark`; unset means the-     * mirror keeps its own last palette.+     * Optional night hook for the hosted map: invoked from [setNight] on the+     * calling thread. The service sets this to `CarAppHost.setNight`, which+     * forwards night as a configuration change so the app restyles its own+     * palette; unset means the hosted map keeps its own last palette.      */     var mapDarkApplier: ((Boolean) -> Unit)? = null      /** Phone status feed for the rail cluster; the service sets its monitor. */-    var phoneStatusSource: (() -> PhoneStatus)? = null+    var phoneStatusSource: (() -> PhoneStatus?)? = null         set(value) {             field = value             // Late wiring must reach an already-up presentation too: the             // ticker pulls through the inner field, never this one.-            mainHandler.post { presentation?.setInnerPhoneStatusSource(value) }+            value?.let { v -> mainHandler.post { presentation?.setInnerPhoneStatusSource(v) } }         } -    /** Card call actions; the service wires these to the bound InCallService. */+    /**+     * Forwards ch8 touches that land on the map surface to the hosted app.+     * Wired by the session host to `CarAppHost.injectMapTouch`; cached for+     * presentations created later like every other late-wired feed.+     */+    var mapTouchForwarder: ((Int, Float, Float) -> Boolean)? = null+        set(value) {+            field = value+            value?.let { v -> mainHandler.post { presentation?.setMapTouchForwarder(v) } }+        }++    /** Call-card actions; the service wires these to the bound InCallService. */     var onAnswerCall: (() -> Unit)? = null         set(value) {             field = value@@ -131,11 +142,12 @@ class CarDisplay(      /**      * Active-call feed for the projected call card; the service sets the-     * latest [ActiveCallInfo] (null with no live call). Cached for-     * presentations created later.+     * latest [ActiveCallInfo] (null with no live call) through [setActiveCall].+     * Backing field only -- the `var` setter would clash on the JVM with the+     * explicit setter, so all writes go through the function.      */     @Volatile-    var activeCall: ActiveCallInfo? = null+    private var activeCall: ActiveCallInfo? = null      /**      * Latest now-playing snapshot: applied to the card when set, and to any@@ -218,6 +230,9 @@ class CarDisplay(             mapSurfaceForwarder?.let { forward ->                 shown.mapSurfaceListener = { s, w, h -> forward(s, w, h) }             }+            mapTouchForwarder?.let { forward ->+                shown.setMapTouchForwarder(forward)+            }         }         dumpVirtualDisplay(display.display, surface)     }@@ -306,8 +321,8 @@ class CarDisplay(      * Switches the car UI between day and night palettes. Safe from any thread.      *      * Recolors root/rail/cards/drawer per the §2.3 night deltas and forwards-     * to the session mirror through [mapDarkApplier] (the service wires it-     * to `CarMapsMirror.setDark`; the mirror marshals to main itself). Night+     * to the hosted map through [mapDarkApplier] (the service wires it+     * to `CarAppHost.setNight`). Night      * sources already in the tree: `ProjectionService.isNightNow` and the      * `SensorChannel` `NightSource` -- the service picks one and calls here,      * and the cached value replays onto presentations created later.@@ -327,6 +342,20 @@ class CarDisplay(         mainHandler.post { presentation?.updateCallCard(info) }     } +    /**+     * Pushes one hosted template state to the nav card. Safe from any thread;+     * cached for presentations created later. The card shows the template's+     * cue/road, distance, lanes, ETA and actions; the map surface itself+     * arrives separately through [setMapSurfaceListener].+     */+    fun setHostNavState(state: HostNavState) {+        hostNavState = state+        mainHandler.post { presentation?.updateHostNav(state) }+    }++    /** Latest hosted template state; cached for presentations created later. */+    @Volatile private var hostNavState: HostNavState? = null+     /**      * Pushes one guidance snapshot to the nav banner, if the render pair is      * up. The service calls this on every guidance-monitor update; the banner@@ -588,6 +617,7 @@ class CarDisplay(             throw e.cause ?: e         }     }+     /**      * Now-playing card bounds in display pixels, for ch8 tap routing.      * Compared in presentation root-view coordinates, which are 1:1 with
auto/src/main/java/com/vayunmathur/auto/platform/CarDrawerView.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarDrawerView.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarDrawerView.ktindex 0a1904e313..a9410260e4 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarDrawerView.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarDrawerView.kt@@ -606,7 +606,10 @@ internal class DrawerContainer(context: Context) : FrameLayout(context) {     private var downX = 0f      init {-        isFocusable = View.NOT_FOCUSABLE+        // NOT_FOCUSABLE is an int constant for `focusable` XML / focusable+        // mode APIs, not the boolean setter: the container must not take+        // focus so head-unit keys keep reaching the content behind it.+        focusable = View.NOT_FOCUSABLE     }      override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
auto/src/main/java/com/vayunmathur/auto/platform/CarMapsMirror.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarMapsMirror.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarMapsMirror.ktdeleted file mode 100644index 4ff55f6927..0000000000--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarMapsMirror.kt+++ /dev/null@@ -1,195 +0,0 @@-package com.vayunmathur.auto.platform--import android.content.Context-import android.os.Handler-import android.os.Looper-import android.util.Log-import android.view.Surface-import com.vayunmathur.auto.protocol.NavSnapshot-import com.vayunmathur.library.map.GeoPoint-import com.vayunmathur.library.map.LayerOptions-import com.vayunmathur.library.map.MapRenderState-import com.vayunmathur.library.map.SurfaceMapRenderer-import com.vayunmathur.library.map.UserPuck--/**- * Draws the phone map into the car video stream (Phase 6 mirror path).- *- * This is the short-term Maps answer from the plan: with no gearhead host- * binding, MA Auto renders the `:library:map` basemap itself -- same- * renderer, archive and tile cache the phone map uses -- onto an offscreen- * [Surface] whose frames join the ch2 path, while Phase 2 touch pans it.- *- * Two surfaces, two renderers, one map state: the encoder keeps its own- * input surface (the `CarDisplay` virtual display composites into it), and- * this mirror draws into [mirrorSurface] with its own `SurfaceMapRenderer`.- * The service composites or switches between them per the session's- * [com.vayunmathur.auto.protocol.MapsPath] -- that composition is the- * bring-up owner's work (see the Phase 6 handoff to the service owner in- * `auto/docs/HANDOFF.md` §10), not this file's: this file only draws a map- * into a surface it is handed.- *- * Threading follows `SurfaceMapRenderer`'s own rule: every call on the main- * thread. [render] and [setSurface] marshal onto [mainHandler] so the- * guidance monitor's worker-thread snapshots stay safe; destruction is- * synchronous on main like `CarMapRenderer.teardown`.- *- * Route identity (not equality) gates the route push, matching- * `NavMapScreen.pushedRoute`: the native side tessellates on every `set`- * call, so pushing an equal-but-new list per GPS fix would re-tessellate a- * cross-city route a few times a second.- */-class CarMapsMirror(-    context: Context,-    private val density: Float = 1f,-) {-    private val appContext = context.applicationContext-    private val mainHandler = Handler(Looper.getMainLooper())--    private var renderer: SurfaceMapRenderer? = null-    private var mirrorSurface: Surface? = null-    private var mirrorWidth = 0-    private var mirrorHeight = 0--    /**-     * Last night state from [setDark], replayed onto every fresh renderer in-     * [attach]. The basemap palette is free (push constant, no-     * re-tessellation), so a surface recreation never flashes the wrong-     * theme.-     */-    @Volatile private var dark = false--    /** The route polyline already on the GPU, by identity. */-    private var pushedRoute: List<GeoPoint>? = null--    private val isMainThread get() = Looper.myLooper() == Looper.getMainLooper()--    /**-     * Attaches the mirror to [surface] at [widthPx] x [heightPx] pixels.-     *-     * The caller owns [surface] (encoder input or an offscreen target) and-     * must not release it before [release]. Re-attaching tears the previous-     * renderer down first, replaying camera/puck/route on the new one like-     * `CarMapRenderer.onSurfaceAvailable`.-     */-    fun setSurface(surface: Surface, widthPx: Int, heightPx: Int) {-        if (isMainThread) attach(surface, widthPx, heightPx)-        else mainHandler.post { attach(surface, widthPx, heightPx) }-    }--    /**-     * Renders one guidance snapshot into the mirror. Safe from any thread;-     * the push marshals onto main.-     *-     * No-op until [setSurface]: a fix before the surface exists is dropped,-     * and the next fix repaints -- positions arrive at ~1 Hz, so nothing-     * worth queuing is lost. Map follows the system theme through-     * [setDark]; idle (no route) draws north-up with the puck, navigating-     * draws heading-up with the route.-     */-    fun render(snapshot: NavSnapshot) {-        if (isMainThread) push(snapshot)-        else mainHandler.post { push(snapshot) }-    }--    /** Switches the basemap palette; free (push constant, no re-tessellation). */-    fun setDark(dark: Boolean) {-        this.dark = dark-        if (isMainThread) renderer?.setPalette(dark = dark, muted = false)-        else mainHandler.post { renderer?.setPalette(dark = dark, muted = false) }-    }--    /** Tears the renderer down; the caller still owns and releases the surface. */-    fun release() {-        if (isMainThread) teardown()-        else mainHandler.post { teardown() }-    }--    /** Whether the last attach produced a drawing renderer. */-    fun isRendering(): Boolean = renderer?.renderState is MapRenderState.Rendering--    private fun attach(surface: Surface, widthPx: Int, heightPx: Int) {-        if (widthPx <= 0 || heightPx <= 0) return-        teardown()-        mirrorSurface = surface-        mirrorWidth = widthPx-        mirrorHeight = heightPx-        val created = runCatching {-            SurfaceMapRenderer(appContext, density).apply {-                setPalette(dark = dark, muted = false)-                setLayers(CAR_LAYERS)-                attachSurface(surface, widthPx, heightPx)-            }-        }.getOrNull() ?: run {-            Log.e(TAG, "car map mirror will not draw: renderer creation failed")-            return-        }-        val state = created.renderState-        if (state is MapRenderState.Unavailable) {-            Log.e(TAG, "car map mirror will not draw: ${state.reason}")-            created.destroy()-            return-        }-        // The route outlives a surface recreation (host rebind, backgrounding):-        // replay the tessellated mesh so the first frame already has it.-        pushedRoute?.let { created.setRoute(it) }-        created.start()-        renderer = created-    }--    private fun push(snapshot: NavSnapshot) {-        val active = renderer ?: return-        val position = GeoPoint(-            longitude = snapshot.longitudeE7 / E7,-            latitude = snapshot.latitudeE7 / E7,-        )-        active.setUserPuck(-            UserPuck(position = position, bearing = snapshot.bearingDeg),-        )-        val route = snapshot.route-        val navigating = snapshot.guidanceActive && route != null-        if (navigating && route != null) {-            val points = route.map { GeoPoint(it.longitude, it.latitude) }-            // Identity gate: the monitor forwards the provider's list-            // untouched, so an unchanged route skips the tessellation.-            if (points !== pushedRoute) {-                pushedRoute = points-                active.setRoute(points)-            }-            active.camera = com.vayunmathur.library.map.CameraPosition(-                target = position,-                zoom = NAVIGATING_ZOOM,-                bearing = snapshot.bearingDeg?.toDouble() ?: 0.0,-            )-        } else {-            if (pushedRoute != null) {-                pushedRoute = null-                active.setRoute(points = null)-            }-            active.camera = com.vayunmathur.library.map.CameraPosition(-                target = position,-                zoom = IDLE_ZOOM,-            )-        }-    }--    private fun teardown() {-        renderer?.destroy()-        renderer = null-        mirrorSurface = null-        pushedRoute = null-    }--    private companion object {-        const val TAG = "MaAuto.Maps"--        /** Same layers as the car-app host path (`CarMapRenderer.CAR_LAYERS`). */-        val CAR_LAYERS = LayerOptions(poi = true, transit = false)--        /** Matches `NavMapScreen`: navigating zooms in, idle shows context. */-        const val NAVIGATING_ZOOM = 17.0-        const val IDLE_ZOOM = 15.0--        const val E7 = 10_000_000.0-    }-}
auto/src/main/java/com/vayunmathur/auto/platform/CarNavCard.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarNavCard.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarNavCard.ktindex eeb7af79c3..9226b25497 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarNavCard.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarNavCard.kt@@ -4,10 +4,10 @@ import android.content.Context import android.graphics.Color import android.graphics.SurfaceTexture import android.view.Gravity+import android.view.MotionEvent import android.view.Surface import android.view.TextureView import android.view.View-import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView@@ -21,23 +21,29 @@ import com.vayunmathur.auto.platform.CarUiMetrics.MATCH import com.vayunmathur.auto.platform.CarUiMetrics.WRAP  /**- * The nav half of the split: live map (`CarMapsMirror` into a- * `TextureView`) with the guidance step header only while guidance- * is active. Without Maps data this still draws the basemap + puck- * from phone GPS; the step views stay GONE idle (never faked), and- * only when no map backend exists at all does the launch tile show.+ * The nav half of the split: the maps app's own surface (hosted through+ * [CarAppHost] into a `TextureView`) with the guidance step header driven by+ * the app's real `NavigationTemplate`.  *- * The step header maps `DetailedNavigationStepView` +- * `NavigationTravelEstimateView`: turn symbol / distance /- * description + lanes image / containers + arrival / time-distance,- * every field GONE-if-empty. `NavSnapshot` carries no lane art, ETA,- * or arrival time, so those slots stay GONE (stubbed, not guessed);- * the banner + distance it does carry render live.+ * How the card works:+ * - [mapSurfaceListener] forwards the `TextureView` surface to [CarAppHost],+ *   which hands it to Maps as a `SurfaceContainer`; Maps draws its own map+ *   (same renderer, archive and tile cache as the phone) into it.+ * - [updateHost] renders the `NavigationTemplate` fields: cue/road banner,+ *   distance, lanes, ETA, and the app's own action strip (Search, End).+ *   Every field is GONE-if-empty; the "no lane art, no ETA" stubs are gone+ *   because the template carries them.+ * - [update] (the `NavSnapshot` path) is the pre-host fallback: banner ++ *   distance only, shown only while the host is not connected.+ * - only when no map backend exists at all -- maps missing, or the bind+ *   failed -- does the launch tile show.  *- * Owns its views; the presentation drives state through [update] and- * recolors through [setNight]. The map surface forwards to the session- * mirror through [mapSurfaceListener]. Views, not Compose (private- * display, no lifecycle owner).+ * Touches on the map surface forward to the host (pan/zoom/click through the+ * app's own `SurfaceCallback`); the launch tile opens Maps on the phone.+ *+ * Owns its views; the presentation drives state through [updateHost]/[update]+ * and recolors through [setNight]. Views, not Compose (private display, no+ * lifecycle owner).  */ internal class CarNavCardView(     private val context: Context,@@ -49,14 +55,24 @@ internal class CarNavCardView(     private var stepContainer: LinearLayout? = null     private var navDistance: TextView? = null     private var navBanner: TextView? = null+    private var navLanes: TextView? = null+    private var navEta: TextView? = null+    private var actionRow: LinearLayout? = null+    private var tileView: LinearLayout? = null++    /** Whether a hosted template is currently driving the header. */+    private var hostConnected = false      /**      * Receives the nav-card map surface: (surface, w, h), or (null, 0, 0)-     * when the TextureView is destroyed. The session's mirror attaches on+     * when the TextureView is destroyed. The session's host attaches on      * non-null and releases on null; unset means no map backend.      */     var mapSurfaceListener: ((Surface?, Int, Int) -> Unit)? = null +    /** Forwards ch8 touches on the map to the hosted app; unset means no host yet. */+    var mapTouchForwarder: ((action: Int, x: Float, y: Float) -> Boolean)? = null+     /** The assembled card; add once to the split. */     val view: LinearLayout = navCard() @@ -73,16 +89,51 @@ internal class CarNavCardView(         stepContainer = null         navDistance = null         navBanner = null+        navLanes = null+        navEta = null+        actionRow = null+        tileView = null+    }++    /**+     * Renders the hosted app's `NavigationTemplate`. Main thread only.+     *+     * `mapsPresent=false` (or `connected=false`) shows the launch tile; the+     * snapshot path keeps driving the banner until then. Otherwise the header+     * shows the template's cue/road, distance, lanes, ETA and action strip --+     * every row GONE-if-empty, exactly like the template views they mirror.+     */+    fun updateHost(state: HostNavState) {+        hostConnected = state.mapsPresent && state.connected+        tileView?.visibility = if (hostConnected) View.GONE else View.VISIBLE+        if (!hostConnected) {+            stepContainer?.visibility = View.GONE+            return+        }+        setText(navBanner, state.cue?.let { cue ->+            val road = state.road?.takeIf { it.isNotBlank() }+            if (road != null) "$cue · $road" else cue+        })+        setText(navDistance, state.distanceText)+        setText(navLanes, state.lanesText)+        setText(navEta, state.etaText)+        renderActions(state.actions)+        val anyVisible = listOf(navBanner, navDistance, navLanes, navEta).any { it?.visibility == View.VISIBLE } ||+            (actionRow?.visibility == View.VISIBLE)+        val container = stepContainer+        if (container != null) {+            container.visibility = if (anyVisible || state.loading || state.navigating) View.VISIBLE else View.GONE+        }     }      /**-     * Pushes one guidance snapshot to the nav banner. Main thread only.-     * The banner shows only while guidance is active with a road or-     * maneuver to announce; otherwise GONE (idle map, no fake banner).-     * The step container mirrors the banner gate and additionally drives-     * the distance field from `nextTurnDistanceM`.+     * Pushes one guidance snapshot to the nav banner (pre-host fallback).+     * Main thread only. Ignored once a hosted template is driving the header;+     * the banner shows only while guidance is active with a road or maneuver+     * to announce, otherwise GONE (idle map, no fake banner).      */     fun update(snapshot: NavSnapshot) {+        if (hostConnected) return         val banner = navBanner ?: return         val road = snapshot.nextRoad?.takeIf { it.isNotBlank() }         val turn = snapshot.maneuver?.takeIf { it.isNotBlank() }@@ -116,6 +167,45 @@ internal class CarNavCardView(             }     } +    private fun setText(view: TextView?, text: String?) {+        if (view == null) return+        if (text != null) {+            view.text = text+            view.visibility = View.VISIBLE+        } else {+            view.visibility = View.GONE+        }+    }++    private fun renderActions(actions: List<HostAction>) {+        val row = actionRow ?: return+        row.removeAllViews()+        if (actions.isEmpty()) {+            row.visibility = View.GONE+            return+        }+        row.visibility = View.VISIBLE+        for (action in actions.take(MAX_ACTIONS)) {+            row.addView(+                TextView(context).apply {+                    text = action.title+                    textSize = 18f+                    setTextColor(Color.WHITE)+                    gravity = Gravity.CENTER+                    setPadding(dp(16), dp(8), dp(16), dp(8))+                    isClickable = true+                    isFocusable = true+                    background = context.carFocusRingBackground()+                    setOnClickListener { action.onClick() }+                    layoutParams = LinearLayout.LayoutParams(WRAP, WRAP).apply {+                        marginStart = dp(4)+                        marginEnd = dp(4)+                    }+                },+            )+        }+    }+     private fun navCard(): LinearLayout {         val maps = apps.firstOrNull {             it.launch.`package` == MAPS_PACKAGE ||@@ -140,8 +230,6 @@ internal class CarNavCardView(                             orientation = LinearLayout.HORIZONTAL                             gravity = Gravity.CENTER_VERTICAL                             layoutParams = LinearLayout.LayoutParams(MATCH, WRAP)-                            // Turn symbol (`turn_symbol`): no maneuver-                            // drawable exists in MA -- GONE stub.                             addView(                                 ImageView(context).apply {                                     visibility = View.GONE@@ -170,43 +258,41 @@ internal class CarNavCardView(                                             navDistance = this                                         },                                     )+                                    // Lane arrows from the template's `Step.lanes`+                                    // (recommended direction per `LaneDirection`).+                                    addView(+                                        TextView(context).apply {+                                            textSize = 20f+                                            setTextColor(Color.WHITE)+                                            gravity = Gravity.CENTER+                                            visibility = View.GONE+                                            navLanes = this+                                        },+                                    )+                                    // Travel estimate (`time_and_distance_text`):+                                    // remaining time from `TravelEstimate`.+                                    addView(+                                        TextView(context).apply {+                                            textSize = 18f+                                            setTextColor(Color.WHITE)+                                            gravity = Gravity.CENTER+                                            visibility = View.GONE+                                            navEta = this+                                        },+                                    )                                 },                             )                         },                     )-                    // Lanes (`lanes_image` + `lanes_container`): no lane-                    // data in `NavSnapshot` -- GONE stubs.-                    addView(-                        ImageView(context).apply {-                            visibility = View.GONE-                            layoutParams = LinearLayout.LayoutParams(WRAP, WRAP)-                        },-                    )+                    // Template action strip (Search, End navigation): the app's+                    // own actions through its `OnClickDelegate`.                     addView(                         LinearLayout(context).apply {                             orientation = LinearLayout.HORIZONTAL+                            gravity = Gravity.CENTER                             visibility = View.GONE                             layoutParams = LinearLayout.LayoutParams(MATCH, WRAP)-                        },-                    )-                    // Travel estimate (`arrival_time_text` /-                    // `time_and_distance_text`): no ETA in `NavSnapshot`-                    // -- GONE stubs.-                    addView(-                        LinearLayout(context).apply {-                            orientation = LinearLayout.VERTICAL-                            visibility = View.GONE-                            layoutParams = LinearLayout.LayoutParams(MATCH, WRAP)-                            addView(-                                TextView(context).apply {-                                    visibility = View.GONE-                                },-                            )-                            addView(-                                TextView(context).apply {-                                    visibility = View.GONE-                                },-                            )+                            actionRow = this                         },                     )                 },@@ -236,14 +322,42 @@ internal class CarNavCardView(                          override fun onSurfaceTextureUpdated(surface: SurfaceTexture) = Unit                     }+                    setOnTouchListener { _, event ->+                        if (mapTouchForwarder?.invoke(event.action, event.x, event.y) == true) true+                        else false+                    }+                },+            )+            // Empty tile: only visible when no map backend exists at all+            // (maps missing or the host bind failed). Opens Maps on the phone.+            addView(+                LinearLayout(context).apply {+                    orientation = LinearLayout.VERTICAL+                    gravity = Gravity.CENTER+                    visibility = View.GONE+                    layoutParams = LinearLayout.LayoutParams(MATCH, MATCH)+                    tileView = this+                    addView(+                        TextView(context).apply {+                            text = context.getString(R.string.car_nav_open_maps)+                            textSize = 20f+                            setTextColor(Color.WHITE)+                            gravity = Gravity.CENTER+                        },+                    )+                    if (maps != null) {+                        isClickable = true+                        isFocusable = true+                        setOnClickListener { context.startActivity(maps.launch) }+                    }                 },             )-            if (maps != null) {-                isClickable = true-                isFocusable = true-                setOnClickListener { context.startActivity(maps.launch) }-            }             navCardView = this         }     }++    private companion object {+        /** Template strips carry at most a couple of actions; never overflow the card. */+        const val MAX_ACTIONS = 2+    } }
auto/src/main/java/com/vayunmathur/auto/platform/CarPresentation.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarPresentation.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarPresentation.ktindex 7ee89d9a1b..66db5bc45f 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarPresentation.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarPresentation.kt@@ -67,6 +67,9 @@ internal class CarPresentation(     /** Active call that arrived before `onCreate` built the card. */     private var pendingActiveCall: ActiveCallInfo? = initialActiveCall +    /** Hosted template state that arrived before `onCreate`. Consumed once there. */+    private var hostNavState: HostNavState? = null+     /**      * Phone status feed captured from the outer display at construction:      * [CarDisplay.phoneStatusSource] may be wired after `show()` starts@@ -183,6 +186,7 @@ internal class CarPresentation(         val nav = CarNavCardView(context, apps)         navCard = nav         nav.mapSurfaceListener = mapSurfaceListener+        mapTouchForwarder?.let { nav.mapTouchForwarder = it }         val call = CarCallCardView(             context,             onAnswer = { outerOnAnswerCall() },@@ -246,6 +250,8 @@ internal class CarPresentation(          pendingNowPlaying?.let { media.update(it) }         pendingNowPlaying = null+        hostNavState?.let { nav.updateHost(it) }+        hostNavState = null         setDrivingRestricted(pendingDrivingRestricted)         setNight(pendingNight)         pendingActiveCall?.let { call.update(it) }@@ -281,6 +287,16 @@ internal class CarPresentation(         mediaCard?.update(info)     } +    /**+     * Renders one hosted template state on the nav card. Main thread only.+     * Called from `CarDisplay.setHostNavState` on every `CarAppHost`+     * invalidate, and from `onCreate` above for a state that arrived before+     * the views existed.+     */+    fun updateHostNav(state: HostNavState) {+        navCard?.updateHost(state)+    }+     /**      * Pushes one guidance snapshot to the nav card. Main thread only.      * The card shows the banner only while guidance is active with a road@@ -396,6 +412,20 @@ internal class CarPresentation(         outerOnMuteToggle = tap     } +    /**+     * Forwards ch8 touches that land on the map surface to the hosted app.+     * Wired by the session host to `CarAppHost.injectMapTouch` through the+     * display chain; cached for presentations created later like every other+     * late-wired feed. Main thread only.+     */+    fun setMapTouchForwarder(forward: (Int, Float, Float) -> Boolean) {+        mapTouchForwarder = forward+        navCard?.mapTouchForwarder = forward+    }++    /** Forwarder cached for nav cards built later; see [setMapTouchForwarder]. */+    private var mapTouchForwarder: ((Int, Float, Float) -> Boolean)? = null+     /** Late-wired phone-status feed; see the outer setter. Main thread only. */     fun setInnerPhoneStatusSource(source: () -> PhoneStatus?) {         outerPhoneStatusSource = source
auto/src/main/java/com/vayunmathur/auto/platform/CarSetupService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarSetupService.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarSetupService.ktindex d53691250a..cc25fa7fcf 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarSetupService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarSetupService.kt@@ -16,12 +16,6 @@ import android.util.Log  * the phone cannot complete.  */ class CarSetupService : Service() {--    /** Setup handshake action, mirroring gearhead's `CAR_SETUP_SERVICE`. */-    companion object {-        const val ACTION_CAR_SETUP_SERVICE = "com.vayunmathur.auto.CAR_SETUP_SERVICE"-    }-     override fun onBind(intent: Intent?): IBinder? {         // Explicit no-op-with-comment: the HU setup-handshake bind is safely         // rejected (null) -- MA setup is the pairing screen, not a bound@@ -33,7 +27,6 @@ class CarSetupService : Service() {     companion object {         /** Setup handshake action, mirroring gearhead's `CAR_SETUP_SERVICE`. */         const val ACTION_CAR_SETUP_SERVICE = "com.vayunmathur.auto.CAR_SETUP_SERVICE"-         private const val TAG = "MaAuto.CarSetup"     } }
auto/src/main/java/com/vayunmathur/auto/platform/GearheadHostProbe.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/GearheadHostProbe.kt b/auto/src/main/java/com/vayunmathur/auto/platform/GearheadHostProbe.ktdeleted file mode 100644index 093d50bd0c..0000000000--- a/auto/src/main/java/com/vayunmathur/auto/platform/GearheadHostProbe.kt+++ /dev/null@@ -1,116 +0,0 @@-package com.vayunmathur.auto.platform--import android.content.ComponentName-import android.content.Context-import android.location.LocationManager-import android.util.Log-import com.vayunmathur.auto.protocol.HostFacts-import com.vayunmathur.auto.protocol.HostVsMirror-import com.vayunmathur.auto.protocol.MapsPath-import com.vayunmathur.auto.protocol.MirrorFacts--/**- * Gathers the host-vs-mirror facts and renders the pure recommendation.- *- * Each lookup mirrors an existing seam in this module: the maps-service- * lookup follows `CarApps.launcherApp` (which already resolves the- * `com.vayunmathur.maps` tile, so this re-checks the car-app service inside- * it), the role read follows `MaosRoleStatus`, and the host-library probe- * is a `Class.forName` that never hard-links the car-app host -- the auto- * module must not take that dependency until the host path is chosen.- *- * Runs on demand (one report per call), never watched: the recommendation- * feeds the Phase 6 side-by-side report in `auto/docs/HANDOFF.md` §10 and- * the phone debug row, not a live switch. Mirror is the session default- * regardless; a HOST recommendation here is "prototype the host next", not- * "reroute this session".- */-object GearheadHostProbe {--    /**-     * Probes the device and recommends a maps path.-     *-     * @param routeActive whether a route is currently overlaid; from the-     *   guidance monitor's latest snapshot, never read from the maps module-     *   (no cross-module dependency, no shared process).-     */-    fun probe(context: Context, routeActive: Boolean = false): HostReport {-        val host = HostFacts(-            mapsServicePresent = hasMapsCarService(context),-            holdsProjectionRole = MaosRoleStatus.isProjectionRoleHeld(context),-            hostLibraryPresent = hasHostLibrary(),-        )-        val mirror = MirrorFacts(-            rendererPresent = hasMapRenderer(),-            locationAvailable = hasLocation(context),-            routeActive = routeActive,-        )-        return HostReport(host, mirror, HostVsMirror.recommend(host, mirror))-    }--    /**-     * The `:maps` car-app service (`MapsCarAppService`) is declared and-     * enabled. Package-qualified on purpose, like the music service string-     * in `MediaPlaybackMonitor`: no compile dependency on the maps module.-     */-    private fun hasMapsCarService(context: Context): Boolean = runCatching {-        val component = ComponentName(MAPS_PACKAGE, MAPS_CAR_SERVICE_CLASS)-        val info = context.packageManager.getServiceInfo(component, 0)-        info.enabled-    }.getOrDefault(false)--    /**-     * The car-app projected host is on the classpath.-     *-     * `Class.forName`, never an import: linking `androidx.car.app.projected`-     * from this module would drag the whole host stack into every auto-     * build for a path that is still a prototype. A missing class is a-     * fact (host not ready), not an error.-     */-    private fun hasHostLibrary(): Boolean = runCatching {-        Class.forName(HOST_CONNECTION_CLASS)-        true-    }.getOrDefault(false)--    /** `:library:map`'s renderer class loads. Native Vulkan still gates the first frame. */-    private fun hasMapRenderer(): Boolean = runCatching {-        Class.forName(MAP_RENDERER_CLASS)-        true-    }.getOrDefault(false)--    /** A location provider exists (enabled or not); permission still gates fixes. */-    private fun hasLocation(context: Context): Boolean = runCatching {-        val manager = context.getSystemService(LocationManager::class.java) ?: return false-        manager.getProviders(true).isNotEmpty() ||-            manager.allProviders.isNotEmpty()-    }.getOrDefault(false)--    /** One probe: the facts plus the pure recommendation. */-    data class HostReport(-        val host: HostFacts,-        val mirror: MirrorFacts,-        val path: MapsPath,-    ) {-        /** One-line verdict for logcat and the side-by-side report. */-        fun describe(): String =-            "maps path=$path " +-                "(host: service=${host.mapsServicePresent} " +-                "role=${host.holdsProjectionRole} lib=${host.hostLibraryPresent}; " +-                "mirror: renderer=${mirror.rendererPresent} " +-                "location=${mirror.locationAvailable} route=${mirror.routeActive})"--        /** Logs the verdict; call from the service bring-up on DEV builds only. */-        fun log() {-            Log.i(TAG, describe())-        }-    }--    private const val TAG = "MaAuto.Maps"--    private const val MAPS_PACKAGE = "com.vayunmathur.maps"-    private const val MAPS_CAR_SERVICE_CLASS = "com.vayunmathur.maps.car.MapsCarAppService"--    private const val HOST_CONNECTION_CLASS = "androidx.car.app.projected.CarAppProjectedService"--    private const val MAP_RENDERER_CLASS = "com.vayunmathur.library.map.SurfaceMapRenderer"-}
auto/src/main/java/com/vayunmathur/auto/platform/MediaPlaybackMonitor.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/MediaPlaybackMonitor.kt b/auto/src/main/java/com/vayunmathur/auto/platform/MediaPlaybackMonitor.ktindex 82a6aa0fe5..7853523e87 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/MediaPlaybackMonitor.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/MediaPlaybackMonitor.kt@@ -122,8 +122,11 @@ class MediaPlaybackMonitor(         val metadata = active.mediaMetadata         // Source badge: the session owner's app icon, matching gearhead's         // per-source badge. Null when the package has no icon to load.+        // (`MediaController` exposes the token, not the package directly;+        // the token is the service we bound in `start`.)         val sourceIcon = runCatching {-            context.packageManager.getApplicationIcon(active.packageName)+            val token = active.connectedToken ?: return@runCatching null+            context.packageManager.getApplicationIcon(token.packageName)         }.getOrNull()         onUpdate(             NowPlayingInfo(
auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt b/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.ktindex becc43f698..146f85a53b 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt@@ -27,11 +27,12 @@ import kotlin.math.roundToInt  * the two APKs do not share a process singleton anyway. Points are  * [MapRoutePoint] so the monitor can forward them without reshaping.  *- * The provider must return a stable list instance while the route is- * unchanged: the monitor forwards the reference untouched, and- * `CarMapsMirror` skips the (expensive, tessellating) route push when the- * reference is identical. A provider that rebuilds the list per read would- * re-tessellate a cross-city route on every GPS fix.+ * The host path (`CarAppHost`) carries the real route inside the app; this+ * provider feeds only the pre-host banner fallback plus the ch7/ch10 wire+ * values, which still come from phone GPS. The provider must return a stable+ * list instance while the route is unchanged: the monitor forwards the+ * reference untouched. A provider that rebuilds the list per read would+ * churn every GPS fix for nothing.  */ data class ActiveRoute(     val points: List<MapRoutePoint>,@@ -46,8 +47,8 @@ fun interface RouteProvider { }  /**- * Binds phone GPS (plus night state) into [NavSnapshot]s for the Phase 6- * mirror and the ch7/ch10 live values.+ * Binds phone GPS (plus night state) into [NavSnapshot]s for the pre-host+ * nav banner fallback and the ch7/ch10 live values.  *  * Owns location collection the way `MediaPlaybackMonitor` owns its  * controller: `start()` subscribes on the main thread, fixes arrive on the@@ -66,7 +67,8 @@ fun interface RouteProvider {  *   `SensorChannel`'s `onValues` seam (sensors-dev owns the channel).  * - ch10: forward `MapsGuidance.toNavStatus(snapshot)` to  *   `NavStatusChannel.postStatus` (sensors-dev owns the channel).- * - `CarMapsMirror.render(snapshot)` drives the ch2 map picture.+ * - nav banner: `CarNavCardView.update(snapshot)` until `CarAppHost`+ *   connects, then the hosted `NavigationTemplate` takes over.  */ class NavGuidanceMonitor(     private val context: Context,
auto/src/main/java/com/vayunmathur/auto/platform/VideoSinkChannel.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/VideoSinkChannel.kt b/auto/src/main/java/com/vayunmathur/auto/platform/VideoSinkChannel.ktindex 824ef0f11c..237a5b55b5 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/VideoSinkChannel.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/VideoSinkChannel.kt@@ -167,8 +167,8 @@ class VideoSinkChannel(     }      /**-     * Wires the map palette applier (`CarMapsMirror.setDark`) so one-     * [setNightDark] call restyles the rail/cards/drawer and the map.+     * Wires the map palette applier (`CarAppHost.setNight`) so one+     * [setNightDark] call restyles the rail/cards/drawer and the hosted map.      * Stored for displays created later; applied immediately when up.      */     fun setMapDarkApplier(applier: (Boolean) -> Unit) {@@ -243,6 +243,19 @@ class VideoSinkChannel(     /** Stored call actions for displays created later; see [setCallSource]. */     private var storedCallActions: CallActions? = null +    /**+     * Forwards the map-surface touch hookup to the display. Stored for+     * displays created later; applied immediately when the render pair is+     * already up.+     */+    fun setMapTouchForwarder(forward: (Int, Float, Float) -> Boolean) {+        mapTouchForwarder = forward+        display?.mapTouchForwarder = forward+    }++    /** Map-touch hookup for displays created later; see [setMapTouchForwarder]. */+    private var mapTouchForwarder: ((Int, Float, Float) -> Boolean)? = null+     /** Phone-status getter; see [setPhoneStatusSource]. */     private var phoneStatusSource: (() -> PhoneStatus?)? = null     fun setNavSource(@@ -254,6 +267,15 @@ class VideoSinkChannel(         get()?.let { display?.setNavSnapshot(it) }     } +    /**+     * Pushes one hosted template state into the car card, if the render pair+     * is up. The session host calls this on every template invalidate so the+     * header tracks the app without waiting for a poll.+     */+    fun setHostNavState(state: HostNavState) {+        display?.setHostNavState(state)+    }+     /**      * Pushes one snapshot to the car card, if the render pair is up. The      * service calls this on every media-monitor update so the card tracks@@ -444,6 +466,7 @@ class VideoSinkChannel(                 it.onNextTap = callbacks.onNext             }             mapDarkApplier?.let { applier -> it.mapDarkApplier = applier }+            mapTouchForwarder?.let { forward -> it.mapTouchForwarder = forward }             phoneStatusSource?.let { source -> it.phoneStatusSource = source }             callSource?.let { source ->                 // Call actions are service-owned; re-read the current
auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt b/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.ktnew file mode 100644index 0000000000..49866af7a9--- /dev/null+++ b/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt@@ -0,0 +1,64 @@+package com.vayunmathur.auto.service++import android.content.Context+import com.vayunmathur.auto.platform.CarAppHost+import com.vayunmathur.auto.platform.VideoSinkChannel++/**+ * Session-scoped owner for the car-app host (`CarAppHost`).+ *+ * Split out of `ProjectionService` for the 800-line limit: the service owns+ * session lifecycle, this owns the Maps bind plus every video-sink hookup the+ * host needs (template states, map surface, night, map touches). Session+ * thread owns start/stop; the video sink is touched from `openNext` on the+ * pump thread like every other `sink.set*` call.+ */+class CarAppHostSession(+    private val context: Context,+    private val video: () -> VideoSinkChannel?,+) {+    private var host: CarAppHost? = null++    /** Binds `MapsCarAppService`; template states push into the car card. */+    fun start() {+        if (host != null) return+        host = CarAppHost(context) { state ->+            video()?.setHostNavState(state)+        }.also { it.bind() }+    }++    /**+     * Wires the host into a video sink: night as a configuration change,+     * the nav-card surface as the app's `SurfaceContainer`, and map touches+     * into the app's own `SurfaceCallback`. Call from `openNext` with the+     * sink under construction, like every other `sink.set*` call.+     */+    fun wireInto(+        sink: VideoSinkChannel,+        snapshots: () -> com.vayunmathur.auto.protocol.NavSnapshot?,+    ) {+        val sessionHost = host ?: return+        // Night reaches the hosted map through the same call that restyles+        // the rail/cards/drawer (see setNightDark): the host forwards it as+        // a configuration change so the app restyles its own palette.+        sink.setMapDarkApplier { dark -> sessionHost.setNight(dark) }+        sink.setNavSource(+            get = snapshots,+            onMapSurface = { surface, w, h ->+                if (surface != null) sessionHost.setSurface(surface, w, h)+                else sessionHost.clearSurface()+            },+        )+        // Map-surface touches ride the hosted app's own SurfaceCallback+        // (pan/zoom/click in Maps itself).+        sink.setMapTouchForwarder { action, x, y ->+            sessionHost.injectMapTouch(action, x, y)+        }+    }++    /** Tears the session down; the service still owns the `Surface`. */+    fun stop() {+        host?.unbind()+        host = null+    }+}
auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.ktindex 46ed54d1bb..a5290f7241 100644--- a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt@@ -28,7 +28,6 @@ import com.vayunmathur.auto.platform.MicSourceChannel import com.vayunmathur.auto.platform.CallCardPush import com.vayunmathur.auto.platform.MusicCaptureSinkHolder import com.vayunmathur.auto.platform.NavGuidanceMonitor-import com.vayunmathur.auto.platform.CarMapsMirror import com.vayunmathur.auto.platform.NavStatusChannel import com.vayunmathur.auto.platform.NightSource import com.vayunmathur.auto.platform.PhoneStatusMonitor@@ -307,12 +306,13 @@ class ProjectionService : Service() {             onEvent = AutoSessionState::onAudioEvent,         ).also { it.start() } -        // Guidance + map mirror start with the session too: fixes flow-        // from the first tick, and the mirror attaches when the nav-        // card's TextureView is ready (or never, if the card is gone).-        mapsMirror = CarMapsMirror(this)+        // Guidance + the car-app host start with the session too: fixes flow+        // from the first tick, and the host binds MapsCarAppService so the+        // nav card renders whatever Maps publishes (its own surface ++        // NavigationTemplate) instead of MA Auto re-rendering a second map.+        // Owned by CarAppHostSession (split for the 800-line limit).+        carAppHostSession.start()         guidanceMonitor = NavGuidanceMonitor(this) { snapshot ->-            mapsMirror?.render(snapshot)             video?.setNavSnapshot(snapshot)             // ch7 live values: the fix folds into the same last-known             // snapshot the head-unit batches fold into (HANDOFF.md section@@ -373,8 +373,7 @@ class ProjectionService : Service() {             tts = null             guidanceMonitor?.stop()             guidanceMonitor = null-            mapsMirror?.release()-            mapsMirror = null+            carAppHostSession.stop()             MusicCaptureService.stop(this)             MusicCaptureSinkHolder.sink = null             // Unowned services need no teardown: their channels opened@@ -573,13 +572,14 @@ class ProjectionService : Service() {     private var phoneStatusMonitor: PhoneStatusMonitor? = null      /**-     * Session-scoped guidance + map mirror, like TTS: started with the-     * session (position/puck are live from the first fix), stopped with it.-     * Snapshots render into the mirror and push the nav banner; with no-     * location permission the monitor holds last-known and the map stays put.+     * Session-scoped guidance, like TTS: started with the session (position+     * live from the first fix), stopped with it. Snapshots push the nav+     * banner fallback; with no location permission the monitor holds+     * last-known. The car-app host rides alongside through+     * [carAppHostSession] (split for the 800-line limit).      */     private var guidanceMonitor: NavGuidanceMonitor? = null-    private var mapsMirror: CarMapsMirror? = null+    private val carAppHostSession = CarAppHostSession(this) { video }      /**      * Seeds the credential-expiry flow once per service start, off the pump thread.@@ -634,9 +634,13 @@ class ProjectionService : Service() {                         onPrevious = { mediaMonitor?.seekToPrevious() },                         onNext = { mediaMonitor?.seekToNext() },                     )-                    // Night reaches the map palette through the same call-                    // that restyles the rail/cards/drawer (see setNightDark).-                    sink.setMapDarkApplier { dark -> mapsMirror?.setDark(dark) }+                    // Night, map surface and map touches ride the session's+                    // car-app host (owned by CarAppHostSession, split for+                    // the 800-line limit).+                    carAppHostSession.wireInto(+                        sink,+                        snapshots = { guidanceMonitor?.snapshots?.value },+                    )                     // Rail cluster + call card feeds: the display caches                     // both for presentations created later.                     sink.setPhoneStatusSource { phoneStatusMonitor?.snapshot }@@ -647,14 +651,6 @@ class ProjectionService : Service() {                         onHold = { CarProjectionInCallService.toggleHold() },                         onMute = { CarProjectionInCallService.toggleMute() },                     )-                    sink.setNavSource(-                        get = { guidanceMonitor?.snapshots?.value },-                        onMapSurface = { surface, w, h ->-                            val mirror = mapsMirror ?: return@setNavSource-                            if (surface != null) mirror.setSurface(surface, w, h)-                            else mirror.release()-                        },-                    )                 }         }         // ch14 advertises in the same wire-order pass; the owner starts
auto/src/main/java/com/vayunmathur/auto/telephony/CarProjectionInCallService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/telephony/CarProjectionInCallService.kt b/auto/src/main/java/com/vayunmathur/auto/telephony/CarProjectionInCallService.ktindex d9d5a8b06d..efd6f68fc5 100644--- a/auto/src/main/java/com/vayunmathur/auto/telephony/CarProjectionInCallService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/telephony/CarProjectionInCallService.kt@@ -4,9 +4,11 @@ import android.content.Intent import android.os.IBinder import android.telecom.Call import android.telecom.InCallService+import android.telecom.VideoProfile import android.util.Log import com.vayunmathur.auto.platform.ActiveCallInfo import com.vayunmathur.auto.platform.AutoSessionState+import com.vayunmathur.auto.platform.CallCardPush  /**  * The car-projection call path: an [InCallService] the platform binds while@@ -48,7 +50,7 @@ class CarProjectionInCallService : InCallService() {         val info = snapshotOf(call, call.state)         lastAcceptedMs = if (info.acceptedMs > 0L) info.acceptedMs else 0L         AutoSessionState.onCallAdded(info)-        pushToSession(info)+        CallCardPush.push(info)         Log.i(TAG, "car-projection call added")     } @@ -81,6 +83,10 @@ class CarProjectionInCallService : InCallService() {         CallCardPush.push(info)     } +    override fun onCallAudioStateChanged(state: android.telecom.CallAudioState) {+        lastMuted = state.isMuted+    }+     private fun snapshotOf(call: Call, state: Int): ActiveCallInfo {         val details = runCatching { call.details }.getOrNull()         // The handle's scheme part is the dialable number; withheld handles@@ -95,10 +101,13 @@ class CarProjectionInCallService : InCallService() {             number = number,             acceptedMs = if (state == Call.STATE_RINGING) 0L else lastAcceptedMs(call, state),             held = held,-            muted = muted,+            muted = lastMuted,         )     } +    /** Latest mute state from `onCallAudioStateChanged`; false until first report. */+    @Volatile private var lastMuted = false+     private var lastAcceptedMs = 0L      private fun lastAcceptedMs(call: Call, state: Int): Long {@@ -131,7 +140,8 @@ class CarProjectionInCallService : InCallService() {         fun answerCall() {             val service = current ?: return             runCatching {-                service.calls.firstOrNull { it.state == Call.STATE_RINGING }?.answer()+                service.calls.firstOrNull { it.state == Call.STATE_RINGING }+                    ?.answer(VideoProfile.STATE_AUDIO_ONLY)             }.onFailure { Log.w(TAG, "answer call failed", it) }         } @@ -147,7 +157,7 @@ class CarProjectionInCallService : InCallService() {         /** Flips the InCall mute, no-op with nothing bound. */         fun toggleMute() {             val service = current ?: return-            runCatching { service.setMuted(!service.muted) }+            runCatching { service.setMuted(!(service.callAudioState?.isMuted ?: false)) }                 .onFailure { Log.w(TAG, "mute toggle failed", it) }         }     }
auto/src/main/res/values/strings.xml
diff --git a/auto/src/main/res/values/strings.xml b/auto/src/main/res/values/strings.xmlindex 96bc5760ec..2a3c4b57ee 100644--- a/auto/src/main/res/values/strings.xml+++ b/auto/src/main/res/values/strings.xml@@ -277,8 +277,6 @@     <string name="car_drawer_glyph">▦</string>     <!-- Decorative glyph on the facet dashboard button (goes home, closes drawer). -->     <string name="car_home_glyph">⌂</string>-    <!-- Shown on the car display when the media session reports no title. -->-    <string name="car_now_playing_unknown">Unknown track</string>      <!-- Heading of the session-card row showing the system sink (ch4, transient TTS/pings). -->     <string name="session_audio_sys">System audio</string>@@ -384,6 +382,9 @@     <!-- Distance to the next maneuver on the nav card. %1$d is whole metres;          translators own the unit so it can be spaced or abbreviated per locale. -->     <string name="car_nav_distance_meters"><xliff:g example="500" id="meters">%1$d</xliff:g> m</string>+    <!-- Empty-tile label on the nav card, shown only when no map backend+         exists at all (maps missing or the car-app host bind failed). -->+    <string name="car_nav_open_maps">Open Maps</string>     <!-- Drawer empty state. Exact gearhead `appdecor_menu_empty` value. -->     <string name="car_drawer_empty">No Items</string>     <!-- Drawer lockout text shown while driving-restricted. Exact gearhead
auto/src/main/res/xml/message_mirror_filter.xml
diff --git a/auto/src/main/res/xml/message_mirror_filter.xml b/auto/src/main/res/xml/message_mirror_filter.xmlindex 0d35409108..f708b291de 100644--- a/auto/src/main/res/xml/message_mirror_filter.xml+++ b/auto/src/main/res/xml/message_mirror_filter.xml@@ -2,7 +2,7 @@ <!-- Mirror filter for MessageMirrorService (see its meta-data): which      notifications may leave the phone. Only CATEGORY_MESSAGE (SMS and chat      apps tag theirs); everything else stays local. The dual gate (system-     listener binding + in-app consent in MessagingPrefs) applies on top --+     listener binding + in-app consent in MessagingPrefs) applies on top:      either off means fail-closed silence regardless of this filter. --> <notification-filter xmlns:android="http://schemas.android.com/apk/res/android">     <category android:name="android.app.Notification.CATEGORY_MESSAGE" />
build-logic/src/main/kotlin/RustNative.kt
diff --git a/build-logic/src/main/kotlin/RustNative.kt b/build-logic/src/main/kotlin/RustNative.ktindex b0c8965aa0..389b2df094 100644--- a/build-logic/src/main/kotlin/RustNative.kt+++ b/build-logic/src/main/kotlin/RustNative.kt@@ -220,14 +220,17 @@ fun Project.rustNativeLib(     }     // Rust file-length gate: fails the build on any *.rs over     // RUST_FILE_LENGTH_LIMIT lines, like the Kotlin FileLength rule (which-    // cannot see Rust). Configuration-cache compatible: the source dir is-    // resolved now, the walk happens in the task action.-    val rustSrcDir = file("src/main/rust/src")+    // cannot see Rust). Configuration-cache compatible: plain path strings+    // cross the configuration boundary, never the Project object.+    val rustSrcPath: String = file("src/main/rust/src").absolutePath+    val rustProjPath: String = projectDir.absolutePath     val rustFileLength = tasks.register("rustFileLength") {         description = "Fails on Rust files over $RUST_FILE_LENGTH_LIMIT lines."-        inputs.dir(rustSrcDir)+        inputs.dir(rustSrcPath)         doLast {-            val over = rustSrcDir.walkTopDown()+            val srcDir = java.io.File(rustSrcPath)+            val projDir = java.io.File(rustProjPath)+            val over = srcDir.walkTopDown()                 .filter { it.isFile && it.extension == "rs" }                 .map { it to it.readLines().size }                 .filter { (f, n) ->@@ -238,7 +241,7 @@ fun Project.rustNativeLib(                 .toList()             if (over.isNotEmpty()) {                 val detail = over.joinToString("\n") { (f, n) ->-                    "  $n ${f.relativeTo(projectDir)}"+                    "  $n ${f.relativeTo(projDir)}"                 }                 throw org.gradle.api.GradleException(                     "Rust files exceed $RUST_FILE_LENGTH_LIMIT lines (split along module lines):\n$detail"
calendar/src/main/java/com/vayunmathur/calendar/ui/AgendaView.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/AgendaView.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/AgendaView.ktindex ba233c225c..ea1f6e1264 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/AgendaView.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/AgendaView.kt@@ -35,6 +35,7 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.plus+import kotlinx.datetime.todayIn import kotlin.time.Clock import kotlin.time.Instant 
calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarPagerView.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarPagerView.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarPagerView.ktindex 3f8d67408d..2c0ad3946d 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarPagerView.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarPagerView.kt@@ -66,6 +66,7 @@ import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.isoDayNumber import kotlinx.datetime.minus import kotlinx.datetime.plus+import kotlinx.datetime.todayIn import kotlinx.datetime.toLocalDateTime import kotlin.time.Clock import kotlin.time.Duration.Companion.seconds
calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarViewHelpers.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarViewHelpers.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarViewHelpers.ktindex 35676d0210..d4d8bd1b6e 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarViewHelpers.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/CalendarViewHelpers.kt@@ -9,6 +9,7 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.atStartOfDayIn import kotlinx.datetime.isoDayNumber+import kotlinx.datetime.plus import kotlin.time.Instant  internal fun firstDayOfWeekOffset(date: LocalDate, locale: Locale): Int {
calendar/src/main/java/com/vayunmathur/calendar/ui/SummaryGrid.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/SummaryGrid.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/SummaryGrid.ktindex d49a9135b5..1457cb0cf2 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/SummaryGrid.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/SummaryGrid.kt@@ -20,6 +20,7 @@ import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.VerticalDivider import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone+import kotlinx.datetime.todayIn import kotlin.time.Clock  @Composable
calendar/src/main/java/com/vayunmathur/calendar/ui/WeekHeaderRow.kt
diff --git a/calendar/src/main/java/com/vayunmathur/calendar/ui/WeekHeaderRow.kt b/calendar/src/main/java/com/vayunmathur/calendar/ui/WeekHeaderRow.ktindex 512f70045d..0aca2ead01 100644--- a/calendar/src/main/java/com/vayunmathur/calendar/ui/WeekHeaderRow.kt+++ b/calendar/src/main/java/com/vayunmathur/calendar/ui/WeekHeaderRow.kt@@ -35,6 +35,7 @@ import com.vayunmathur.library.util.sharedText import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.isoDayNumber+import kotlinx.datetime.todayIn import kotlin.time.Clock  @Composable
communicate/src/main/rust/src/wa_tokens.rs
diff --git a/communicate/src/main/rust/src/wa_tokens.rs b/communicate/src/main/rust/src/wa_tokens.rsindex aa5296efc4..5c420d08f3 100644--- a/communicate/src/main/rust/src/wa_tokens.rs+++ b/communicate/src/main/rust/src/wa_tokens.rs@@ -249,4 +249,5 @@ pub const SINGLE_BYTE_TOKENS: &[&str] = &[  include!("wa_tokens_part1.rs"); include!("wa_tokens_part2.rs");-include!("wa_tokens_part3.rs");\ No newline at end of file+include!("wa_tokens_part3.rs");+include!("wa_tokens_part4.rs");
communicate/src/main/rust/src/wa_tokens_part1.rs
diff --git a/communicate/src/main/rust/src/wa_tokens_part1.rs b/communicate/src/main/rust/src/wa_tokens_part1.rsindex 9710085255..d40b762090 100644--- a/communicate/src/main/rust/src/wa_tokens_part1.rs+++ b/communicate/src/main/rust/src/wa_tokens_part1.rs@@ -1,6 +1,5 @@ /// Secondary dictionaries, selected by the `DICTIONARY_0..3` tag bytes.-pub const DOUBLE_BYTE_TOKENS: [&[&str]; 4] = [-    &[+pub const DOUBLE_BYTE_DICT_0: &[&str] = &[         "read-self",         "active",         "fbns",@@ -257,194 +256,4 @@ pub const DOUBLE_BYTE_TOKENS: [&[&str]; 4] = [         "catalog_exists",         "01f",         "mute_v2",-    ],-    &[-        "reject",-        "dirty",-        "announcement",-        "020",-        "13",-        "9",-        "status_video_max_bitrate",-        "fb:thrift_iq",-        "offline_batch",-        "022",-        "full",-        "ctwa_first_business_reply_logging",-        "h.264",-        "smax_id",-        "group_description_length",-        "https://www.whatsapp.com/otp/code",-        "status_image_max_edge",-        "smb_upsell_business_profile_enabled",-        "021",-        "web_upgrade_to_md_modal",-        "14",-        "023",-        "s_o",-        "smaller_video_thumbs_status_enabled",-        "media_max_autodownload",-        "960",-        "blocking_status",-        "peer_msg",-        "joinable_group_call_client_version",-        "group_call_video_maximization_enabled",-        "return_snapshot",-        "high",-        "America/Mexico_City",-        "entry_point_block_logging_enabled",-        "pop",-        "024",-        "1050",-        "16",-        "1380",-        "one_tap_calling_in_group_chat_size",-        "regular_low",-        "inline_joinable_education_enabled",-        "hq_image_max_edge",-        "locked",-        "America/Bogota",-        "smb_biztools_deeplink_enabled",-        "status_image_quality",-        "1088",-        "025",-        "payments_upi_intent_transaction_limit",-        "voip",-        "w:g2",-        "027",-        "md_pin_chat_enabled",-        "026",-        "multi_scan_pjpeg_download_enabled",-        "shops_product_grid",-        "transaction_id",-        "ctwa_context_enabled",-        "20",-        "fna",-        "hq_image_quality",-        "alt_jpeg_doc_detection_quality",-        "group_call_max_participants",-        "pkey",-        "America/Belem",-        "image_max_kbytes",-        "web_cart_v1_1_order_message_changes_enabled",-        "ctwa_context_enterprise_enabled",-        "urn:xmpp:whatsapp:account",-        "840",-        "Asia/Kuala_Lumpur",-        "max_participants",-        "video_remux_after_repair_enabled",-        "stella_addressbook_restriction_type",-        "660",-        "900",-        "780",-        "context_menu_ios13_enabled",-        "mute-state",-        "ref",-        "payments_request_messages",-        "029",-        "frskmsg",-        "vcard_max_size_kb",-        "sample_buffer_gif_player_enabled",-        "match_last_seen",-        "510",-        "4983",-        "video_max_bitrate",-        "028",-        "w:comms:chat",-        "17",-        "frequently_forwarded_max",-        "groups_privacy_blacklist",-        "Asia/Karachi",-        "02a",-        "web_download_document_thumb_mms_enabled",-        "02b",-        "hist_sync",-        "biz_block_reasons_version",-        "1024",-        "18",-        "web_is_direct_connection_for_plm_transparent",-        "view_once_write",-        "file_max_size",-        "paid_convo_id",-        "online_privacy_setting",-        "video_max_edge",-        "view_once_read",-        "enhanced_storage_management",-        "multi_scan_pjpeg_encoding_enabled",-        "ctwa_context_forward_enabled",-        "video_transcode_downgrade_enable",-        "template_doc_mime_types",-        "hq_image_bw_threshold",-        "30",-        "body",-        "u_aud_limit_sil_restarts_ctrl",-        "other",-        "participating",-        "w:biz:directory",-        "1110",-        "vp8",-        "4018",-        "meta",-        "doc_detection_image_max_edge",-        "image_quality",-        "1170",-        "02c",-        "smb_upsell_chat_banner_enabled",-        "key_expiry_time_second",-        "pid",-        "stella_interop_enabled",-        "19",-        "linked_device_max_count",-        "md_device_sync_enabled",-        "02d",-        "02e",-        "360",-        "enhanced_block_enabled",-        "ephemeral_icon_in_forwarding",-        "paid_convo_status",-        "gif_provider",-        "project_name",-        "server-error",-        "canonical_url_validation_enabled",-        "wallpapers_v2",-        "syncd_clear_chat_delete_chat_enabled",-        "medianotify",-        "02f",-        "shops_required_tos_version",-        "vote",-        "reset_skey_on_id_change",-        "030",-        "image_max_edge",-        "multicast_limit_global",-        "ul_bw",-        "21",-        "25",-        "5000",-        "poll",-        "570",-        "22",-        "031",-        "1280",-        "WhatsApp",-        "032",-        "bloks_shops_enabled",-        "50",-        "upload_host_switching_enabled",-        "web_ctwa_context_compose_enabled",-        "ptt_forwarded_features_enabled",-        "unblocked",-        "partial_pjpeg_enabled",-        "fbid:devices",-        "height",-        "ephemeral_group_query_ts",-        "group_join_permissions",-        "order",-        "033",-        "alt_jpeg_status_quality",-        "migrate",-        "popular-bank",-        "win_uwp_deprecation_killswitch_enabled",-        "web_download_status_thumb_mms_enabled",-        "blocking",-        "url_text",-        "035",\ No newline at end of file+];
communicate/src/main/rust/src/wa_tokens_part2.rs
diff --git a/communicate/src/main/rust/src/wa_tokens_part2.rs b/communicate/src/main/rust/src/wa_tokens_part2.rsindex 39147568f6..be37fbd587 100644--- a/communicate/src/main/rust/src/wa_tokens_part2.rs+++ b/communicate/src/main/rust/src/wa_tokens_part2.rs@@ -1,3 +1,193 @@+pub const DOUBLE_BYTE_DICT_1: &[&str] = &[+        "reject",+        "dirty",+        "announcement",+        "020",+        "13",+        "9",+        "status_video_max_bitrate",+        "fb:thrift_iq",+        "offline_batch",+        "022",+        "full",+        "ctwa_first_business_reply_logging",+        "h.264",+        "smax_id",+        "group_description_length",+        "https://www.whatsapp.com/otp/code",+        "status_image_max_edge",+        "smb_upsell_business_profile_enabled",+        "021",+        "web_upgrade_to_md_modal",+        "14",+        "023",+        "s_o",+        "smaller_video_thumbs_status_enabled",+        "media_max_autodownload",+        "960",+        "blocking_status",+        "peer_msg",+        "joinable_group_call_client_version",+        "group_call_video_maximization_enabled",+        "return_snapshot",+        "high",+        "America/Mexico_City",+        "entry_point_block_logging_enabled",+        "pop",+        "024",+        "1050",+        "16",+        "1380",+        "one_tap_calling_in_group_chat_size",+        "regular_low",+        "inline_joinable_education_enabled",+        "hq_image_max_edge",+        "locked",+        "America/Bogota",+        "smb_biztools_deeplink_enabled",+        "status_image_quality",+        "1088",+        "025",+        "payments_upi_intent_transaction_limit",+        "voip",+        "w:g2",+        "027",+        "md_pin_chat_enabled",+        "026",+        "multi_scan_pjpeg_download_enabled",+        "shops_product_grid",+        "transaction_id",+        "ctwa_context_enabled",+        "20",+        "fna",+        "hq_image_quality",+        "alt_jpeg_doc_detection_quality",+        "group_call_max_participants",+        "pkey",+        "America/Belem",+        "image_max_kbytes",+        "web_cart_v1_1_order_message_changes_enabled",+        "ctwa_context_enterprise_enabled",+        "urn:xmpp:whatsapp:account",+        "840",+        "Asia/Kuala_Lumpur",+        "max_participants",+        "video_remux_after_repair_enabled",+        "stella_addressbook_restriction_type",+        "660",+        "900",+        "780",+        "context_menu_ios13_enabled",+        "mute-state",+        "ref",+        "payments_request_messages",+        "029",+        "frskmsg",+        "vcard_max_size_kb",+        "sample_buffer_gif_player_enabled",+        "match_last_seen",+        "510",+        "4983",+        "video_max_bitrate",+        "028",+        "w:comms:chat",+        "17",+        "frequently_forwarded_max",+        "groups_privacy_blacklist",+        "Asia/Karachi",+        "02a",+        "web_download_document_thumb_mms_enabled",+        "02b",+        "hist_sync",+        "biz_block_reasons_version",+        "1024",+        "18",+        "web_is_direct_connection_for_plm_transparent",+        "view_once_write",+        "file_max_size",+        "paid_convo_id",+        "online_privacy_setting",+        "video_max_edge",+        "view_once_read",+        "enhanced_storage_management",+        "multi_scan_pjpeg_encoding_enabled",+        "ctwa_context_forward_enabled",+        "video_transcode_downgrade_enable",+        "template_doc_mime_types",+        "hq_image_bw_threshold",+        "30",+        "body",+        "u_aud_limit_sil_restarts_ctrl",+        "other",+        "participating",+        "w:biz:directory",+        "1110",+        "vp8",+        "4018",+        "meta",+        "doc_detection_image_max_edge",+        "image_quality",+        "1170",+        "02c",+        "smb_upsell_chat_banner_enabled",+        "key_expiry_time_second",+        "pid",+        "stella_interop_enabled",+        "19",+        "linked_device_max_count",+        "md_device_sync_enabled",+        "02d",+        "02e",+        "360",+        "enhanced_block_enabled",+        "ephemeral_icon_in_forwarding",+        "paid_convo_status",+        "gif_provider",+        "project_name",+        "server-error",+        "canonical_url_validation_enabled",+        "wallpapers_v2",+        "syncd_clear_chat_delete_chat_enabled",+        "medianotify",+        "02f",+        "shops_required_tos_version",+        "vote",+        "reset_skey_on_id_change",+        "030",+        "image_max_edge",+        "multicast_limit_global",+        "ul_bw",+        "21",+        "25",+        "5000",+        "poll",+        "570",+        "22",+        "031",+        "1280",+        "WhatsApp",+        "032",+        "bloks_shops_enabled",+        "50",+        "upload_host_switching_enabled",+        "web_ctwa_context_compose_enabled",+        "ptt_forwarded_features_enabled",+        "unblocked",+        "partial_pjpeg_enabled",+        "fbid:devices",+        "height",+        "ephemeral_group_query_ts",+        "group_join_permissions",+        "order",+        "033",+        "alt_jpeg_status_quality",+        "migrate",+        "popular-bank",+        "win_uwp_deprecation_killswitch_enabled",+        "web_download_status_thumb_mms_enabled",+        "blocking",+        "url_text",+        "035",         "web_forwarding_limit_to_groups",         "1600",         "val",@@ -65,386 +255,4 @@         "web_md_migration_experience",         "ptt_conversation_waveform",         "u_aud_limit_sil_restarts_test1",-    ],-    &[-        "64",-        "ptt_playback_speed_enabled",-        "web_product_list_message_enabled",-        "paid_convo_ts",-        "27",-        "manufacturer",-        "psp-routing",-        "grp_uii_cleanup",-        "ptt_draft_enabled",-        "03c",-        "business_initiated",-        "web_catalog_products_onoff",-        "web_upload_link_thumb_mms_enabled",-        "03e",-        "mediaretry",-        "35",-        "hfm_string_changes",-        "28",-        "America/Fortaleza",-        "max_keys",-        "md_mhfs_days",-        "streaming_upload_chunk_size",-        "5541",-        "040",-        "03d",-        "2675",-        "03f",-        "...",-        "512",-        "mute",-        "48",-        "041",-        "alt_jpeg_quality",-        "60",-        "042",-        "md_smb_quick_reply",-        "5183",-        "c",-        "1343",-        "40",-        "1230",-        "043",-        "044",-        "mms_cat_v1_forward_hot_override_enabled",-        "user_notice",-        "ptt_waveform_send",-        "047",-        "Asia/Calcutta",-        "250",-        "md_privacy_v2",-        "31",-        "29",-        "128",-        "md_messaging_enabled",-        "046",-        "crypto",-        "690",-        "045",-        "enc_iv",-        "75",-        "failure",-        "ptt_oot_playback",-        "AIzaSyDR5yfaG7OG8sMTUj8kfQEb8T9pN8BM6Lk",-        "w",-        "048",-        "2201",-        "web_large_files_ui",-        "Asia/Makassar",-        "812",-        "status_collapse_muted",-        "1334",-        "257",-        "2HP4dm",-        "049",-        "patches",-        "1290",-        "43cY6T",-        "America/Caracas",-        "web_sticker_maker",-        "campaign",-        "ptt_pausable_enabled",-        "33",-        "42",-        "attestation",-        "biz",-        "04b",-        "query_linked",-        "s",-        "125",-        "04a",-        "810",-        "availability",-        "1411",-        "responsiveness_v2_m1",-        "catalog_not_created",-        "34",-        "America/Santiago",-        "1465",-        "enc_p",-        "04d",-        "status_info",-        "04f",-        "key_version",-        "..",-        "04c",-        "04e",-        "md_group_notification",-        "1598",-        "1215",-        "web_cart_enabled",-        "37",-        "630",-        "1920",-        "2394",-        "-1",-        "vcard",-        "38",-        "elapsed",-        "36",-        "828",-        "peer",-        "pricing_category",-        "1245",-        "invalid",-        "stella_ios_enabled",-        "2687",-        "45",-        "1528",-        "39",-        "u_is_redial_audio_1104_ctrl",-        "1025",-        "1455",-        "58",-        "2524",-        "2603",-        "054",-        "bsp_system_message_enabled",-        "web_pip_redesign",-        "051",-        "verify_apps",-        "1974",-        "1272",-        "1322",-        "1755",-        "052",-        "70",-        "050",-        "1063",-        "1135",-        "1361",-        "80",-        "1096",-        "1828",-        "1851",-        "1251",-        "1921",-        "key_config_id",-        "1254",-        "1566",-    

Diff truncated.