mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-11-30 23:23:01 +00:00
EN: Don't create TEK without need
This commit is contained in:
parent
6ec8332b1e
commit
a016feba35
2 changed files with 22 additions and 17 deletions
|
@ -96,7 +96,12 @@ class ExposureNotificationsPreferencesFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
collectedRpis.summary = getString(R.string.pref_exposure_collected_rpis_summary, lastHourKeys)
|
collectedRpis.summary = getString(R.string.pref_exposure_collected_rpis_summary, lastHourKeys)
|
||||||
advertisingId.summary = currentId.toString()
|
if (currentId != null) {
|
||||||
|
advertisingId.isVisible = true
|
||||||
|
advertisingId.summary = currentId.toString()
|
||||||
|
} else {
|
||||||
|
advertisingId.isVisible = false
|
||||||
|
}
|
||||||
exposureApps.removeAll()
|
exposureApps.removeAll()
|
||||||
if (apps.isEmpty()) {
|
if (apps.isEmpty()) {
|
||||||
exposureApps.addPreference(exposureAppsNone)
|
exposureApps.addPreference(exposureAppsNone)
|
||||||
|
|
|
@ -499,29 +499,29 @@ class ExposureDatabase private constructor(private val context: Context) : SQLit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val currentTemporaryExposureKey: TemporaryExposureKey
|
private fun ensureTemporaryExposureKey(): TemporaryExposureKey = writableDatabase.let { database ->
|
||||||
get() = writableDatabase.let { database ->
|
database.beginTransaction()
|
||||||
database.beginTransaction()
|
try {
|
||||||
try {
|
var key = findOwnKeyAt(currentRollingStartNumber.toInt(), database)
|
||||||
var key = findOwnKeyAt(currentRollingStartNumber.toInt(), database)
|
if (key == null) {
|
||||||
if (key == null) {
|
key = generateCurrentTemporaryExposureKey()
|
||||||
key = generateCurrentTemporaryExposureKey()
|
storeOwnKey(key, database)
|
||||||
storeOwnKey(key, database)
|
|
||||||
}
|
|
||||||
database.setTransactionSuccessful()
|
|
||||||
key
|
|
||||||
} finally {
|
|
||||||
database.endTransaction()
|
|
||||||
}
|
}
|
||||||
|
database.setTransactionSuccessful()
|
||||||
|
key
|
||||||
|
} finally {
|
||||||
|
database.endTransaction()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val currentRpiId: UUID
|
val currentRpiId: UUID?
|
||||||
get() {
|
get() {
|
||||||
val buffer = ByteBuffer.wrap(currentTemporaryExposureKey.generateRpiId(currentIntervalNumber.toInt()))
|
val key = findOwnKeyAt(currentRollingStartNumber.toInt()) ?: return null
|
||||||
|
val buffer = ByteBuffer.wrap(key.generateRpiId(currentIntervalNumber.toInt()))
|
||||||
return UUID(buffer.long, buffer.long)
|
return UUID(buffer.long, buffer.long)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateCurrentPayload(metadata: ByteArray) = currentTemporaryExposureKey.generatePayload(currentIntervalNumber.toInt(), metadata)
|
fun generateCurrentPayload(metadata: ByteArray) = ensureTemporaryExposureKey().generatePayload(currentIntervalNumber.toInt(), metadata)
|
||||||
|
|
||||||
override fun getWritableDatabase(): SQLiteDatabase {
|
override fun getWritableDatabase(): SQLiteDatabase {
|
||||||
if (this != instance) {
|
if (this != instance) {
|
||||||
|
|
Loading…
Reference in a new issue