Fix breaking services APIs changes

nightly-build-test
Grisha Kruglov 5 years ago committed by Sebastian Kaspari
parent 2c7fd93c7d
commit 231924f5eb

@ -16,6 +16,7 @@ import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
import mozilla.components.browser.storage.sync.PlacesHistoryStorage import mozilla.components.browser.storage.sync.PlacesHistoryStorage
import mozilla.components.concept.push.Bus import mozilla.components.concept.push.Bus
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.DeviceCapability import mozilla.components.concept.sync.DeviceCapability
import mozilla.components.concept.sync.DeviceEvent import mozilla.components.concept.sync.DeviceEvent
import mozilla.components.concept.sync.DeviceEventsObserver import mozilla.components.concept.sync.DeviceEventsObserver
@ -30,6 +31,7 @@ import mozilla.components.feature.push.PushType
import mozilla.components.service.fxa.DeviceConfig import mozilla.components.service.fxa.DeviceConfig
import mozilla.components.service.fxa.ServerConfig import mozilla.components.service.fxa.ServerConfig
import mozilla.components.service.fxa.SyncConfig import mozilla.components.service.fxa.SyncConfig
import mozilla.components.service.fxa.SyncEngine
import mozilla.components.service.fxa.manager.FxaAccountManager import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.service.fxa.sync.GlobalSyncableStoreProvider import mozilla.components.service.fxa.sync.GlobalSyncableStoreProvider
import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.logger.Logger
@ -77,7 +79,7 @@ class BackgroundServices(
private val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) { private val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
null null
} else { } else {
SyncConfig(setOf("history", "bookmarks"), syncPeriodInMinutes = 240L) // four hours SyncConfig(setOf(SyncEngine.HISTORY, SyncEngine.BOOKMARKS), syncPeriodInMinutes = 240L) // four hours
} }
val pushConfig by lazy { val pushConfig by lazy {
@ -102,8 +104,8 @@ class BackgroundServices(
init { init {
// Make the "history" and "bookmark" stores accessible to workers spawned by the sync manager. // Make the "history" and "bookmark" stores accessible to workers spawned by the sync manager.
GlobalSyncableStoreProvider.configureStore("history" to historyStorage) GlobalSyncableStoreProvider.configureStore(SyncEngine.HISTORY to historyStorage)
GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage) GlobalSyncableStoreProvider.configureStore(SyncEngine.BOOKMARKS to bookmarkStorage)
} }
private val deviceEventObserver = object : DeviceEventsObserver { private val deviceEventObserver = object : DeviceEventsObserver {
@ -139,8 +141,8 @@ class BackgroundServices(
Settings.getInstance(context).fxaSignedIn = false Settings.getInstance(context).fxaSignedIn = false
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (newAccount) { if (authType != AuthType.Existing) {
push.subscribeForType(PushType.Services) push.subscribeForType(PushType.Services)
} }
@ -168,7 +170,7 @@ class BackgroundServices(
// See https://github.com/mozilla-mobile/android-components/issues/3732 // See https://github.com/mozilla-mobile/android-components/issues/3732
setOf("https://identity.mozilla.com/apps/oldsync") setOf("https://identity.mozilla.com/apps/oldsync")
).also { ).also {
Settings.getInstance(context).fxaHasSyncedItems = syncConfig?.syncableStores?.isNotEmpty() ?: false Settings.getInstance(context).fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false) it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)

@ -5,6 +5,7 @@
package org.mozilla.fenix.customtabs package org.mozilla.fenix.customtabs
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
@ -17,7 +18,7 @@ class AuthCustomTabActivity : CustomTabActivity() {
/** /**
* Navigate away from this activity when we have successful authentication * Navigate away from this activity when we have successful authentication
*/ */
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
finish() finish()
} }
} }

@ -41,6 +41,7 @@ import mozilla.components.browser.menu.BrowserMenu
import mozilla.components.browser.session.Session import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile import mozilla.components.concept.sync.Profile
import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.feature.tab.collections.TabCollection
@ -761,8 +762,8 @@ class HomeFragment : Fragment(), AccountObserver {
} }
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
if (newAccount) { if (authType != AuthType.Existing) {
view?.let { view?.let {
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT).setText( FenixSnackbar.make(it, Snackbar.LENGTH_SHORT).setText(
it.context.getString(R.string.onboarding_firefox_account_sync_is_on) it.context.getString(R.string.onboarding_firefox_account_sync_is_on)

@ -34,6 +34,7 @@ import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.BackHandler
@ -242,7 +243,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), BackHandler, Accou
return bookmarkView.onBackPressed() return bookmarkView.onBackPressed()
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
bookmarkInteractor.onSignedIn() bookmarkInteractor.onSignedIn()
lifecycleScope.launch { lifecycleScope.launch {
refreshBookmarks() refreshBookmarks()

@ -29,6 +29,7 @@ import kotlinx.coroutines.withContext
import mozilla.appservices.places.BookmarkRoot import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getColorFromAttr import org.mozilla.fenix.ext.getColorFromAttr
@ -127,7 +128,7 @@ class SelectBookmarkFolderFragment : Fragment(), AccountObserver {
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
bookmarkInteractor.onSignedIn() bookmarkInteractor.onSignedIn()
} }

@ -12,6 +12,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
@ -66,7 +67,7 @@ class AccountProblemFragment : PreferenceFragmentCompat(), AccountObserver {
} }
// We're told our auth problems have been fixed; close this fragment. // We're told our auth problems have been fixed; close this fragment.
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) = closeFragment() override fun onAuthenticated(account: OAuthAccount, authType: AuthType) = closeFragment()
// We're told there are no more auth problems since there is no more account; close this fragment. // We're told there are no more auth problems since there is no more account; close this fragment.
override fun onLoggedOut() = closeFragment() override fun onLoggedOut() = closeFragment()

@ -24,6 +24,7 @@ import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile import mozilla.components.concept.sync.Profile
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
@ -326,7 +327,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
Navigation.findNavController(view!!).navigate(directions) Navigation.findNavController(view!!).navigate(directions)
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
lifecycleScope.launch { lifecycleScope.launch {
context?.let { context?.let {
updateAccountUIState(it, it.components.backgroundServices.accountManager.accountProfile()) updateAccountUIState(it, it.components.backgroundServices.accountManager.accountProfile())

@ -15,6 +15,7 @@ import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import kotlinx.android.synthetic.main.fragment_turn_on_sync.view.* import kotlinx.android.synthetic.main.fragment_turn_on_sync.view.*
import mozilla.components.concept.sync.AccountObserver import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar import org.mozilla.fenix.components.FenixSnackbar
@ -72,7 +73,7 @@ class TurnOnSyncFragment : Fragment(), AccountObserver {
return view return view
} }
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) { override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
FenixSnackbar.make(view!!, FenixSnackbar.LENGTH_SHORT) FenixSnackbar.make(view!!, FenixSnackbar.LENGTH_SHORT)
.setText(requireContext().getString(R.string.sync_syncing_in_progress)) .setText(requireContext().getString(R.string.sync_syncing_in_progress))
.show() .show()

Loading…
Cancel
Save