Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
Bug 1885288 - Add logs to FeatureSettingsHelperDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiAJ authored and mergify[bot] committed Mar 14, 2024
1 parent 5262783 commit 8a49590
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

package org.mozilla.fenix.helpers

import android.util.Log
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.ETPPolicy.CUSTOM
import org.mozilla.fenix.helpers.ETPPolicy.STANDARD
import org.mozilla.fenix.helpers.ETPPolicy.STRICT
Expand Down Expand Up @@ -68,11 +70,15 @@ class FeatureSettingsHelperDelegate() : FeatureSettingsHelper {
override var composeTopSitesEnabled: Boolean by updatedFeatureFlags::composeTopSitesEnabled

override fun applyFlagUpdates() {
Log.i(TAG, "applyFlagUpdates: Trying to apply the updated feature flags: $updatedFeatureFlags")
applyFeatureFlags(updatedFeatureFlags)
Log.i(TAG, "applyFlagUpdates: Applied the updated feature flags: $updatedFeatureFlags")
}

override fun resetAllFeatureFlags() {
Log.i(TAG, "resetAllFeatureFlags: Trying to reset the feature flags to: $initialFeatureFlags")
applyFeatureFlags(initialFeatureFlags)
Log.i(TAG, "resetAllFeatureFlags: Performed feature flags reset to: $initialFeatureFlags")
}

override var isDeleteSitePermissionsEnabled: Boolean by updatedFeatureFlags::isDeleteSitePermissionsEnabled
Expand Down Expand Up @@ -122,9 +128,14 @@ internal fun getETPPolicy(settings: Settings): ETPPolicy {

private fun setETPPolicy(policy: ETPPolicy) {
when (policy) {
STRICT -> settings.setStrictETP()
STRICT -> {
Log.i(TAG, "setETPPolicy: Trying to set ETP policy to: \"Strict\"")
settings.setStrictETP()
Log.i(TAG, "setETPPolicy: ETP policy was set to: \"Strict\"")
}
// The following two cases update ETP in the same way "setStrictETP" does.
STANDARD -> {
Log.i(TAG, "setETPPolicy: Trying to set ETP policy to: \"Standard\"")
settings.preferences.edit()
.putBoolean(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_strict_default),
Expand All @@ -139,8 +150,10 @@ private fun setETPPolicy(policy: ETPPolicy) {
true,
)
.commit()
Log.i(TAG, "setETPPolicy: ETP policy was set to: \"Standard\"")
}
CUSTOM -> {
Log.i(TAG, "setETPPolicy: Trying to set ETP policy to: \"Custom\"")
settings.preferences.edit()
.putBoolean(
appContext.getPreferenceKey(R.string.pref_key_tracking_protection_strict_default),
Expand All @@ -155,19 +168,23 @@ private fun setETPPolicy(policy: ETPPolicy) {
true,
)
.commit()
Log.i(TAG, "setETPPolicy: ETP policy was set to: \"Custom\"")
}
}
}

private fun getHomeOnboardingVersion(): Int {
Log.i(TAG, "getHomeOnboardingVersion: Trying to get the onboarding version")
return FenixOnboarding(appContext)
.preferences
.getInt(FenixOnboarding.LAST_VERSION_ONBOARDING_KEY, 0)
}

private fun setHomeOnboardingVersion(version: Int) {
Log.i(TAG, "setHomeOnboardingVersion: Trying to set the onboarding version to: $version")
FenixOnboarding(appContext)
.preferences.edit()
.putInt(FenixOnboarding.LAST_VERSION_ONBOARDING_KEY, version)
.commit()
Log.i(TAG, "setHomeOnboardingVersion: Onboarding version was set to: $version")
}

0 comments on commit 8a49590

Please sign in to comment.