From d3d04459d66a0b7a357cffa3bdca84a21e4e0cd1 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Thu, 15 Oct 2020 22:09:15 +0200 Subject: [PATCH] EN: Support partial device list matches --- .../microg/gms/nearby/exposurenotification/DeviceInfo.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt index 79d298a4..cd4b1a81 100644 --- a/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt +++ b/play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/DeviceInfo.kt @@ -24,13 +24,20 @@ val currentDeviceInfo: DeviceInfo get() { var deviceInfo = knownDeviceInfo if (deviceInfo == null) { + // Note: Custom ROMs sometimes have slightly different model information, so we have some flexibility for those val byOem = allDeviceInfos.filter { it.oem.equalsIgnoreCase(Build.MANUFACTURER) } + val byDevice = allDeviceInfos.filter { it.device.equalsIgnoreCase(Build.DEVICE) } + val byModel = allDeviceInfos.filter { it.model.equalsIgnoreCase(Build.MODEL) } val exactMatch = byOem.find { it.device.equalsIgnoreCase(Build.DEVICE) && it.model.equalsIgnoreCase(Build.MODEL) } deviceInfo = when { exactMatch != null -> { // Exact match, use provided confidence exactMatch } + byModel.isNotEmpty() || byDevice.isNotEmpty() -> { + // We have data from "sister devices", that's way better than taking the OEM average + averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, (byDevice + byModel).distinct(), CalibrationConfidence.MEDIUM) + } byOem.isNotEmpty() -> { // Fallback to OEM average averageCurrentDeviceInfo(Build.MANUFACTURER, Build.DEVICE, Build.MODEL, byOem, CalibrationConfidence.LOW)