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

Bug 1885288 - Add logs to FeatureSettingsHelperDelegate #6018

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
Loading