As part of the technical decoupling of accounts & sync ([bug 2060556](https://bugzilla.mozilla.org/show_bug.cgi?id=2060556)), we need to extend the [SyncManager](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/SyncManager.kt#121-227) APIs & FxaAccountManager APIs to connect and disconnect sync. Android currently has an internal `SyncManager` API that is used via the FxaAccountManager - and we need to extend both of them to support `connect(), `disconnect()` and `isConnected` behaviours and states. The goal is to have something that looks like this: ```kotlin // android components internal abstract class SyncManager { val isConnected: StateFlow<Boolean> fun connect() fun disconnect() } ``` The details of what each step should do might undergo revisions as we go on, but here are some known expected behaviours. At the time of implementation, we may decide to file separate bugs for those behaviours/actions if the code changes are too large. ### Disconnect To disconnect sync, we need to do the following: 1. Call rust's syncmanager `disconnect()` API so that they can drop the internal states they maintain 2. Clear the local "is sync enabled" state introduced in Bug 2065174 3. Clear the "sync state" blob that we persist. See [WorkManagerSyncWorker.doSync()](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt#487-489) to see where we set it ### Connect Connecting to sync is quite involved, so please double check with the folks in #fxa-mobile-integrations to check that it does what it should. A pseudocode of this flow is as follows: ``` function connect: if user is not authenticated: state = "disconnected" return if user does not have sync scope: start auth flow for sync return state = "connected" initiate first sync. schedule periodic sync. ```
Bug 2065181 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
As part of the technical decoupling of accounts & sync ([bug 2060556](https://bugzilla.mozilla.org/show_bug.cgi?id=2060556)), we need to extend the [SyncManager](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/SyncManager.kt#121-227) APIs & FxaAccountManager APIs to connect and disconnect sync. Android currently has an internal `SyncManager` API that is used via the FxaAccountManager - and we need to extend both of them to support `connect(), `disconnect()` and `isConnected` behaviours and states. The goal is to have something that looks like this: ```kotlin // android components internal abstract class SyncManager { val isConnected: StateFlow<Boolean> fun connect() fun disconnect() } ``` The details of what each step should do might undergo revisions as we go on, but here are some known expected behaviours. At the time of implementation, we may decide to file separate bugs for those behaviours/actions if the code changes are too large. ### Disconnect To disconnect sync, we need to do the following: 1. Call rust's syncmanager `disconnect()` API so that they can drop the internal states they maintain 2. Clear the local "is sync enabled" state introduced in Bug 2065174 3. Clear the "sync state" blob that we persist. See [WorkManagerSyncWorker.doSync()](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt#487-489) to see where we set it 4. Cancel scheduled work manager sync jobs ### Connect Connecting to sync is quite involved, so please double check with the folks in #fxa-mobile-integrations to check that it does what it should. A pseudocode of this flow is as follows: ``` function connect: if user is not authenticated: state = "disconnected" return if user does not have sync scope: start auth flow for sync return state = "connected" initiate first sync. schedule periodic sync. ```
As part of the technical decoupling of accounts & sync ([bug 2060556](https://bugzilla.mozilla.org/show_bug.cgi?id=2060556)), we need to extend the [SyncManager](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/SyncManager.kt#121-227) APIs & FxaAccountManager APIs to connect and disconnect sync. Android currently has an internal `SyncManager` API that is used via the FxaAccountManager - and we need to extend both of them to support `connect(), `disconnect()` and `isConnected` behaviours and states. The goal is to have something that looks like this: ```kotlin // android components internal abstract class SyncManager { val isConnected: StateFlow<Boolean> abstract fun connect() abstract fun disconnect() } ``` The details of what each step should do might undergo revisions as we go on, but here are some known expected behaviours. At the time of implementation, we may decide to file separate bugs for those behaviours/actions if the code changes are too large. ### Disconnect To disconnect sync, we need to do the following: 1. Call rust's syncmanager `disconnect()` API so that they can drop the internal states they maintain 2. Clear the local "is sync enabled" state introduced in Bug 2065174 3. Clear the "sync state" blob that we persist. See [WorkManagerSyncWorker.doSync()](https://searchfox.org/firefox-main/rev/ad5db99e4d2e00e9b5db2700c69050d709c7f340/mobile/android/android-components/components/service/firefox-accounts/src/main/java/mozilla/components/service/fxa/sync/WorkManagerSyncManager.kt#487-489) to see where we set it 4. Cancel scheduled work manager sync jobs ### Connect Connecting to sync is quite involved, so please double check with the folks in #fxa-mobile-integrations to check that it does what it should. A pseudocode of this flow is as follows: ``` function connect: if user is not authenticated: state = "disconnected" return if user does not have sync scope: start auth flow for sync return state = "connected" initiate first sync. schedule periodic sync. ```