|
|
@ -8,7 +8,6 @@ import android.content.Context
|
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
import mozilla.components.browser.storage.sync.PlacesBookmarksStorage
|
|
|
|
|
|
|
|
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
|
|
|
import mozilla.components.browser.storage.sync.PlacesHistoryStorage
|
|
|
|
import mozilla.components.feature.sync.BackgroundSyncManager
|
|
|
|
import mozilla.components.feature.sync.BackgroundSyncManager
|
|
|
|
import mozilla.components.feature.sync.GlobalSyncableStoreProvider
|
|
|
|
import mozilla.components.feature.sync.GlobalSyncableStoreProvider
|
|
|
@ -21,8 +20,7 @@ import mozilla.components.service.fxa.FxaAccountManager
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class BackgroundServices(
|
|
|
|
class BackgroundServices(
|
|
|
|
context: Context,
|
|
|
|
context: Context,
|
|
|
|
historyStorage: PlacesHistoryStorage,
|
|
|
|
historyStorage: PlacesHistoryStorage
|
|
|
|
bookmarkStorage: PlacesBookmarksStorage
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
companion object {
|
|
|
|
companion object {
|
|
|
|
const val CLIENT_ID = "a2270f727f45f648"
|
|
|
|
const val CLIENT_ID = "a2270f727f45f648"
|
|
|
@ -37,14 +35,12 @@ class BackgroundServices(
|
|
|
|
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
|
|
|
private val config = Config.release(CLIENT_ID, REDIRECT_URL)
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
// Make the "history" and "bookmark" stores accessible to workers spawned by the sync manager.
|
|
|
|
// Make the "history" store accessible to workers spawned by the sync manager.
|
|
|
|
GlobalSyncableStoreProvider.configureStore("history" to historyStorage)
|
|
|
|
GlobalSyncableStoreProvider.configureStore("history" to historyStorage)
|
|
|
|
GlobalSyncableStoreProvider.configureStore("bookmarks" to bookmarkStorage)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
|
|
|
|
val syncManager = BackgroundSyncManager("https://identity.mozilla.com/apps/oldsync").also {
|
|
|
|
it.addStore("history")
|
|
|
|
it.addStore("history")
|
|
|
|
it.addStore("bookmarks")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val accountManager = FxaAccountManager(context, config, scopes, syncManager).also {
|
|
|
|
val accountManager = FxaAccountManager(context, config, scopes, syncManager).also {
|
|
|
|