Update EN API

This commit is contained in:
Marvin W 2020-08-11 22:34:04 +02:00
parent 0388917350
commit df5ad9f3de
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
17 changed files with 469 additions and 26 deletions

View File

@ -7,7 +7,6 @@ package org.microg.gms.ui
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import com.db.williamchart.data.Scale

View File

@ -6,7 +6,10 @@
package org.microg.gms.ui
import android.annotation.TargetApi
import android.icu.text.DateFormat.getDateInstance
import android.os.Bundle
import android.text.format.DateFormat
import android.text.format.DateUtils
import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
@ -45,12 +48,22 @@ class ExposureNotificationsRpisFragment : PreferenceFragmentCompat() {
val lowestDate = Math.round((Date().time / 24 / 60 / 60 / 1000 - 13).toDouble()) * 24 * 60 * 60 * 1000
for (i in 0..13) {
val date = Calendar.getInstance().apply { this.time = Date(lowestDate + i * 24 * 60 * 60 * 1000) }.get(Calendar.DAY_OF_MONTH)
map[date.toString()] = 0f
val str = when (i) {
0, 13 -> DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMMd"), lowestDate + i * 24 * 60 * 60 * 1000).toString()
else -> IntArray(date).joinToString("").replace("0", "\u200B")
}
map[str] = 0f
}
val refDateLow = Calendar.getInstance().apply { this.time = Date(lowestDate) }.get(Calendar.DAY_OF_MONTH)
val refDateHigh = Calendar.getInstance().apply { this.time = Date(lowestDate + 13 * 24 * 60 * 60 * 1000) }.get(Calendar.DAY_OF_MONTH)
for (entry in database.rpiHistogram) {
val time = Date(entry.key * 24 * 60 * 60 * 1000)
val date = Calendar.getInstance().apply { this.time = time }.get(Calendar.DAY_OF_MONTH)
map[date.toString()] = entry.value.toFloat()
val str = when (date) {
refDateLow, refDateHigh -> DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "MMMd"), entry.key * 24 * 60 * 60 * 1000).toString()
else -> IntArray(date).joinToString("").replace("0", "\u200B")
}
map[str] = entry.value.toFloat()
}
val totalRpiCount = database.totalRpiCount
totalRpiCount to map

View File

@ -12,7 +12,7 @@
android:layout_height="180dp"
android:padding="16dp"
app:chart_barsColor="?attr/colorAccent"
app:chart_barsRadius="5dp"
app:chart_barsRadius="3dp"
app:chart_labelsColor="?android:attr/textColorSecondary"
app:chart_labelsSize="14sp"
app:chart_spacing="10dp" />
app:chart_spacing="6dp" />

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;

View File

@ -10,17 +10,21 @@ import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.*
import android.bluetooth.le.AdvertiseSettings.*
import android.content.Intent
import android.util.Log
import androidx.lifecycle.LifecycleService
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import java.io.FileDescriptor
import java.io.PrintWriter
import java.nio.ByteBuffer
import java.util.*
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
@TargetApi(21)
class AdvertiserService : LifecycleService() {
private val version = VERSION_1_0
private var callback: AdvertiseCallback? = null
private val advertiser: BluetoothLeAdvertiser
get() = BluetoothAdapter.getDefaultAdapter().bluetoothLeAdvertiser
@ -62,12 +66,22 @@ class AdvertiserService : LifecycleService() {
fun startAdvertising() {
lifecycleScope.launchWhenStarted {
do {
val payload = database.generateCurrentPayload(byteArrayOf(
0x40, // Version 1.0
currentDeviceInfo.txPowerCorrection.toByte(), // TX Power (TODO)
0x00, // Reserved
0x00 // Reserved
))
val aem = when (version) {
VERSION_1_0 -> byteArrayOf(
version, // Version and flags
(currentDeviceInfo.txPowerCorrection + TX_POWER_LOW).toByte(), // TX power
0x00, // Reserved
0x00 // Reserved
)
VERSION_1_1 -> byteArrayOf(
(version + currentDeviceInfo.confidence * 4).toByte(), // Version and flags
(currentDeviceInfo.txPowerCorrection + TX_POWER_LOW).toByte(), // TX power
0x00, // Reserved
0x00 // Reserved
)
else -> return@launchWhenStarted
}
val payload = database.generateCurrentPayload(aem)
var nextSend = nextKeyMillis.coerceAtMost(180000)
startAdvertising(payload, nextSend.toInt())
delay(nextSend)
@ -84,6 +98,8 @@ class AdvertiserService : LifecycleService() {
.setTxPowerLevel(ADVERTISE_TX_POWER_MEDIUM)
.setConnectable(false)
.build()
val (uuid, aem) = ByteBuffer.wrap(bytes).let { UUID(it.long, it.long) to it.int }
Log.d(TAG, "RPI: $uuid, Version: 0x${version.toString(16)}, TX Power: ${currentDeviceInfo.txPowerCorrection + TX_POWER_LOW}, AEM: 0x${aem.toLong().let { if (it < 0) 0x100000000L + it else it }.toString(16)}, Timeout: ${nextSend}ms")
callback = advertiser.startAdvertising(settings, data)
}

View File

@ -27,3 +27,28 @@ const val CONFIRM_ACTION_STOP = "stop"
const val CONFIRM_ACTION_KEYS = "keys"
const val PERMISSION_EXPOSURE_CALLBACK = "com.google.android.gms.nearby.exposurenotification.EXPOSURE_CALLBACK"
const val TX_POWER_LOW = -15
const val VERSION_1_0: Byte = 0x40
const val VERSION_1_1: Byte = 0x50
/**
* No calibration data, using fleet-wide as default options.
*/
const val CONFIDENCE_LOWEST: Byte = 0
/**
* Using average calibration over models from manufacturer.
*/
const val CONFIDENCE_LOW: Byte = 1
/**
* Using single-antenna orientation for a similar model.
*/
const val CONFIDENCE_MEDIUM: Byte = 2
/**
* Using significant calibration data for this model.
*/
const val CONFIDENCE_HIGH: Byte = 3

View File

@ -1,12 +1,366 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package org.microg.gms.nearby.exposurenotification
data class DeviceInfo(val txPowerCorrection: Int, val rssiCorrection: Int)
import android.os.Build
import android.util.Log
import kotlin.math.roundToInt
data class DeviceInfo(val oem: String, val model: String, val txPowerCorrection: Byte, val rssiCorrection: Byte, val confidence: Byte = CONFIDENCE_MEDIUM)
private var knownDeviceInfo: DeviceInfo? = null
fun averageCurrentDeviceInfo(oem: String, model: String, deviceInfos: List<DeviceInfo>, confidence: Byte = CONFIDENCE_LOW): DeviceInfo =
DeviceInfo(oem, model, deviceInfos.map { it.txPowerCorrection }.average().roundToInt().toByte(), deviceInfos.map { it.txPowerCorrection }.average().roundToInt().toByte(), CONFIDENCE_LOW)
// TODO
val currentDeviceInfo: DeviceInfo
get() = DeviceInfo(-17, -5)
get() {
var deviceInfo = knownDeviceInfo
if (deviceInfo == null) {
val byOem = allDeviceInfos.filter { it.oem == Build.MANUFACTURER }
val exactMatch = byOem.find { it.model == Build.MODEL }
deviceInfo = when {
exactMatch != null -> {
// Exact match
exactMatch
}
byOem.isNotEmpty() -> {
// Fallback to OEM average
averageCurrentDeviceInfo(Build.MANUFACTURER, Build.MODEL, byOem)
}
else -> {
// Fallback to all device average
averageCurrentDeviceInfo(Build.MANUFACTURER, Build.MODEL, allDeviceInfos, CONFIDENCE_LOWEST)
}
}
Log.d(TAG, "Selected $deviceInfo")
knownDeviceInfo = deviceInfo
}
return deviceInfo
}
/*
* Derived from en-calibration-2020-06-13.csv published via
* https://developers.google.com/android/exposure-notifications/ble-attenuation-computation#device-list
*/
val allDeviceInfos = listOf(
DeviceInfo("Asus", "ASUS_A001", -1, -22),
DeviceInfo("Asus", "ASUS_X008DC", -8, -19),
DeviceInfo("Asus", "ASUS_X00TD", -8, -29),
DeviceInfo("Asus", "ASUS_X018D", -6, -23),
DeviceInfo("Asus", "ASUS_X01BDA", -5, -26),
DeviceInfo("Asus", "ASUS_Z010D", -8, -17),
DeviceInfo("Asus", "ASUS_Z01FD", -4, -20),
DeviceInfo("Asus", "P027", -7, -23),
DeviceInfo("BlackBerry", "BBE100-4", -4, -24),
DeviceInfo("BlackBerry", "BBF100-6", -2, -26),
DeviceInfo("Blu", "Grand M", -12, -20),
DeviceInfo("Blu", "Studio Mega", -4, -28),
DeviceInfo("Blu", "Tank Xtreme 4.0", -6, -22),
DeviceInfo("Blu", "VIVO 5", -6, -30),
DeviceInfo("Blu", "Vivo ONE", -6, -36),
DeviceInfo("Coolpad", "Coolpad 8722V", -11, -18),
DeviceInfo("Essential Products", "PH-1", -3, -24),
DeviceInfo("Google", "Pixel", -15, -28),
DeviceInfo("Google", "Pixel 3", -4, -34),
DeviceInfo("Google", "Pixel 3a", -5, -39),
DeviceInfo("Google", "Pixel 3a XL", -7, -35),
DeviceInfo("Google", "Pixel 4", 5, -28),
DeviceInfo("Google", "Pixel 4 XL", -3, -26),
DeviceInfo("Google", "Pixel XL", -11, -34),
DeviceInfo("HTC", "2PS64", -2, -41),
DeviceInfo("HTC", "HTC 10", -3, -36),
DeviceInfo("HTC", "HTC Desire 530", -4, -33),
DeviceInfo("HTC", "HTC One A9", 1, -28),
DeviceInfo("HTC", "HTC One M9", 4, -30),
DeviceInfo("HTC", "HTC U11", -6, -26),
DeviceInfo("HTC", "HTC U11 plus", -3, -28),
DeviceInfo("HTC", "HTC U12 life", 5, -32),
DeviceInfo("HTC", "HTC U12+", -3, -29),
DeviceInfo("HTC", "HTC_U-1u", -18, -23),
DeviceInfo("HTC", "HTC_U-3u", -2, -20),
DeviceInfo("Huawei", "ANE-LX3", -6, -7),
DeviceInfo("Huawei", "CLT-L09", -7, -31),
DeviceInfo("Huawei", "COR-L29", -7, -5),
DeviceInfo("Huawei", "DRA-LX3", -6, -18),
DeviceInfo("Huawei", "HUAWEI TIT-AL00", -6, -9),
DeviceInfo("Huawei", "HW-01K", -9, -32),
DeviceInfo("Huawei", "KIW-L24", -1, -23),
DeviceInfo("Huawei", "MHA-L29", -1, -37),
DeviceInfo("Huawei", "NEO-L29", -13, -29),
DeviceInfo("Huawei", "Nexus 6P", -4, -31),
DeviceInfo("Huawei", "PIC-AL00", -7, -9),
DeviceInfo("Huawei", "PRA-LX1", 0, -7),
DeviceInfo("Huawei", "WAS-LX3", 0, -9),
DeviceInfo("Itel", "itel A32F", -1, -25),
DeviceInfo("LGE", "LG-AS110", -7, -24),
DeviceInfo("LGE", "LG-F500L", -13, -24),
DeviceInfo("LGE", "LG-F700L", 6, -31),
DeviceInfo("LGE", "LG-H345", -4, -23),
DeviceInfo("LGE", "LG-H815", -10, -24),
DeviceInfo("LGE", "LG-K100", -7, -19),
DeviceInfo("LGE", "LG-K350", -5, -20),
DeviceInfo("LGE", "LG-K430", -4, -20),
DeviceInfo("LGE", "LG-K500", -2, -20),
DeviceInfo("LGE", "LG-K540", 6, -27),
DeviceInfo("LGE", "LG-M250", 1, -25),
DeviceInfo("LGE", "LG-X230", -7, -25),
DeviceInfo("LGE", "LG-X240", -6, -28),
DeviceInfo("LGE", "LGLK430", -2, -17),
DeviceInfo("LGE", "LGLS450", -2, -21),
DeviceInfo("LGE", "LGM-V300L", -1, -24),
DeviceInfo("LGE", "LGUS991", -11, -25),
DeviceInfo("LGE", "LM-Q910", -8, -24),
DeviceInfo("LGE", "LM-X210", -7, -14),
DeviceInfo("LGE", "Nexus 5X", -15, -17),
DeviceInfo("LGE", "RS988", -2, -2),
DeviceInfo("LGE", "VS988", -14, -6),
DeviceInfo("LGE", "VS995", 2, -3),
DeviceInfo("Lava", "Z50", -6, -27),
DeviceInfo("LeTV", "Le X527", -2, -21),
DeviceInfo("Leagoo", "T5c", -37, -20),
DeviceInfo("Lenovo", "Lenovo A1010a20", -8, -27),
DeviceInfo("Lenovo", "Lenovo A6600d40", -7, -22),
DeviceInfo("Lenovo", "Lenovo K33a42", -13, -19),
DeviceInfo("Lenovo", "Lenovo K520", 7, -31),
DeviceInfo("Lenovo", "Lenovo K52e78", 3, -27),
DeviceInfo("Lenovo", "Lenovo K53a48", 2, -35),
DeviceInfo("Lenovo", "Lenovo K8", -2, -22),
DeviceInfo("Lenovo", "Lenovo K8 Note", -1, -28),
DeviceInfo("Lenovo", "Lenovo L78011", -6, -20),
DeviceInfo("Lenovo", "Lenovo P2a42", -3, -18),
DeviceInfo("Lenovo", "Lenovo TB3-710I", 8, -37),
DeviceInfo("Lenovo", "Lenovo Z90-3", -1, -23),
DeviceInfo("Motorola", "Moto G (4)", -9, -14),
DeviceInfo("Motorola", "Moto G (5)", -6, -23),
DeviceInfo("Motorola", "Moto G (5) Plus", -6, -17),
DeviceInfo("Motorola", "Moto G (5S) Plus", 7, -28),
DeviceInfo("Motorola", "Moto G Play", -3, -23),
DeviceInfo("Motorola", "Moto Z2 Play", -4, -21),
DeviceInfo("Motorola", "MotoE2", -3, 0),
DeviceInfo("Motorola", "MotoG3", 1, -29),
DeviceInfo("Motorola", "Nexus 6", 14, -46),
DeviceInfo("Motorola", "XT1034", -5, 0),
DeviceInfo("Motorola", "XT1080", -1, -31),
DeviceInfo("Motorola", "XT1575", -3, -32),
DeviceInfo("Motorola", "XT1609", 4, -33),
DeviceInfo("Motorola", "XT1635-01", -5, -16),
DeviceInfo("Motorola", "XT1650", -11, -29),
DeviceInfo("Motorola", "XT1706", -4, -23),
DeviceInfo("Motorola", "moto e5 play", -4, -28),
DeviceInfo("Motorola", "moto e5 plus", 4, -22),
DeviceInfo("Motorola", "moto g(6) play", -4, -21),
DeviceInfo("Motorola", "moto g(7)", -6, -20),
DeviceInfo("Motorola", "moto x4", -8, -26),
DeviceInfo("Motorola", "moto z3", -7, -27),
DeviceInfo("Motorola", "moto z4", 0, -37),
DeviceInfo("Motorola", "motorola one", -3, -27),
DeviceInfo("Nokia", "Nokia 1", -3, -30),
DeviceInfo("Nokia", "Nokia 2", -4, -26),
DeviceInfo("Nokia", "Nokia 2.1", -9, -22),
DeviceInfo("Nokia", "Nokia 3.1", -7, -18),
DeviceInfo("Nokia", "Nokia 6.1 Plus", 2, -28),
DeviceInfo("Nokia", "Nokia 7 plus", -1, -33),
DeviceInfo("Nokia", "Nokia 7.1", 0, -33),
DeviceInfo("Nokia", "Nokia 7.2", -3, -7),
DeviceInfo("Nokia", "Nokia 8 Sirocco", 2, -36),
DeviceInfo("Nokia", "TA-1025", 5, -24),
DeviceInfo("Nokia", "TA-1054", -3, -31),
DeviceInfo("OnePlus", "ONEPLUS A3000", -12, -29),
DeviceInfo("OnePlus", "ONEPLUS A5000", 1, -25),
DeviceInfo("OnePlus", "ONEPLUS A5010", -2, -27),
DeviceInfo("OnePlus", "ONEPLUS A6003", 0, -37),
DeviceInfo("OnePlus", "ONEPLUS A6013", -2, -24),
DeviceInfo("Orbic", "RC555L", 2, -27),
DeviceInfo("Razer", "Phone", -3, -33),
DeviceInfo("Razer", "Phone 2", -5, -27),
DeviceInfo("Samsung", "SAMSUNG-SM-G891A", -1, -31),
DeviceInfo("Samsung", "SAMSUNG-SM-G900A", 0, -27),
DeviceInfo("Samsung", "SAMSUNG-SM-G930AZ", 6, -34),
DeviceInfo("Samsung", "SAMSUNG-SM-G935A", 6, -35),
DeviceInfo("Samsung", "SC-02J", 7, -36),
DeviceInfo("Samsung", "SC-02K", 4, -27),
DeviceInfo("Samsung", "SC-02L", -2, -25),
DeviceInfo("Samsung", "SC-03K", 1, -35),
DeviceInfo("Samsung", "SCV33", -1, -28),
DeviceInfo("Samsung", "SCV36", 1, -29),
DeviceInfo("Samsung", "SM-A105FN", -4, -27),
DeviceInfo("Samsung", "SM-A300FU", -3, -18),
DeviceInfo("Samsung", "SM-A320FL", -17, -26),
DeviceInfo("Samsung", "SM-A510F", -6, -2),
DeviceInfo("Samsung", "SM-A510M", -5, 2),
DeviceInfo("Samsung", "SM-A710F", 4, -6),
DeviceInfo("Samsung", "SM-A750GN", -2, -21),
DeviceInfo("Samsung", "SM-A9200", -1, -30),
DeviceInfo("Samsung", "SM-A920F", 0, -32),
DeviceInfo("Samsung", "SM-C5010", -1, -22),
DeviceInfo("Samsung", "SM-C7100", -2, -2),
DeviceInfo("Samsung", "SM-G1650", -2, -26),
DeviceInfo("Samsung", "SM-G532F", -5, -18),
DeviceInfo("Samsung", "SM-G532M", -6, -22),
DeviceInfo("Samsung", "SM-G6000", -3, -20),
DeviceInfo("Samsung", "SM-G610F", -6, -1),
DeviceInfo("Samsung", "SM-G611F", 0, 0),
DeviceInfo("Samsung", "SM-G850F", 0, -28),
DeviceInfo("Samsung", "SM-G8850", -5, -27),
DeviceInfo("Samsung", "SM-G885S", -3, -33),
DeviceInfo("Samsung", "SM-G892A", -5, -16),
DeviceInfo("Samsung", "SM-G900F", 0, -28),
DeviceInfo("Samsung", "SM-G920F", 3, -29),
DeviceInfo("Samsung", "SM-G920I", 4, -25),
DeviceInfo("Samsung", "SM-G920T", 0, -25),
DeviceInfo("Samsung", "SM-G925F", -4, -30),
DeviceInfo("Samsung", "SM-G925I", 4, -21),
DeviceInfo("Samsung", "SM-G930P", 2, -35),
DeviceInfo("Samsung", "SM-G930T", 0, -29),
DeviceInfo("Samsung", "SM-G930V", -4, -36),
DeviceInfo("Samsung", "SM-G930VL", -4, -31),
DeviceInfo("Samsung", "SM-G9350", -5, -35),
DeviceInfo("Samsung", "SM-G935F", 2, -26),
DeviceInfo("Samsung", "SM-G935P", -4, -31),
DeviceInfo("Samsung", "SM-G935R4", 0, -29),
DeviceInfo("Samsung", "SM-G935T", -5, -26),
DeviceInfo("Samsung", "SM-G935V", 6, -34),
DeviceInfo("Samsung", "SM-G950F", -3, -27),
DeviceInfo("Samsung", "SM-G950N", -3, -29),
DeviceInfo("Samsung", "SM-G950U1", -3, -30),
DeviceInfo("Samsung", "SM-G950W", 0, -27),
DeviceInfo("Samsung", "SM-G955F", -1, -28),
DeviceInfo("Samsung", "SM-G955N", 7, -28),
DeviceInfo("Samsung", "SM-G955U", -6, -23),
DeviceInfo("Samsung", "SM-G955U1", -2, -24),
DeviceInfo("Samsung", "SM-G955W", -5, -21),
DeviceInfo("Samsung", "SM-G9600", -2, -28),
DeviceInfo("Samsung", "SM-G960F", 1, -27),
DeviceInfo("Samsung", "SM-G960N", -3, -31),
DeviceInfo("Samsung", "SM-G960U1", -3, -21),
DeviceInfo("Samsung", "SM-G9650", 1, -25),
DeviceInfo("Samsung", "SM-G965F", -3, -25),
DeviceInfo("Samsung", "SM-G965N", -2, -28),
DeviceInfo("Samsung", "SM-G965U1", -3, -31),
DeviceInfo("Samsung", "SM-G975F", -7, -27),
DeviceInfo("Samsung", "SM-G977P", -3, -35),
DeviceInfo("Samsung", "SM-J100VPP", 2, -25),
DeviceInfo("Samsung", "SM-J250F", -6, -27),
DeviceInfo("Samsung", "SM-J260G", -7, -20),
DeviceInfo("Samsung", "SM-J320V", -10, -12),
DeviceInfo("Samsung", "SM-J327U", -1, -23),
DeviceInfo("Samsung", "SM-J330F", -9, -17),
DeviceInfo("Samsung", "SM-J330L", -9, -17),
DeviceInfo("Samsung", "SM-J337V", -5, -18),
DeviceInfo("Samsung", "SM-J400G", -4, -26),
DeviceInfo("Samsung", "SM-J500F", -3, -17),
DeviceInfo("Samsung", "SM-J500H", -8, -15),
DeviceInfo("Samsung", "SM-J500M", -3, -16),
DeviceInfo("Samsung", "SM-J510F", -5, -13),
DeviceInfo("Samsung", "SM-J510FN", -6, -15),
DeviceInfo("Samsung", "SM-J510GN", -6, -16),
DeviceInfo("Samsung", "SM-J510MN", -6, -15),
DeviceInfo("Samsung", "SM-J610F", 0, -30),
DeviceInfo("Samsung", "SM-J727V", -2, -20),
DeviceInfo("Samsung", "SM-J730K", -5, -28),
DeviceInfo("Samsung", "SM-J810F", -6, -26),
DeviceInfo("Samsung", "SM-M205F", 4, -25),
DeviceInfo("Samsung", "SM-N910C", 10, -41),
DeviceInfo("Samsung", "SM-N915G", -5, -29),
DeviceInfo("Samsung", "SM-N9208", -2, -31),
DeviceInfo("Samsung", "SM-N920C", -3, -40),
DeviceInfo("Samsung", "SM-N930R4", 2, -31),
DeviceInfo("Samsung", "SM-N950F", -5, -18),
DeviceInfo("Samsung", "SM-N950N", -3, -20),
DeviceInfo("Samsung", "SM-N950U", -3, -20),
DeviceInfo("Samsung", "SM-N950U1", -3, -27),
DeviceInfo("Samsung", "SM-N960F", 2, -37),
DeviceInfo("Samsung", "SM-N960N", -1, -28),
DeviceInfo("Samsung", "SM-N960U1", -2, -27),
DeviceInfo("Samsung", "SM-S367VL", -8, -26),
DeviceInfo("Samsung", "SM-S727VL", -1, -20),
DeviceInfo("Samsung", "SM-T350", 4, -28),
DeviceInfo("Samsung", "SM-T378V", -6, -22),
DeviceInfo("Samsung", "SM-T380", -4, -16),
DeviceInfo("Samsung", "SM-T380C", 7, -28),
DeviceInfo("Samsung", "SM-T385C", -2, -21),
DeviceInfo("Samsung", "SM-T385K", 0, -22),
DeviceInfo("Samsung", "SM-T385L", -8, -16),
DeviceInfo("Samsung", "SM-T390", -17, -29),
DeviceInfo("Samsung", "SM-T395", -13, -34),
DeviceInfo("Samsung", "SM-T580", -15, -22),
DeviceInfo("Samsung", "SM-T820", -21, -22),
DeviceInfo("Samsung", "SM-T827V", -6, -18),
DeviceInfo("Samsung", "SM-T837V", -2, -21),
DeviceInfo("Sharp", "SH-03K", -4, -26),
DeviceInfo("Sony", "602SO", -8, -33),
DeviceInfo("Sony", "701SO", -3, -22),
DeviceInfo("Sony", "801SO", 6, -36),
DeviceInfo("Sony", "E6603", -3, -18),
DeviceInfo("Sony", "E6633", -2, -20),
DeviceInfo("Sony", "E6683", 1, -19),
DeviceInfo("Sony", "F5121", 8, -46),
DeviceInfo("Sony", "F8131", -11, -33),
DeviceInfo("Sony", "F8331", -12, -34),
DeviceInfo("Sony", "F8332", -11, -31),
DeviceInfo("Sony", "G3123", -5, -24),
DeviceInfo("Sony", "G3223", 3, -38),
DeviceInfo("Sony", "G3313", 0, -24),
DeviceInfo("Sony", "G8142", 1, -23),
DeviceInfo("Sony", "G8232", -5, -36),
DeviceInfo("Sony", "G8341", 5, -33),
DeviceInfo("Sony", "G8342", 1, -31),
DeviceInfo("Sony", "G8441", 3, -26),
DeviceInfo("Sony", "H8216", -6, -28),
DeviceInfo("Sony", "H8266", -1, -31),
DeviceInfo("Sony", "H8296", -5, -30),
DeviceInfo("Sony", "H8314", -2, -36),
DeviceInfo("Sony", "H8324", -6, -24),
DeviceInfo("Sony", "H8416", 5, -36),
DeviceInfo("Sony", "I4213", 0, -32),
DeviceInfo("Sony", "SO-01J", -3, -36),
DeviceInfo("Sony", "SO-03J", -6, -33),
DeviceInfo("Sony", "SO-04J", -1, -35),
DeviceInfo("Sony", "SOV33", -10, -31),
DeviceInfo("Sony", "SOV34", -4, -34),
DeviceInfo("Sony", "SOV36", -2, -30),
DeviceInfo("TCL", "5159A", 1, -35),
DeviceInfo("Tecno", "TECNO KB8", -9, -33),
DeviceInfo("Vivo", "vivo 1723", 4, -30),
DeviceInfo("Vivo", "vivo 1804", -4, -22),
DeviceInfo("Vivo", "vivo 1851", 0, -31),
DeviceInfo("Xiaomi", "MI 4W", -4, -21),
DeviceInfo("Xiaomi", "MI 5", -7, -26),
DeviceInfo("Xiaomi", "MI 5s", -13, -24),
DeviceInfo("Xiaomi", "MI 5s Plus", -6, -30),
DeviceInfo("Xiaomi", "MI 6", 3, -36),
DeviceInfo("Xiaomi", "MI 8", -8, -26),
DeviceInfo("Xiaomi", "MI 8 Lite", -9, -19),
DeviceInfo("Xiaomi", "MI 8 Pro", -8, -33),
DeviceInfo("Xiaomi", "MI MAX 3", -1, -32),
DeviceInfo("Xiaomi", "MI NOTE LTE", 10, -30),
DeviceInfo("Xiaomi", "MIX", -15, -28),
DeviceInfo("Xiaomi", "Mi A1", -4, -28),
DeviceInfo("Xiaomi", "Mi A2", -5, -34),
DeviceInfo("Xiaomi", "Mi A2 Lite", -4, -19),
DeviceInfo("Xiaomi", "Mi A3", -5, -20),
DeviceInfo("Xiaomi", "Mi MIX 2", -4, -27),
DeviceInfo("Xiaomi", "Mi MIX 2S", -8, -17),
DeviceInfo("Xiaomi", "Mi Note 2", -10, -32),
DeviceInfo("Xiaomi", "POCOPHONE F1", 2, -37),
DeviceInfo("Xiaomi", "Redmi 3", -6, -45),
DeviceInfo("Xiaomi", "Redmi 3S", -8, -25),
DeviceInfo("Xiaomi", "Redmi 4X", -8, -24),
DeviceInfo("Xiaomi", "Redmi 5A", -6, -25),
DeviceInfo("Xiaomi", "Redmi 6 Pro", -3, -24),
DeviceInfo("Xiaomi", "Redmi Note 3", -2, -18),
DeviceInfo("Xiaomi", "Redmi Note 5", -2, -22),
DeviceInfo("Xiaomi", "Redmi Note 6 Pro", 0, -32),
DeviceInfo("Xiaomi", "Redmi S2", -5, -24),
DeviceInfo("ZTE", "Z833", -2, -29),
DeviceInfo("ZTE", "ZTE A2020U Pro", -9, -21),
DeviceInfo("Zebra", "TC52", 5, -35),
DeviceInfo("Zebra", "TC57", -7, -23)
)

View File

@ -39,7 +39,7 @@ class ExposureNotificationService : BaseService(TAG, GmsService.NEARBY_EXPOSURE)
Log.d(TAG, "handleServiceRequest: " + request.packageName)
callback.onPostInitCompleteWithConnectionInfo(SUCCESS, ExposureNotificationServiceImpl(this, request.packageName), ConnectionInfo().apply {
features = arrayOf(Feature("nearby_exposure_notification", 2))
features = arrayOf(Feature("nearby_exposure_notification", 3))
})
}
}

View File

@ -277,4 +277,10 @@ class ExposureNotificationServiceImpl(private val context: Context, private val
Log.w(TAG, "Callback failed", e)
}
}
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
if (super.onTransact(code, data, reply, flags)) return true
Log.d(TAG, "onTransact [unknown]: $code, $data, $flags")
return false
}
}

View File

@ -10,6 +10,7 @@ import android.app.Service
import android.bluetooth.BluetoothAdapter
import android.bluetooth.le.*
import android.content.Intent
import android.os.Build
import android.os.IBinder
@TargetApi(21)
@ -55,8 +56,13 @@ class ScannerService : Service() {
private fun startScan() {
if (started) return
scanner.startScan(
listOf(ScanFilter.Builder().setServiceUuid(SERVICE_UUID).setServiceData(SERVICE_UUID, byteArrayOf(0), byteArrayOf(0)).build()),
ScanSettings.Builder().build(),
listOf(ScanFilter.Builder()
.setServiceUuid(SERVICE_UUID)
.setServiceData(SERVICE_UUID, byteArrayOf(0), byteArrayOf(0))
.build()),
ScanSettings.Builder()
.let { if (Build.VERSION.SDK_INT >= 23) it.setMatchMode(ScanSettings.MATCH_MODE_STICKY) else it }
.build(),
callback
)
started = true

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby;

View File

@ -1,6 +1,9 @@
/*
* SPDX-FileCopyrightText: 2020, microG Project Team
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0 AND CC-BY-4.0
* Notice: Portions of this file are reproduced from work created and shared by Google and used
* according to terms described in the Creative Commons 4.0 Attribution License.
* See https://developers.google.com/readme/policies for details.
*/
package com.google.android.gms.nearby.exposurenotification;