Skip to content

Commit

Permalink
Bug 1851678 - Catch AutofillApiException exception when fetching auto…
Browse files Browse the repository at this point in the history
…fill data and setting startup metrics

(cherry picked from commit 6449e3c)
  • Loading branch information
gabrielluong authored and rvandermeulen committed Sep 11, 2023
1 parent cdb4661 commit 8f29882
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import mozilla.appservices.Megazord
import mozilla.appservices.autofill.AutofillApiException
import mozilla.components.browser.state.action.SystemAction
import mozilla.components.browser.state.selector.selectedTab
import mozilla.components.browser.state.state.searchEngines
Expand Down Expand Up @@ -837,9 +838,13 @@ open class FenixApplication : LocaleAwareApplication(), Provider {

@OptIn(DelicateCoroutinesApi::class)
GlobalScope.launch(IO) {
val autoFillStorage = applicationContext.components.core.autofillStorage
Addresses.savedAll.set(autoFillStorage.getAllAddresses().size.toLong())
CreditCards.savedAll.set(autoFillStorage.getAllCreditCards().size.toLong())
try {
val autoFillStorage = applicationContext.components.core.autofillStorage
Addresses.savedAll.set(autoFillStorage.getAllAddresses().size.toLong())
CreditCards.savedAll.set(autoFillStorage.getAllCreditCards().size.toLong())
} catch (e: AutofillApiException) {
logger.error("Failed to fetch autofill data", e)
}

try {
val passwordsStorage = applicationContext.components.core.passwordsStorage
Expand Down

0 comments on commit 8f29882

Please sign in to comment.