Loading play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt +42 −37 Original line number Diff line number Diff line Loading @@ -19,10 +19,7 @@ import com.google.android.gms.common.api.Status import com.google.android.gms.nearby.exposurenotification.* import com.google.android.gms.nearby.exposurenotification.ExposureNotificationStatusCodes.* import com.google.android.gms.nearby.exposurenotification.internal.* import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.withTimeout import kotlinx.coroutines.* import org.json.JSONArray import org.json.JSONObject import org.microg.gms.common.Constants Loading Loading @@ -296,8 +293,9 @@ class ExposureNotificationServiceImpl(private val context: Context, private val Log.d(TAG, "Using key file supplier") try { while (keyFileSupplier.isAvailable && keyFileSupplier.hasNext()) { withContext(Dispatchers.IO) { try { val cacheFile = File(context.cacheDir, "en-keyfile-${System.currentTimeMillis()}-${Random.nextInt()}.zip") val cacheFile = File(context.cacheDir, "en-keyfile-${System.currentTimeMillis()}-${Random.nextLong()}.zip") ParcelFileDescriptor.AutoCloseInputStream(keyFileSupplier.next()).use { it.copyToFile(cacheFile) } val hash = MessageDigest.getInstance("SHA-256").digest(cacheFile) val storedKeys = database.storeDiagnosisFileUsed(tid, hash) Loading @@ -311,6 +309,7 @@ class ExposureNotificationServiceImpl(private val context: Context, private val Log.w(TAG, "Failed parsing file", e) } } } } catch (e: Exception) { Log.w(TAG, "Disconnected from key file supplier", e) } Loading @@ -331,6 +330,8 @@ class ExposureNotificationServiceImpl(private val context: Context, private val var newKeys = if (params.keys != null) database.finishSingleMatching(tid) else 0 for ((cacheFile, hash) in todoKeyFiles) { withContext(Dispatchers.IO) { try { ZipFile(cacheFile).use { zip -> for (entry in zip.entries()) { if (entry.name == "export.bin") { Loading @@ -357,6 +358,10 @@ class ExposureNotificationServiceImpl(private val context: Context, private val } } cacheFile.delete() } catch (e: Exception) { Log.w(TAG, "Failed parsing file", e) } } } val time = (System.currentTimeMillis() - start).coerceAtLeast(1).toDouble() / 1000.0 Loading Loading
play-services-nearby-core/src/main/kotlin/org/microg/gms/nearby/exposurenotification/ExposureNotificationServiceImpl.kt +42 −37 Original line number Diff line number Diff line Loading @@ -19,10 +19,7 @@ import com.google.android.gms.common.api.Status import com.google.android.gms.nearby.exposurenotification.* import com.google.android.gms.nearby.exposurenotification.ExposureNotificationStatusCodes.* import com.google.android.gms.nearby.exposurenotification.internal.* import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.withTimeout import kotlinx.coroutines.* import org.json.JSONArray import org.json.JSONObject import org.microg.gms.common.Constants Loading Loading @@ -296,8 +293,9 @@ class ExposureNotificationServiceImpl(private val context: Context, private val Log.d(TAG, "Using key file supplier") try { while (keyFileSupplier.isAvailable && keyFileSupplier.hasNext()) { withContext(Dispatchers.IO) { try { val cacheFile = File(context.cacheDir, "en-keyfile-${System.currentTimeMillis()}-${Random.nextInt()}.zip") val cacheFile = File(context.cacheDir, "en-keyfile-${System.currentTimeMillis()}-${Random.nextLong()}.zip") ParcelFileDescriptor.AutoCloseInputStream(keyFileSupplier.next()).use { it.copyToFile(cacheFile) } val hash = MessageDigest.getInstance("SHA-256").digest(cacheFile) val storedKeys = database.storeDiagnosisFileUsed(tid, hash) Loading @@ -311,6 +309,7 @@ class ExposureNotificationServiceImpl(private val context: Context, private val Log.w(TAG, "Failed parsing file", e) } } } } catch (e: Exception) { Log.w(TAG, "Disconnected from key file supplier", e) } Loading @@ -331,6 +330,8 @@ class ExposureNotificationServiceImpl(private val context: Context, private val var newKeys = if (params.keys != null) database.finishSingleMatching(tid) else 0 for ((cacheFile, hash) in todoKeyFiles) { withContext(Dispatchers.IO) { try { ZipFile(cacheFile).use { zip -> for (entry in zip.entries()) { if (entry.name == "export.bin") { Loading @@ -357,6 +358,10 @@ class ExposureNotificationServiceImpl(private val context: Context, private val } } cacheFile.delete() } catch (e: Exception) { Log.w(TAG, "Failed parsing file", e) } } } val time = (System.currentTimeMillis() - start).coerceAtLeast(1).toDouble() / 1000.0 Loading