From a275c51d21d92fb654b38ec7e3c9405995b9577d Mon Sep 17 00:00:00 2001 From: RoboMagus <68224306+RoboMagus@users.noreply.github.com> Date: Mon, 4 Sep 2023 12:06:51 +0200 Subject: [PATCH] Mitigate duplicate biometric prompts caused by unexpected WindowFocusChanged events. --- .../companion/android/webview/WebViewActivity.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt index e6843432453..3ea6ac6a671 100644 --- a/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt +++ b/app/src/main/java/io/homeassistant/companion/android/webview/WebViewActivity.kt @@ -207,6 +207,7 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi private var firstAuthTime: Long = 0 private var resourceURL: String = "" private var appLocked = true + private var unlockingApp = false private var exoPlayer: ExoPlayer? = null private var isExoFullScreen = false private var exoTop = 0 // These margins are from the DOM and scaled to screen @@ -1025,6 +1026,7 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi } else -> Log.d(TAG, "Authentication failed, retry attempts allowed") } + unlockingApp = false } override fun onWindowFocusChanged(hasFocus: Boolean) { @@ -1053,7 +1055,10 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi appLocked = presenter.isAppLocked() if (appLocked) { binding.blurView.setBlurEnabled(true) - authenticator.authenticate(getString(commonR.string.biometric_title)) + if (!unlockingApp) { + authenticator.authenticate(getString(commonR.string.biometric_title)) + } + unlockingApp = true } else { binding.blurView.setBlurEnabled(false) }