From a3d6f1aed5198d89602b3d0d000a5e063f40fa75 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 10 Dec 2020 16:55:19 +0100 Subject: [PATCH] EN: Don't adjust tx power by TX_POWER_LOW (-15) The exposure-notifications-internal suggests that this is the thing to do, but the actual implementaton doesn't. --- .../gms/nearby/exposurenotification/AdvertiserService.kt | 6 +++--- .../gms/nearby/exposurenotification/ExposureDatabase.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt index 2e048b28..2c0b4401 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/AdvertiserService.kt @@ -117,13 +117,13 @@ class AdvertiserService : LifecycleService() { val aemBytes = when (version) { VERSION_1_0 -> byteArrayOf( version, // Version and flags - (currentDeviceInfo.txPowerCorrection + TX_POWER_LOW).toByte(), // TX power + currentDeviceInfo.txPowerCorrection, // TX power 0x00, // Reserved 0x00 // Reserved ) VERSION_1_1 -> byteArrayOf( (version + currentDeviceInfo.confidence.toByte() * 4).toByte(), // Version and flags - (currentDeviceInfo.txPowerCorrection + TX_POWER_LOW).toByte(), // TX power + currentDeviceInfo.txPowerCorrection, // TX power 0x00, // Reserved 0x00 // Reserved ) @@ -175,7 +175,7 @@ class AdvertiserService : LifecycleService() { Since: ${Date(startTime)} RPI: $uuid Version: 0x${version.toString(16)} - TX Power: ${currentDeviceInfo.txPowerCorrection + TX_POWER_LOW} + TX Power: ${currentDeviceInfo.txPowerCorrection} AEM: 0x${aem.toLong().let { if (it < 0) 0x100000000L + it else it }.toString(16)} """.trimIndent()) } catch (e: Exception) { diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureDatabase.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureDatabase.kt index 4fcf3d01..3a27339f 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureDatabase.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureDatabase.kt @@ -490,7 +490,7 @@ class ExposureDatabase private constructor(private val context: Context) : SQLit }.mapNotNull { val decrypted = key.cryptAem(it.rpi, it.aem) val version = (decrypted[0] and 0xf0.toByte()) - val txPower = if (decrypted.size >= 4 && version >= VERSION_1_0) decrypted[1].toInt() else (averageDeviceInfo.txPowerCorrection + TX_POWER_LOW) + val txPower = if (decrypted.size >= 4 && version >= VERSION_1_0) decrypted[1].toInt() else averageDeviceInfo.txPowerCorrection.toInt() val confidence = if (decrypted.size >= 4 && version >= VERSION_1_1) ((decrypted[0] and 0xc) / 4) else (averageDeviceInfo.confidence) if (version > VERSION_1_1) { Log.w(TAG, "Unknown AEM version: 0x${version.toString(16)}")