mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-11 08:12:26 +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)) {
|
for (key in Wire.allBytes(Wire.fields(keyEvent), 1)) {
|
||||||
val fields = Wire.fields(key)
|
val fields = Wire.fields(key)
|
||||||
val keycode = Wire.varint(fields, 1)?.toInt() ?: continue
|
val keycode = Wire.varint(fields, 1)?.toInt() ?: continue
|
||||||
val down = (Wire.varint(fields, 2) ?: continue) != 0L
|
val down = Wire.varint(fields, 2) == 1L
|
||||||
if (Wire.varint(fields, 3) == null) continue
|
val longPress = Wire.varint(fields, 4) == 1L
|
||||||
val longPress = (Wire.varint(fields, 4) ?: 0L) != 0L
|
|
||||||
log.i("<- key event: keycode=$keycode ${if (down) "down" else "up"}${if (longPress) " long" else ""}")
|
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")
|
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
|
val keycode = Wire.varint(fields, 1)?.toInt() ?: continue
|
||||||
// int32, so a turn the other way arrives as a 64-bit two's complement varint.
|
// int32, so a turn the other way arrives as a 64-bit two's complement varint.
|
||||||
val delta = Wire.varint(fields, 2)?.toInt() ?: continue
|
val delta = Wire.varint(fields, 2)?.toInt() ?: continue
|
||||||
if (keycode != 65536 || delta == 0) continue
|
|
||||||
log.i("<- relative event: keycode=$keycode delta=$delta")
|
log.i("<- relative event: keycode=$keycode delta=$delta")
|
||||||
CarKeys.onRotate(delta)
|
CarKeys.onRotate(delta)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ class PhoneTls(keyStore: KeyStore, password: CharArray) {
|
|||||||
|
|
||||||
engine = context.createSSLEngine().apply {
|
engine = context.createSSLEngine().apply {
|
||||||
useClientMode = false
|
useClientMode = false
|
||||||
// Android Auto's phone endpoint requires the head unit to present a certificate.
|
// want, not need: we ask the head unit for its certificate so the run also tells
|
||||||
needClientAuth = true
|
// us what real units present, but we never make the session depend on getting one.
|
||||||
enabledProtocols = arrayOf("TLSv1.2")
|
// Homemade head units may have none.
|
||||||
|
wantClientAuth = true
|
||||||
|
enabledProtocols = arrayOf("TLSv1.2") // aasdk pins TLS 1.2
|
||||||
}
|
}
|
||||||
engine.beginHandshake()
|
engine.beginHandshake()
|
||||||
}
|
}
|
||||||
@@ -172,7 +174,7 @@ class PhoneTls(keyStore: KeyStore, password: CharArray) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_: SSLPeerUnverifiedException) {
|
} 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
|
@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 generated = SelfSignedCert.generate()
|
||||||
val identity = CertProvider.Identity(generated.keyStore, generated.certificate,
|
val identity = CertProvider.Identity(generated.keyStore, generated.certificate,
|
||||||
SelfSignedCert.PASSWORD, "test")
|
SelfSignedCert.PASSWORD, "test")
|
||||||
assertFalse(TlsSelfTest.run(identity, withClientCertificate = false))
|
assertTrue(TlsSelfTest.run(identity, withClientCertificate = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in new issue
Block a user