From 2e5537d9a591630013ef845a4b85e1df4cedfd43 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Wed, 10 Aug 2022 11:49:56 -0400 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/26412 - Remove try catch for NimbusFeatureException from FxNimbus value() getter --- .../components/settings/FeatureFlagPreference.kt | 14 ++------------ .../main/java/org/mozilla/fenix/utils/Settings.kt | 6 +----- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/components/settings/FeatureFlagPreference.kt b/app/src/main/java/org/mozilla/fenix/components/settings/FeatureFlagPreference.kt index 26a2925e34..c0ffb6ac36 100644 --- a/app/src/main/java/org/mozilla/fenix/components/settings/FeatureFlagPreference.kt +++ b/app/src/main/java/org/mozilla/fenix/components/settings/FeatureFlagPreference.kt @@ -4,10 +4,8 @@ package org.mozilla.fenix.components.settings -import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.ktx.android.content.PreferencesHolder import mozilla.components.support.ktx.android.content.booleanPreference -import org.mozilla.experiments.nimbus.internal.NimbusFeatureException import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -29,16 +27,8 @@ fun featureFlagPreference(key: String, default: Boolean, featureFlag: Boolean) = private class LazyPreference(val key: String, val default: () -> Boolean) : ReadWriteProperty { - override fun getValue(thisRef: PreferencesHolder, property: KProperty<*>): Boolean { - val defValue = try { - default() - } catch (e: NimbusFeatureException) { - Logger.error("Failed fetch default value for $key", e) - false - } - - return thisRef.preferences.getBoolean(key, defValue) - } + override fun getValue(thisRef: PreferencesHolder, property: KProperty<*>): Boolean = + thisRef.preferences.getBoolean(key, default()) override fun setValue(thisRef: PreferencesHolder, property: KProperty<*>, value: Boolean) = thisRef.preferences.edit().putBoolean(key, value).apply() diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 187a75f844..fe46a5b9f6 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -28,7 +28,6 @@ import mozilla.components.support.ktx.android.content.longPreference import mozilla.components.support.ktx.android.content.stringPreference import mozilla.components.support.ktx.android.content.stringSetPreference import mozilla.components.support.locale.LocaleManager -import org.mozilla.experiments.nimbus.internal.NimbusFeatureException import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.Config import org.mozilla.fenix.FeatureFlags @@ -1204,11 +1203,8 @@ class Settings(private val appContext: Context) : PreferencesHolder { private val onboardScreenSection: Map get() = FxNimbus.features.onboarding.value().sectionsEnabled - private val homescreenSections: Map get() = try { + private val homescreenSections: Map get() = FxNimbus.features.homescreen.value().sectionsEnabled - } catch (e: NimbusFeatureException) { - emptyMap() - } var historyMetadataUIFeature by lazyFeatureFlagPreference( appContext.getPreferenceKey(R.string.pref_key_history_metadata_feature),