audi 32 to 64 bit fix

This commit is contained in:
Seb3thehacker committed 2026-10-01 20:37:04 -07:00
1 parent ff8a6a4cff
commit f21df41506
3 files changed
+10 -4

No files matched your search

@@ -800,9 +800,11 @@ class GearslipRunner(
}
private fun onPingRequest(body: ByteArray) {
val timestamp = Protobuf.readInt32Field(body, 1)?.toLong() ?: System.nanoTime()
// The timestamp is an int64 and has to come back unchanged. Read as an int32 it was cut
// short, and a car that checks the echo (an Audi MIB2+) gave up at its second ping.
val timestamp = Protobuf.readInt64Field(body, 1) ?: System.nanoTime()
send(MSG_PING_RESPONSE, Protobuf.varintField(1, timestamp), encrypted = tls.handshakeComplete)
log.i("<- PingRequest / -> PingResponse (keeping the session alive)")
log.i("<- PingRequest(timestamp=$timestamp) / -> PingResponse (keeping the session alive)")
}
private fun send(
@@ -35,7 +35,10 @@ object Protobuf {
varint((field shl 3).toLong()) + varint(value)
/** Reads the single int32 in AuthResponse. Negative values are 10-byte varints. */
fun readInt32Field(data: ByteArray, field: Int): Int? {
fun readInt32Field(data: ByteArray, field: Int): Int? = readInt64Field(data, field)?.toInt()
/** Reads a varint field whole, for int64s such as a ping's timestamp. */
fun readInt64Field(data: ByteArray, field: Int): Long? {
var pos = 0
while (pos < data.size) {
val (tag, afterTag) = readVarint(data, pos) ?: return null
@@ -45,7 +48,7 @@ object Protobuf {
0 -> {
val (value, afterValue) = readVarint(data, pos) ?: return null
pos = afterValue
if (number == field) return value.toInt()
if (number == field) return value
}
2 -> {
val (len, afterLen) = readVarint(data, pos) ?: return null
@@ -51,6 +51,7 @@ object KnownApps {
private val hidden = setOf(
"com.google.android.dialer", // Google Phone
"com.google.android.googlequicksearchbox", // Google Assistant driving surfaces
"com.google.android.apps.maps", // Google Maps: shows as a messenger, and its car UI is Android Auto's own
)
fun isHidden(packageName: String): Boolean = packageName in hidden