mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-12-04 00:37:27 +00:00
EN: Catch errors in zip file processing
This commit is contained in:
parent
8e7544bd14
commit
f12536e6ce
1 changed files with 42 additions and 37 deletions
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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") {
|
||||
|
@ -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…
Reference in a new issue