From 68e2fe4dd73bdfc493fa5c3ddadf37f80034d0a1 Mon Sep 17 00:00:00 2001 From: David Perez Date: Thu, 19 Mar 2026 15:25:00 -0500 Subject: [PATCH] PM-33907: bug: Handle exceptions thrown when querying the AutofillManager (#6695) --- .../manager/AutofillActivityManagerImpl.kt | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillActivityManagerImpl.kt b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillActivityManagerImpl.kt index 9df8d63fda..eea50154c1 100644 --- a/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillActivityManagerImpl.kt +++ b/app/src/main/kotlin/com/x8bit/bitwarden/data/autofill/manager/AutofillActivityManagerImpl.kt @@ -8,6 +8,7 @@ import com.x8bit.bitwarden.data.autofill.manager.browser.BrowserThirdPartyAutofi import com.x8bit.bitwarden.data.autofill.model.browser.BrowserThirdPartyAutofillStatus import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach +import timber.log.Timber /** * Primary implementation of [AutofillActivityManager]. @@ -20,10 +21,34 @@ class AutofillActivityManagerImpl( lifecycleScope: LifecycleCoroutineScope, browserThirdPartyAutofillEnabledManager: BrowserThirdPartyAutofillEnabledManager, ) : AutofillActivityManager { - private val isAutofillEnabledAndSupported: Boolean - get() = autofillManager.isEnabled && - autofillManager.hasEnabledAutofillServices() && + private val autofillManagerIsEnabled: Boolean + get() = try { + autofillManager.isEnabled + } catch (@Suppress("TooGenericExceptionCaught") e: RuntimeException) { + Timber.e(e, "autofillManager.isEnabled failed") + false + } + + private val autofillManagerHasEnabledAutofillServices: Boolean + get() = try { + autofillManager.hasEnabledAutofillServices() + } catch (@Suppress("TooGenericExceptionCaught") e: RuntimeException) { + Timber.e(e, "autofillManager.hasEnabledAutofillServices() failed") + false + } + + private val autofillManagerIsAutofillSupported: Boolean + get() = try { autofillManager.isAutofillSupported + } catch (@Suppress("TooGenericExceptionCaught") e: RuntimeException) { + Timber.e(e, "autofillManager.isAutofillSupported() failed") + false + } + + private val isAutofillEnabledAndSupported: Boolean + get() = autofillManagerIsEnabled && + autofillManagerHasEnabledAutofillServices && + autofillManagerIsAutofillSupported private val browserAutofillStatus: BrowserThirdPartyAutofillStatus get() = BrowserThirdPartyAutofillStatus(