keep homemade head units without a certificate working, and read wheel buttons and the knob as main does

This commit is contained in:
Seb3thehacker committed 2026-10-21 12:30:38 -07:00
1 parent c7077f2a57
commit ac8488200d
3 files changed
+10 -10

No files matched your search

@@ -888,9 +888,8 @@ class GearslipRunner(
for (key in Wire.allBytes(Wire.fields(keyEvent), 1)) {
val fields = Wire.fields(key)
val keycode = Wire.varint(fields, 1)?.toInt() ?: continue
val down = (Wire.varint(fields, 2) ?: continue) != 0L
if (Wire.varint(fields, 3) == null) continue
val longPress = (Wire.varint(fields, 4) ?: 0L) != 0L
val down = Wire.varint(fields, 2) == 1L
val longPress = Wire.varint(fields, 4) == 1L
log.i("<- key event: keycode=$keycode ${if (down) "down" else "up"}${if (longPress) " long" else ""}")
if (!CarKeys.onKey(keycode, down, longPress) && down) log.i("unhandled keycode=$keycode")
}
@@ -906,7 +905,6 @@ class GearslipRunner(
val keycode = Wire.varint(fields, 1)?.toInt() ?: continue
// int32, so a turn the other way arrives as a 64-bit two's complement varint.
val delta = Wire.varint(fields, 2)?.toInt() ?: continue
if (keycode != 65536 || delta == 0) continue
log.i("<- relative event: keycode=$keycode delta=$delta")
CarKeys.onRotate(delta)
}
@@ -38,9 +38,11 @@ class PhoneTls(keyStore: KeyStore, password: CharArray) {
engine = context.createSSLEngine().apply {
useClientMode = false
// Android Auto's phone endpoint requires the head unit to present a certificate.
needClientAuth = true
enabledProtocols = arrayOf("TLSv1.2")
// want, not need: we ask the head unit for its certificate so the run also tells
// us what real units present, but we never make the session depend on getting one.
// Homemade head units may have none.
wantClientAuth = true
enabledProtocols = arrayOf("TLSv1.2") // aasdk pins TLS 1.2
}
engine.beginHandshake()
}
@@ -172,7 +174,7 @@ class PhoneTls(keyStore: KeyStore, password: CharArray) {
}
}
} catch (_: SSLPeerUnverifiedException) {
log.i("head unit peer certificate is unavailable")
log.i("head unit presented NO certificate (we asked but did not require one)")
}
}