diff --git a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
index 1a21a71ad..716e73e05 100644
--- a/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
+++ b/app/src/main/java/org/mozilla/fenix/components/BackgroundServices.kt
@@ -38,6 +38,7 @@ import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.isInExperiment
import org.mozilla.fenix.test.Mockable
+import org.mozilla.fenix.utils.Settings
/**
* Component group for background services. These are the components that need to be accessed from within a
@@ -76,7 +77,7 @@ class BackgroundServices(
}
)
// If sync has been turned off on the server then disable syncing.
- val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
+ private val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
null
} else {
SyncConfig(setOf("history", "bookmarks"), syncPeriodInMinutes = 240L) // four hours
@@ -137,6 +138,8 @@ class BackgroundServices(
pushService.stop()
push.unsubscribeForType(PushType.Services)
+
+ Settings.instance?.setFxaSignedIn(false)
}
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) {
@@ -145,6 +148,7 @@ class BackgroundServices(
if (newAccount) {
push.subscribeForType(PushType.Services)
}
+ Settings.instance?.setFxaSignedIn(true)
}
}
@@ -166,6 +170,8 @@ class BackgroundServices(
// See https://github.com/mozilla-mobile/android-components/issues/3732
setOf("https://identity.mozilla.com/apps/oldsync")
).also {
+ Settings.instance?.setFxaHasSyncedItems(syncConfig?.syncableStores?.isNotEmpty() ?: false)
+
if (FeatureFlags.sendTabEnabled) {
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt
index 1c65f8211..7b64b7a72 100644
--- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt
+++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt
@@ -66,17 +66,14 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
LeanplumActivityHelper.enableLifecycleCallbacks(application)
val installedApps = MozillaProductDetector.getInstalledMozillaProducts(application)
- val backgroundServices = application.applicationContext.components.backgroundServices
- val fxaLoggedIn = backgroundServices.accountManager.accountProfile() != null
- val syncedItems = backgroundServices.syncConfig?.syncableStores?.isNotEmpty() ?: false
Leanplum.start(application, hashMapOf(
"default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: ""),
"fennec_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FIREFOX.productName),
"focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName),
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName),
- "fxa_logged_in" to fxaLoggedIn,
- "fxa_synced_items" to syncedItems
+ "fxa_signed_in" to (Settings.instance?.fxaSignedIn ?: false),
+ "fxa_has_synced_items" to (Settings.instance?.fxaHasSyncedItems ?: false)
))
}
diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
index 9ad794d5e..4249b8bac 100644
--- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
+++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
@@ -204,6 +204,7 @@ class HomeFragment : Fragment(), AccountObserver {
val homeViewModel = activity?.run {
ViewModelProvider(this).get(HomeScreenViewModel::class.java)
}
+
homeViewModel?.layoutManagerState?.also { parcelable ->
sessionControlComponent.view.layoutManager?.onRestoreInstanceState(parcelable)
}
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 9e63f9c51..69f1191e1 100644
--- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
+++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt
@@ -235,6 +235,28 @@ class Settings private constructor(
)
}
+ fun setFxaSignedIn(isSignedIn: Boolean) {
+ preferences.edit()
+ .putBoolean(appContext.getPreferenceKey(R.string.pref_key_fxa_signed_in), isSignedIn)
+ .apply()
+ }
+
+ val fxaSignedIn: Boolean
+ get() = preferences.getBoolean(
+ appContext.getPreferenceKey(R.string.pref_key_fxa_signed_in), true
+ )
+
+ fun setFxaHasSyncedItems(hasSyncedItems: Boolean) {
+ preferences.edit()
+ .putBoolean(appContext.getPreferenceKey(R.string.pref_key_fxa_has_synced_items), hasSyncedItems)
+ .apply()
+ }
+
+ val fxaHasSyncedItems: Boolean
+ get() = preferences.getBoolean(
+ appContext.getPreferenceKey(R.string.pref_key_fxa_has_synced_items), true
+ )
+
private val SitePermissionsRules.Action.id: Int
get() {
return when (this) {
diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml
index 3fabc832d..b8b665d5b 100644
--- a/app/src/main/res/values/preference_keys.xml
+++ b/app/src/main/res/values/preference_keys.xml
@@ -47,6 +47,8 @@