1
0
Fork 0

Add application-services fretboard feature flags

master
vladikoff 2019-05-29 18:33:38 -04:00 committed by Emily Kager
parent ce33054173
commit dfe181aa0a
6 changed files with 36 additions and 13 deletions

View File

@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #2903 - Fixed crash when trying to rate the app on a devices without the play store app.
- #2419 - Adds a deletion state to the history component
- #1570 - Enables the opening of links by other apps. Disabled in #3359.
- #3200 - Adds application-services fretboard feature flags for FxA and Sync.
### Changed
- #2673 - Fixed can't upload files using third party apps from the file manager.

View File

@ -10,11 +10,15 @@ import mozilla.components.service.fretboard.ExperimentDescriptor
const val EXPERIMENTS_JSON_FILENAME = "experiments.json"
const val EXPERIMENTS_BASE_URL = "https://settings.prod.mozaws.net/v1"
const val EXPERIMENTS_BUCKET_NAME = "main"
// TODO Change this after fenix-experiments is created
const val EXPERIMENTS_COLLECTION_NAME = "focus-experiments"
// collection name below, see https://bugzilla.mozilla.org/show_bug.cgi?id=1523395 for ownership details
const val EXPERIMENTS_COLLECTION_NAME = "fenix-experiments"
object Experiments {
val AATestDescriptor = ExperimentDescriptor("AAtest")
// application services flag to disable the Firefox Sync syncManager
val asFeatureSyncDisabled = ExperimentDescriptor("asFeatureSyncDisabled")
// application services flag to disable Firefox Accounts pairing button.
val asFeatureFxAPairingDisabled = ExperimentDescriptor("asFeatureFxAPairingDisabled")
}
val Context.app: FenixApplication

View File

@ -115,7 +115,7 @@ open class HomeActivity : AppCompatActivity() {
components.backgroundServices.accountManager.initAsync().await()
// If we're authenticated, kick-off a sync and a device state refresh.
components.backgroundServices.accountManager.authenticatedAccount()?.let {
components.backgroundServices.syncManager.syncNow(startup = true)
components.backgroundServices.syncManager?.syncNow(startup = true)
it.deviceConstellation().refreshDeviceStateAsync().await()
}
}

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix.components
import android.content.Context
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.work.WorkManager
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -21,7 +22,9 @@ import mozilla.components.service.fxa.Config
import mozilla.components.service.fxa.manager.DeviceTuple
import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.Experiments
import org.mozilla.fenix.R
import org.mozilla.fenix.isInExperiment
import org.mozilla.fenix.test.Mockable
/**
@ -53,9 +56,15 @@ class BackgroundServices(
GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage)
}
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
it.addStore("history")
it.addStore("bookmarks")
// if sync has been turned off on the server then make `syncManager` null
val syncManager = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
WorkManager.getInstance().cancelUniqueWork("Periodic")
null
} else {
BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
it.addStore("history")
it.addStore("bookmarks")
}
}
private val deviceEventObserver = object : DeviceEventsObserver {

View File

@ -108,11 +108,13 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
// Current sync state
updateLastSyncedTimePref(context!!, preferenceSyncNow)
if (requireComponents.backgroundServices.syncManager.isSyncRunning()) {
preferenceSyncNow.title = getString(R.string.sync_syncing_in_progress)
preferenceSyncNow.isEnabled = false
} else {
preferenceSyncNow.isEnabled = true
requireComponents.backgroundServices.syncManager?.let {
if (it.isSyncRunning()) {
preferenceSyncNow.title = getString(R.string.sync_syncing_in_progress)
preferenceSyncNow.isEnabled = false
} else {
preferenceSyncNow.isEnabled = true
}
}
}
@ -133,7 +135,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
// NB: ObserverRegistry will take care of cleaning up internal references to 'observer' and
// 'owner' when appropriate.
requireComponents.backgroundServices.syncManager.register(syncStatusObserver, owner = this, autoPause = true)
requireComponents.backgroundServices.syncManager?.register(syncStatusObserver, owner = this, autoPause = true)
}
private fun getClickListenerForSignOut(): Preference.OnPreferenceClickListener {
@ -150,7 +152,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat(), CoroutineScope {
return Preference.OnPreferenceClickListener {
// Trigger a sync.
requireComponents.analytics.metrics.track(Event.SyncAccountSyncNow)
requireComponents.backgroundServices.syncManager.syncNow()
requireComponents.backgroundServices.syncManager?.syncNow()
// Poll for device events.
launch {
accountManager.authenticatedAccount()

View File

@ -14,11 +14,13 @@ import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile
import mozilla.components.support.ktx.android.content.hasCamera
import org.mozilla.fenix.Experiments
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.isInExperiment
@SuppressWarnings("TooManyFunctions")
class TurnOnSyncFragment : PreferenceFragmentCompat(), AccountObserver {
@ -57,6 +59,11 @@ class TurnOnSyncFragment : PreferenceFragmentCompat(), AccountObserver {
preferenceNewAccount?.onPreferenceClickListener = getClickListenerForCreateAccount()
preferencePairSignIn?.onPreferenceClickListener = getClickListenerForPairing()
preferencePairSignIn?.isVisible = context?.hasCamera() ?: true
// if FxA pairing has been turned off on the server
if (context?.isInExperiment(Experiments.asFeatureFxAPairingDisabled)!!) {
preferencePairSignIn?.isVisible = false
}
}
private fun getClickListenerForSignIn(): Preference.OnPreferenceClickListener {