Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / auto / docs / HANDOFF.md
| 1 | # MA Auto — handoff |
| 2 | |
| 3 | **Status: the full GAL bring-up completes against Google's Desktop Head Unit — |
| 4 | discovery → channel opens → media setup → focus → start — and H.264 frames |
| 5 | stream with head-unit acks. Render path (decode→surface) still unconfirmed.** |
| 6 | |
| 7 | > This file is tracked at `auto/docs/HANDOFF.md` (moved out of gitignored |
| 8 | > `analysis/maauto/` in `5c323e528`). Companion teardown lives at |
| 9 | > `auto/docs/FINDINGS.md`. |
| 10 | |
| 11 | Companion documents: |
| 12 | - `auto/docs/FINDINGS.md` — the full gearhead teardown: crypto, framing, message IDs, |
| 13 | service table, protobuf recovery. Read that first for anything protocol-shaped. |
| 14 | - `C:\Users\Vayun\.llms\plans\ma_auto_projection.plan.md` — the approved plan, including the |
| 15 | role strategy. |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ## 1. What this is |
| 20 | |
| 21 | MA Auto is the **sender** side of Android Auto: it replaces Google's |
| 22 | `com.google.android.projection.gearhead` on the phone and speaks the Google Automotive Link |
| 23 | (GAL) protocol to a car head unit. Decided scope, from the plan: sender only, tested against |
| 24 | the Desktop Head Unit, shipping Google's extracted GAL credential. |
| 25 | |
| 26 | --- |
| 27 | |
| 28 | ## 2. Where it actually got to |
| 29 | |
| 30 | Verified live against `desktop-head-unit.exe` 2.0 over TCP (Run 8 + video run): |
| 31 | |
| 32 | ``` |
| 33 | HU → VersionRequest (1.7) PH → VersionResponse (1.7, OK) ✓ |
| 34 | HU → SslHandshake ×2 PH → SslHandshake ×2 ✓ TLS 1.2 established |
| 35 | HU → AuthComplete (STATUS_SUCCESS) PH → ServiceDiscoveryRequest ✓ field 5 only |
| 36 | HU → ServiceDiscoveryResponse PH → ChannelOpen ×7 (services 1-7 in wire order) ✓ |
| 37 | HU → ChannelOpenResponse (SUCCESS) PH → MediaSetupRequest (video) ✓ |
| 38 | HU → MediaConfig (index 0) PH → VideoFocusRequest → MediaStart → H.264 frames ✓ |
| 39 | HU → PingRequest every 1s PH → PingResponse ✓ link stays healthy |
| 40 | ``` |
| 41 | |
| 42 | **The full GAL bring-up completes against a real Google head unit |
| 43 | implementation, and H.264 frames stream with head-unit acks.** The biggest open |
| 44 | risk in the whole project (credential acceptance) is closed, and so is every |
| 45 | post-discovery sub-blocker from Task 6 (see §3). |
| 46 | |
| 47 | The ping/pong after the error is important evidence: DHU keeps pinging and keeps accepting |
| 48 | our *encrypted* replies, so **application-data TLS works in both directions**. The failure is |
| 49 | specific to the ServiceDiscoveryRequest, not to crypto, framing or the transport. |
| 50 | |
| 51 | Identical failure on a Pixel 8 (MAOS) and a Pixel 9 Pro XL (GrapheneOS), so it is purely |
| 52 | protocol — nothing to do with the OS or with privileges. |
| 53 | |
| 54 | ### Not done |
| 55 | - Render path unconfirmed: frames are encoded, sent and acked, but nobody has |
| 56 | confirmed they decode and display on the DHU surface yet. |
| 57 | - No MAOS integration at all: the app is **sideloaded**, holds no role, and none of the |
| 58 | role/privapp/RRO work from plan Phase 3 has been started. |
| 59 | - USB (AOAP) and wireless transports not written. Only TCP, which is what DHU uses. |
| 60 | - Audio, input and sensor channels advertised but no traffic verified on them yet. |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ## 10. Phase 6 — Maps host (maps-dev, task 9; mirror deleted) |
| 65 | |
| 66 | **Decision: HOST. The mirror was the wrong architecture and is deleted.** |
| 67 | |
| 68 | Android car apps render through the host: the app (`MapsCarAppService` -> |
| 69 | `MapsSession` -> `NavMapScreen`) draws its own map into a host-owned |
| 70 | `Surface` (`AppManager.setSurfaceCallback` -> `CarMapRenderer`) and publishes |
| 71 | a `NavigationTemplate`. The old mirror re-rendered a second map in the auto |
| 72 | process from GPS scraps and missed everything `NavSnapshot` never carried |
| 73 | (lanes, ETA, arrival). `CarAppHost` is the host: it binds the maps service, |
| 74 | implements the host binders (`ICarHost`/`IAppHost`/`INavigationHost`/ |
| 75 | `IConstraintHost`, all from the `app-1.4.0` contract), hands Maps the nav |
| 76 | card's `TextureView` surface as a `SurfaceContainer`, and renders the real |
| 77 | template (cue/road, distance, lane arrows, ETA, app action strip) into the |
| 78 | step header. Ch8 map touches forward into the app's `SurfaceCallback`. |
| 79 | Empty launch tile only when maps is missing or the bind fails. |
| 80 | |
| 81 | What landed: |
| 82 | |
| 83 | - `platform/CarAppHost.kt` -- the host (bind + handshake + lifecycle + |
| 84 | template pull + surface supply + touch forwarding). Direct |
| 85 | `androidx.car.app:app` dependency (same 1.4.0 the maps app uses). |
| 86 | - `platform/CarNavCardView` -- renders `HostNavState` (template fields, |
| 87 | GONE-if-empty; actions through the app's `OnClickDelegate`); the |
| 88 | `NavSnapshot` banner stays as the pre-host fallback. |
| 89 | - `service/CarAppHostSession.kt` -- session ownership split (800-line limit). |
| 90 | - `auto/protocol/.../HostVsMirror.kt` -- now `HostFacts` + `HostReadiness` |
| 91 | (host-only readiness, no mirror comparison; `HostVsMirrorTest` rewritten). |
| 92 | - Deleted: `platform/CarMapsMirror.kt`, `platform/GearheadHostProbe.kt`; |
| 93 | `:library:map` dep removed from `:auto` (which also unblocks the build). |
| 94 | - `auto/protocol/.../MapsGuidance.kt` -- unchanged wire role: `NavSnapshot` |
| 95 | still feeds ch7/ch10 + the pre-host banner. |
| 96 | |
| 97 | Verdict status: `:auto:assembleDev` + protocol tests + lint green; APK |
| 98 | installed on Pixel 44050DLJH001PC, Maps car service present. Live leg (DHU |
| 99 | shows the hosted map, ch8 pans it, template invalidates) needs a DHU run. |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ## 9. Decompiler traps |
| 104 | |
| 105 | ## 3. The blocker, precisely — RESOLVED (Tasks 3+6) |
| 106 | |
| 107 | DHU *used to* answer our ServiceDiscoveryRequest (control message 5) with |
| 108 | MessageError (255, empty payload) and then carry on pinging. That blocker is |
| 109 | closed, along with every sub-blocker found past it. What each turned out to be: |
| 110 | |
| 111 | 1. **Discovery content** (Task 3, `8449cbeb7`): send only field 5 = |
| 112 | `"Google Pixel 8"` (MANUFACTURER-first), framing `0x0B`. |
| 113 | 2. **0x8 gating** (`a93db5e18`): wait for ChannelOpenResponse before media |
| 114 | setup; parse `xir` status. |
| 115 | 3. **Non-fatal 0xff** (`d9694dab4`): inbound MessageError is observed, session |
| 116 | stays ACTIVE (gearhead's `izu` logs and carries on). |
| 117 | 4. **Open queue** (`e5d2ff668`→`01abb3bbe`): sequential opens in HU wire order; |
| 118 | bare 0xff drains the pending open into refusedChannels. |
| 119 | 5. **CONTROL on 0x7** (`0b0a7cb6e`→`91f7b1d72`): 0x7 goes `0x0F` (CONTROL set), |
| 120 | scoped to the open path only; 0x5 stays CONTROL-less as accepted. |
| 121 | 6. **Target-channel opens** (`200b2c92b`): 0x7 rides the channel being opened |
| 122 | (`izd.b` sends via `izl.g(this.b, …)`); ch0-framed opens drew |
| 123 | STATUS_INVALID_CHANNEL (-5). |
| 124 | 7. **CONTROL-less setup** (`86039cc7c`): service-channel sends never set |
| 125 | CONTROL (`jbe.i` flags from `Lizm.f`, false for all service traffic); |
| 126 | our CONTROL-flagged 0x8000 was 0xff'd. |
| 127 | 8. **TLS wrap guard** (`572de7515`): fail loudly on zero-progress wrap instead |
| 128 | of spinning (also fixed a hung test worker). |
| 129 | |
| 130 | ### What has been ruled out |
| 131 | - **Encryption.** DHU decrypts our PingResponses happily and we decrypt its messages. |
| 132 | - **The CONTROL frame flag.** Tried both with and without `0x04` set; identical failure. |
| 133 | - **Direction.** Confirmed twice: `izu.java` handles inbound message 6 and logs |
| 134 | `SDP_RESPONSE_RECEIVED`. The phone sends 5, the head unit answers 6. |
| 135 | - **Device/OS.** Same on MAOS and GrapheneOS. |
| 136 | |
| 137 | ### The strongest untested lead |
| 138 | `defpackage/jog.java` is where the **live** control endpoint builds the request. Read it — |
| 139 | it is short and not obfuscated beyond names. What it does: |
| 140 | |
| 141 | | Field | Java | Set when | |
| 142 | |-------|------|----------| |
| 143 | | 1 | `xoa.c` bytes | only if `izu.g != null` | |
| 144 | | 2 | `xoa.d` bytes | only if `izu.h != null` | |
| 145 | | 3 | `xoa.e` bytes | only if `izu.i != null` | |
| 146 | | 4 | `xoa.f` string | only if `izu.f != null` | |
| 147 | | 5 | `xoa.g` string | **always** | |
| 148 | | 6 | `xoa.h` message `xgs` | only if version high enough and `izu.j != null` | |
| 149 | |
| 150 | Field 5 is composed from `Build.MANUFACTURER` and `Build.MODEL`: unless MODEL |
| 151 | already starts with MANUFACTURER, gearhead sends `MANUFACTURER + " " + MODEL` |
| 152 | (e.g. `"Google Pixel 8"` — manufacturer first, not `"Pixel 8 Google"`). This is |
| 153 | verified Dalvik ground truth: `disasm_jog.txt` shows `bJ(MODEL, MANUFACTURER, |
| 154 | " ")` and `a.bJ` returns `str2 + str3 + str`, i.e. MANUFACTURER + " " + MODEL; |
| 155 | hasbit 16 = field 5 confirmed. It is the **only unconditional field** — `g/h/i` |
| 156 | come from optional head-unit resource config, `f` from an optional string |
| 157 | resource, `j` from a version-gated cert string, and `jog` nulls `g/h/i/f` after |
| 158 | the first send, so every repeat is field-5-only by construction. |
| 159 | |
| 160 | It is then sent with `((jbj) obj).k(5, …)`, and `k()` routes to `o(i, msg, true, |
| 161 | …)` — but `m()` there constructs `new izn(z, false, …)`, and `izn.a` is |
| 162 | **isEncrypted**, `izn.b` is **isMediaPayload** (see `izn.toString()`: |
| 163 | "isEncrypted;isMediaPayload;callbackId;maxUnackedDuration", confirmed against |
| 164 | the disassembled `Lizm;-><init>` and the `Ljbe` flag assembly where |
| 165 | `Lizm->h`(encrypted)→`0x08` and `Lizm->f`(isControl/canFragment)→`0x04`). |
| 166 | So the `true` sets the **ENCRYPTED** bit, not CONTROL: gearhead's message-5 |
| 167 | frame is FIRST|LAST|ENCRYPTED = `0x0B` with the CONTROL bit **clear** — same as |
| 168 | every other control-channel frame both sides send. The earlier "CONTROL on/off" |
| 169 | experiments were testing a bit neither side ever sets on channel 0; no further |
| 170 | flag experiments are needed. |
| 171 | |
| 172 | **Fix applied (Task 3):** send *only* field 5 containing `"Google Pixel 8"` |
| 173 | (composed by `composeDiscoveryLabel()` in `GalControlSession.kt`), framing |
| 174 | unchanged at `0x0B`. The old code sent field 4 = `MODEL` + field 5 = |
| 175 | `MANUFACTURER`, which matches gearhead on neither count. |
| 176 | |
| 177 | If that still fails, capture the decrypted bytes gearhead itself sends: install real Android |
| 178 | Auto on a phone, point DHU at it through `dhu_relay.py`, and compare. The relay only sees |
| 179 | ciphertext, so you would need to also log gearhead's plaintext — easier is to diff our |
| 180 | request against the field table above until it matches byte for byte. |
| 181 | |
| 182 | Also worth checking: `izu.i(5, par.GAL_READ_WRITE_MESSAGE_RAND)` is an early-return guard |
| 183 | before the request is built. Whatever that gates might matter. |
| 184 | |
| 185 | --- |
| 186 | |
| 187 | ## 4. What is committed |
| 188 | |
| 189 | Protocol bring-up commits (Tasks 3+6), all pathspec-limited so other agents' |
| 190 | work was never swept in: |
| 191 | |
| 192 | ``` |
| 193 | 52e64a7b2 maauto: show car Presentation on main thread |
| 194 | 86039cc7c maauto: clear CONTROL on service-channel sends |
| 195 | 200b2c92b maauto: frame channel-open on its target channel |
| 196 | 572de7515 maauto: fail TLS wrap on zero progress, fix tests |
| 197 | 91f7b1d72 maauto: scope CONTROL bit to channel-open sends |
| 198 | 0b0a7cb6e maauto: set CONTROL on encrypted channel-0 sends |
| 199 | 01abb3bbe maauto: drain open queue on bare 0xff, try service 1 |
| 200 | e5d2ff668 maauto: open channels sequentially in HU wire order |
| 201 | c0126946b maauto: walk refusal test to ACTIVE before 0x8 |
| 202 | b73fe6848 maauto: log full control payloads inbound |
| 203 | e1389aa18 maauto: repair MessageStatus enum mangled by edit |
| 204 | d9694dab4 maauto: survive inbound MessageError without closing |
| 205 | a93db5e18 maauto: gate media setup on ChannelOpenResponse |
| 206 | 9689479d3 maauto: pass renamed device fields in GalConnection |
| 207 | 8449cbeb7 maauto: send field-5-only ServiceDiscoveryRequest |
| 208 | 5c323e528 maauto: preserve protocol handoff docs |
| 209 | ff9ea758e maauto: record completed bring-up in handoff |
| 210 | ``` |
| 211 | |
| 212 | Earlier foundation commits (handshake, transport, TLS codec, frame codec) |
| 213 | predate this list; see `git log --oneline -- auto/` for the full history. |
| 214 | |
| 215 | **85+ unit tests, all passing.** `:auto:protocol:testDebugUnitTest`. |
| 216 | |
| 217 | --- |
| 218 | |
| 219 | ## 5. Map of the code |
| 220 | |
| 221 | ### `auto/protocol/` — the wire protocol, deliberately Android-free |
| 222 | Keep it that way: it is what makes the handshake host-testable. Logging goes through the |
| 223 | `trace: (String) -> Unit` hook the app supplies, **not** `android.util.Log`. |
| 224 | |
| 225 | | File | Role | |
| 226 | |------|------| |
| 227 | | `FrameHeader.kt` | 4/8-byte frame header, flags | |
| 228 | | `Fragmenter.kt` / `FrameWriter.kt` / `FrameReader.kt` | splitting, framing, reassembly | |
| 229 | | `MessageCodec.kt` | the 2-byte big-endian message type prefix | |
| 230 | | `GalMessage.kt` | every message ID and the service enum | |
| 231 | | `VersionNegotiation.kt` | messages 1/2 — raw shorts, not protobuf | |
| 232 | | `GalCredential.kt` | loads the PEMs, builds the TLS context | |
| 233 | | `TlsCodec.kt` | per-frame application-data wrap/unwrap | |
| 234 | | `GalControlSession.kt` | the handshake state machine, no I/O | |
| 235 | | `GalConnection.kt` | ties transport + framing + TLS + session together | |
| 236 | | `GalTransport.kt` / `StreamTransport.kt` | byte-stream abstraction | |
| 237 | | `src/main/proto/gal/*.proto` | control, services, media | |
| 238 | | `src/main/assets/gal/*.pem` | the GAL credential (see §7) | |
| 239 | |
| 240 | ### `auto/` — the Android side |
| 241 | | File | Role | |
| 242 | |------|------| |
| 243 | | `network/HeadUnitServer.kt` | TCP listener on 5277, loopback-bound | |
| 244 | | `service/ProjectionService.kt` | foreground service, single-threaded pump loop | |
| 245 | | `platform/VideoSinkChannel.kt` | media setup → focus → start → stream | |
| 246 | | `platform/VideoEncoder.kt` | MediaCodec H.264 Baseline, surface input | |
| 247 | | `platform/CarDisplay.kt` | virtual display + `Presentation` placeholder UI | |
| 248 | |
| 249 | `ProjectionService` is single-threaded **on purpose**: one `SSLEngine` backs the connection |
| 250 | and an engine is not thread-safe, so reads, writes and encoder draining share a thread. |
| 251 | |
| 252 | ### `analysis/maauto/` — tooling (gitignored) |
| 253 | | File | Role | |
| 254 | |------|------| |
| 255 | | `FINDINGS.md` | the teardown. Read it. | |
| 256 | | `extract_key.py` | recovers the GAL private key from the APK | |
| 257 | | `verify_tls.sh` | proves the credential does a mutual-auth handshake | |
| 258 | | `dump_protos.py` | decodes any protobuf-lite descriptor in the APK to exact field numbers | |
| 259 | | `disasm.py` | androguard bytecode dump, for when jadx lies | |
| 260 | | `dhu_relay.py` | MITM between DHU and phone, dumps both directions | |
| 261 | | `dhu_probe.py` | stands in for the phone, dumps DHU's opening bytes | |
| 262 | | `jadx-out/` | the decompiled APK | |
| 263 | |
| 264 | --- |
| 265 | |
| 266 | ## 6. How to run the test loop |
| 267 | |
| 268 | ```powershell |
| 269 | # build + install (Pixel 8 / MAOS is 44050DLJH001PC) |
| 270 | cd C:\Users\Vayun\Documents\code\Modern-Apps |
| 271 | .\gradlew.bat :auto:assembleDev |
| 272 | adb -s 44050DLJH001PC install -r auto\build\outputs\apk\dev\auto-dev.apk |
| 273 | |
| 274 | # DHU reaches the phone through an adb forward; the PHONE listens |
| 275 | adb -s 44050DLJH001PC forward tcp:5277 tcp:5277 |
| 276 | adb -s 44050DLJH001PC shell am start -n com.vayunmathur.auto/.MainActivity |
| 277 | |
| 278 | # logs, in another window |
| 279 | adb -s 44050DLJH001PC logcat -v time MaAuto.Service:V MaAuto.Server:V MaAuto.Video:V "*:S" |
| 280 | |
| 281 | # the head unit |
| 282 | C:\Android\Sdk\extras\google\auto\desktop-head-unit.exe |
| 283 | ``` |
| 284 | |
| 285 | To see the wire instead, forward to 5278 and put the relay in the middle: |
| 286 | |
| 287 | ```powershell |
| 288 | adb -s 44050DLJH001PC forward tcp:5278 tcp:5277 |
| 289 | python analysis\maauto\dhu_relay.py 30 # listens on 5277, relays to 5278 |
| 290 | C:\Android\Sdk\extras\google\auto\desktop-head-unit.exe |
| 291 | ``` |
| 292 | |
| 293 | ### Things that will waste your time if you do not know them |
| 294 | - **DHU is interactive.** Piping its stdout closes its stdin and it exits in under a second. |
| 295 | Launch it with `Start-Process` (its own window), or relay to see the wire. |
| 296 | - **`adb logcat -d` was unreliable here.** It repeatedly showed a stale buffer. Use a live |
| 297 | capture (`Start-Job` around `adb logcat`) when checking a fresh run. |
| 298 | - **DHU defaults** to 800x480, 160 dpi, 30 fps, touch enabled — `config\default.ini`. That is |
| 299 | `VIDEO_800x480` = 1. |
| 300 | - **Two devices are usually attached.** Always pass `-s`. |
| 301 | - The Gradle build wedged once for ~9 minutes, almost certainly lock contention with another |
| 302 | agent's build. The same work took 12s afterwards. If a build hangs at "Calculating task |
| 303 | graph", kill it rather than waiting. |
| 304 | |
| 305 | --- |
| 306 | |
| 307 | ## 7. The credential |
| 308 | |
| 309 | `auto/protocol/src/main/assets/gal/` — leaf cert, its RSA private key, and the GAL root. All |
| 310 | three ship inside the APK. Recovered from gearhead by `extract_key.py`; documented in |
| 311 | `SUPPLY_CHAIN_RISKS.md` §10.2. |
| 312 | |
| 313 | **It expires 2026-12-09 and cannot be renewed by us.** We do not hold the root key. Google |
| 314 | also has a remote-provisioning path (`rvf`, fed by six phenotype flags), so the embedded cert |
| 315 | could stop being accepted before that date. Keep `extract_key.py` working so it can be |
| 316 | re-extracted from a newer gearhead. |
| 317 | |
| 318 | ### Expiry surfacing (Phase 8, landed) |
| 319 | |
| 320 | The phone status screen shows the leaf's remaining validity, parsed at runtime so it |
| 321 | stays correct across a rotation with no code change: `GalCredential.daysRemaining()` |
| 322 | (`CertificateFactory`, pure JVM — `auto/protocol` stays Android-free) → |
| 323 | `ProjectionService.publishCredentialExpiry()` seeds `AutoSessionState.credentialDaysLeft` |
| 324 | once per service start (never reset per session; the credential outlives connections) → |
| 325 | `AutoViewModel` → `SessionSnapshot.credentialDaysLeft` → `SessionCard.CredentialRow`. |
| 326 | Quiet day-count while far out, escalating warnings at 90 / 30 / 7 days, expired notice |
| 327 | at zero; all text in `strings.xml` (`session_credential_*`, plurals per CONTRIBUTING.md). |
| 328 | |
| 329 | ### Renewal decision: re-extract, not rvf (Phase 8) |
| 330 | |
| 331 | `rvg(Context)` reads six phenotype flags (`adbo.gu()` `a`–`f`): a cert PEM, an encrypted |
| 332 | key blob and a salt, each paired with a SHA-1 checksum, and builds `rvf` from them instead |
| 333 | of the hardcoded `rvd` when all three validate (`rvg.java:38-54`). `rvf` itself is a trivial |
| 334 | `rvh` holder — cert string, key blob, salt — decrypted by the same `rth`/`jca` path. |
| 335 | |
| 336 | That path is Google's own rotation channel **into the genuine gearhead app**, not something |
| 337 | a third-party sender can tap: the phenotype values are delivered server-side to Google's |
| 338 | package, and we have no way to fetch or inject them. So `rvf` is unusable to us by |
| 339 | construction, regardless of what cert it would carry. **Recommendation: re-extract from |
| 340 | each new gearhead release.** `extract_key.py` is pinned to the 17.5.663214 decompile |
| 341 | (`rvg`/`rvd`/`rth` class names and array shapes); if a newer gearhead renames those |
| 342 | families the script needs re-pinning to the new names, then `verify_tls.sh` re-proves the |
| 343 | triple before it ships. Not yet re-run against a newer APK here — that needs a current |
| 344 | gearhead pull plus `jadx` and the `openssl` CLI, none of which this environment had. |
| 345 | |
| 346 | ### Rotation runbook |
| 347 | |
| 348 | 1. Pull the current gearhead APK and re-run `analysis/maauto/extract_key.py`. On |
| 349 | `MATCH`, it writes `analysis/maauto/certs/` (`gal-client-cert.pem`, |
| 350 | `gal-client-key.pem`, `gal-root.pem`). |
| 351 | 2. Run `analysis/maauto/verify_tls.sh`: chain verifies against the GAL root, key |
| 352 | modulus equals cert modulus, TLS 1.2 mutual-auth handshake returns 0 (ok). |
| 353 | 3. Swap the three files under `auto/protocol/src/main/assets/gal/` — same names, same |
| 354 | PEM formats (`BEGIN CERTIFICATE` leaf + root, PKCS#8 `BEGIN PRIVATE KEY`). No code |
| 355 | change: `GalCredential.create()` parses whatever ships, and the session card reads |
| 356 | the new expiry at the next service start. |
| 357 | 4. Run `:auto:protocol:testDebugUnitTest` — `GalCredentialRotationTest` proves the |
| 358 | fixture-swap shape (fresh CA + leaf + key through `create()` into a mutual-auth |
| 359 | handshake), and `GalCredentialTest` re-proves the shipped triple. |
| 360 | 5. Live leg: full DHU handshake per §6 with the rotated PEMs in place. Needs DHU + |
| 361 | Pixel access — coordinate with the task 4 (DHU live-verification) owner via the |
| 362 | `ma-auto-parity` team channel; the JVM leg above is the most that can be shown |
| 363 | without it. |
| 364 | |
| 365 | --- |
| 366 | |
| 367 | ## 8. Suggested order from here |
| 368 | |
| 369 | 1. **Confirm the render path** — frames stream and are acked, but nobody has |
| 370 | confirmed they decode and display on the DHU surface yet. |
| 371 | 2. **Input tap E2E** — the channel is up (binds on the DHU's service 3, |
| 372 | key-binding round-trips with status 0); what remains is a real tap with |
| 373 | the DHU window focused, confirming `InputEvent.Touch` increments. |
| 374 | 3. **MAOS integration** (plan Phase 3) — the role move is the risky part. Both the |
| 375 | privapp-permissions entry and the `roles.xml` patch are boot-fatal if wrong, so change one |
| 376 | at a time and flash between. |
| 377 | 4. Audio (sinks on 4/5 carry `media_sink` payloads and should work; mic moved |
| 378 | to the DHU's service 7 — needs a live chunk check), then the real car UI. |
| 379 | Sensors are DONE against the DHU (LOCATION/NIGHT/DRIVING subscribed, |
| 380 | batches flow; other types get per-type -9, types 23-26 get bare 0xff). |
| 381 | |
| 382 | Phase 3 in the plan has the full role strategy: MA Auto takes |
| 383 | `SYSTEM_AUTOMOTIVE_PROJECTION`, MA Cast moves to `COMPANION_DEVICE_APP_STREAMING` (which |
| 384 | carries the same `virtual_device` permission set and is non-exclusive). That needs two new |
| 385 | patches because that role has no `defaultHolders` and an RRO cannot add a new framework |
| 386 | resource name. |
| 387 | |
| 388 | Note the current `CarDisplay` uses a **private** virtual display, which needs no permission. |
| 389 | That is why the DHU test works on a stock phone. Launching *other apps'* activities onto the |
| 390 | car display is what needs `ADD_TRUSTED_DISPLAY`, and input injection needs |
| 391 | `CREATE_VIRTUAL_DEVICE` — both role-carried. |
| 392 | |
| 393 | --- |
| 394 | |
| 395 | ## 9. Decompiler traps |
| 396 | |
| 397 | Four of these have already cost real time. Each produces plausible, compiling, **wrong** |
| 398 | code rather than an error. Details in FINDINGS.md. |
| 399 | |
| 400 | 1. `roc.aQ` — jadx caches a loop variable the bytecode re-reads. Gave a confident wrong key. |
| 401 | 2. `abpe.java:501` — the hasbit branch is inverted. |
| 402 | 3. `wub.o` — received media message IDs are compared against `id + 1`. |
| 403 | 4. Java escapes in descriptor strings — field 8 is `\b`, 12 is `\f`, 13 is `\r`. |
| 404 | |
| 405 | **When something is load-bearing, disassemble it** with `disasm.py` instead of reading jadx. |
| 406 | I lost a long stretch to trap 1 after a 6,400-candidate brute force found nothing. |
| 407 | |
| 408 | Two more found from live wire capture, not decompilation: |
| 409 | - The `0x04` CONTROL flag does **not** mean "control channel". Route by channel id. |
| 410 | The full rule, verified live across Runs 5-8: DHU→phone never sets the bit on |
| 411 | anything. Phone→HU sets it **only** on channel-0 channel-open requests (0x7, |
| 412 | framed `0x0F`). Discovery (0x5), ping responses and byebye ride CONTROL-clear |
| 413 | (`0x0B`) and are accepted that way; every service-channel send (setup, focus, |
| 414 | start, media) rides CONTROL-clear (`0x0B`) — a CONTROL-flagged 0x8000 is |
| 415 | 0xff'd. And the 0x7 must be framed on the TARGET channel, not channel 0 |
| 416 | (ch0-framed opens draw STATUS_INVALID_CHANNEL, -5). |
| 417 | - The head unit speaks first. The phone answers a version request, it does not send one. |
| 418 | - **DHU 2.0 service ids do NOT match gearhead's `rro`** (verified by decoding |
| 419 | the 569B 0x6 discovery payload, 2026-09-18). The DHU advertises 1-7 as: |
| 420 | 1=sensor (`Sensor{1,10,13}`, exactly `default.ini [sensors]`), 2=video, |
| 421 | 3=input (keycodes + 800x480 TouchConfig), 4/5=audio sinks, 6=vendor, |
| 422 | 7=mic (`MediaSourceService`). There is NO service 8. Owners bind by |
| 423 | **payload type** (`hasSensorSource`/`hasInputSource`/`hasMediaSource`), |
| 424 | like gearhead (`jlf.a(xpa)` reads the sensor config out of the entry) -- |
| 425 | never by hardcoded id. Sending sensor subscribes to the mic channel earns |
| 426 | `0xff` "unexpected message", which is what the ch7 failures were. |
| 427 | - **`xnv` SensorResponse is status-only** (`xow`: field 1 = `xls` status, no |
| 428 | type echo -- gearhead's `jcd.s` waits synchronously per subscribe). `08 00` |
| 429 | = SUCCESS; `08 f7 ff..` (10-byte varint) = -9 STATUS_INVALID_SENSOR. |
| 430 | Owners attribute answers FIFO in subscribe order. Our old |
| 431 | `{sensor_type=1, status=2}` layout parsed every real answer as |
| 432 | uninitialized → Observed. |