Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 29313bae authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

perf: remove signature verify cap

Let signature verification run fully in parallel to minimize matching time.
parent 97d18bfb
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -37,8 +37,6 @@ import foundation.e.apps.domain.preferences.AppPreferencesRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.util.Locale
@@ -64,8 +62,6 @@ class UpdatesManagerImpl @Inject constructor(
        private const val MILLIS_IN_SECOND = 1000L
        private const val SECONDS_IN_MINUTE = 60L
        private const val MINUTES_IN_HOUR = 60L

        private const val SIGNATURE_VERIFY_CONCURRENCY = 3
    }

    private val userApplications: List<ApplicationInfo>
@@ -487,7 +483,6 @@ class UpdatesManagerImpl @Inject constructor(
        )

        val fDroidUpdatablePackageNames = mutableListOf<String>()
        val semaphore = Semaphore(SIGNATURE_VERIFY_CONCURRENCY)
        val verificationTasks = fDroidAppsAndSignatures.mapNotNull { (packageName, signature) ->
            if (signature.isEmpty()) {
                Timber.tag("FAHIM").i(
@@ -498,11 +493,9 @@ class UpdatesManagerImpl @Inject constructor(
            }

            async {
                semaphore.withPermit {
                verifyFdroidSignatureCandidate(packageName, signature)
            }
        }
        }

        verificationTasks.forEach { deferred ->
            val (packageName, verified) = deferred.await()