mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-11 00:12:24 +01:00
keep homemade head units without a certificate working, and read wheel buttons and the knob as main does
This commit is contained in:
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)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ class CryptoTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `TLS rejects a head unit that does not present a client certificate`() {
|
||||
fun `TLS still connects a head unit that presents no certificate, as homemade ones may`() {
|
||||
val generated = SelfSignedCert.generate()
|
||||
val identity = CertProvider.Identity(generated.keyStore, generated.certificate,
|
||||
SelfSignedCert.PASSWORD, "test")
|
||||
assertFalse(TlsSelfTest.run(identity, withClientCertificate = false))
|
||||
assertTrue(TlsSelfTest.run(identity, withClientCertificate = false))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user