Extend SyncManager APIs with the ability to connect and disconnect sync
Categories
(Firefox for Android :: Accounts and Sync, task)
Tracking
()
People
(Reporter: segun, Assigned: segun)
References
Details
(Whiteboard: [fxdroid] [android-activation-trust])
Attachments
(5 files)
As part of the technical decoupling of accounts & sync (bug 2060556), we need to extend the SyncManager 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()andisConnected` behaviours and states. The goal is to have something that looks like this:
// 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:
- Call rust's syncmanager
disconnect()API so that they can drop the internal states they maintain - Clear the local "is sync enabled" state introduced in Bug 2065174
- Clear the "sync state" blob that we persist. See WorkManagerSyncWorker.doSync() to see where we set it
- 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.
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 1•1 month ago
|
||
This commit makes two changes
-
Adds reset() - to handle updating the state to what would indicate that sync values have been reset. This includes resetting the last synced time, "is sync connected", and "persisted sync state"
Reset is different from clear because clear removes the entries from the storage. Reset merely sets them back to a default state. -
SyncStateStorage.syncEnabled becomes SyncStateStorage.syncConnected, is now nullable, and has an observable variant.
nullindicates that the value has never been set.
It also adds astoreSyncConnectedfor setting that value.
"Connected" rather than "enabled" because this preference records whether sync was connected on this device through an explicit action, which kinda sounds better with the planned connect() / disconnect() APIs on SyncManager.
The resolution of SyncStateStorage.syncConnected to true/false falls outside the storage layer, and this only tells us if any value has been set or not.
| Assignee | ||
Comment 2•1 month ago
|
||
| Assignee | ||
Comment 3•1 month ago
|
||
The syncConnectionState infers the state of "sync" based on a combination of sync decoupling is enabled, whether the user has explicitly turned off sync, or whether the account is not authenticated, connected or missing the sync scope.
| Assignee | ||
Comment 4•1 month ago
|
||
This API connects & configures sync when a connected and authorised (with sync scope) account exists.
It also offers the possibility of starting sync immediately.
| Assignee | ||
Comment 5•1 month ago
|
||
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
| Assignee | ||
Updated•1 month ago
|
Comment 7•1 month ago
|
||
| bugherder | ||
Updated•1 month ago
|
Updated•1 month ago
|
Comment 9•27 days ago
|
||
| bugherder | ||
| Assignee | ||
Updated•26 days ago
|
Description
•