Skip to content

Commit

Permalink
Long timeout for applications list. Just as a precaution
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-Makarov committed Oct 6, 2023
1 parent 900efb0 commit b3e9bde
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.media.MediaDrm
import android.os.Build
import com.fingerprintjs.android.fingerprint.BuildConfig
import com.fingerprintjs.android.fingerprint.tools.DeprecationMessages
import com.fingerprintjs.android.fingerprint.tools.threading.safe.Safe
import com.fingerprintjs.android.fingerprint.tools.threading.safe.safeWithTimeout
import java.security.MessageDigest
import java.util.UUID
Expand Down Expand Up @@ -48,4 +49,4 @@ private const val WIDEWINE_UUID_MOST_SIG_BITS = -0x121074568629b532L
private const val WIDEWINE_UUID_LEAST_SIG_BITS = -0x5c37d8232ae2de13L
// on CI, the timeout of 1s is not enough for emulator with api 32 and google apis.
// therefore, let's make it much higher for CI tests and a bit higher for all builds (just in case)
private val MEDIA_DRM_ID_TIMEOUT_MS = if (BuildConfig.CI_TEST) 600_000L else 3000L
private val MEDIA_DRM_ID_TIMEOUT_MS = if (BuildConfig.CI_TEST) 600_000L else Safe.timeoutLong
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.fingerprintjs.android.fingerprint.info_providers
import android.annotation.SuppressLint
import android.content.pm.PackageManager
import com.fingerprintjs.android.fingerprint.tools.DeprecationMessages
import com.fingerprintjs.android.fingerprint.tools.threading.safe.Safe
import com.fingerprintjs.android.fingerprint.tools.threading.safe.safeWithTimeout


Expand All @@ -25,7 +26,7 @@ internal class PackageManagerDataSourceImpl(
private val packageManager: PackageManager?,
) : PackageManagerDataSource {
@SuppressLint("QueryPermissionsNeeded")
override fun getApplicationsList() = safeWithTimeout {
override fun getApplicationsList() = safeWithTimeout(timeoutMs = Safe.timeoutLong) {
packageManager!!
.getInstalledApplications(PackageManager.GET_META_DATA)
.map {
Expand All @@ -37,7 +38,7 @@ internal class PackageManagerDataSourceImpl(


@SuppressLint("QueryPermissionsNeeded")
override fun getSystemApplicationsList() = safeWithTimeout {
override fun getSystemApplicationsList() = safeWithTimeout(timeoutMs = Safe.timeoutLong) {
packageManager!!
.getInstalledApplications(PackageManager.GET_META_DATA)
.filter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.util.concurrent.atomic.AtomicReference

internal object Safe {
const val timeoutShort = 1_000L
const val timeoutLong = 3_000L

private val runningInsideSafeWithTimeout = ThreadLocal<Boolean>()

Expand Down

0 comments on commit b3e9bde

Please sign in to comment.