android-components / mozilla.components.service.fxa.manager / FxaAccountManager

FxaAccountManager

open class FxaAccountManager : Closeable, Observable<AccountObserver> (source)

An account manager which encapsulates various internal details of an account lifecycle and provides an observer interface along with a public API for interacting with an account. The internal state machine abstracts over state space as exposed by the fxaclient library, not the internal states experienced by lower-level representation of a Firefox Account; those are opaque to us.

Class is ‘open’ to facilitate testing.

Parameters

context - A Context instance that’s used for internal messaging and interacting with local storage.

serverConfig - A ServerConfig used for account initialization.

deviceConfig - A description of the current device (name, type, capabilities).

syncConfig - Optional, initial sync behaviour configuration. Sync will be disabled if this is null.

applicationScopes - A set of scopes which will be requested during account authentication.

Constructors

Name Summary
<init> FxaAccountManager(context: <ERROR CLASS>, serverConfig: ServerConfig, deviceConfig: DeviceConfig, syncConfig: SyncConfig?, applicationScopes: Set<String> = emptySet(), coroutineContext: CoroutineContext` = Executors
.newSingleThreadExecutor().asCoroutineDispatcher() + SupervisorJob())`
An account manager which encapsulates various internal details of an account lifecycle and provides an observer interface along with a public API for interacting with an account. The internal state machine abstracts over state space as exposed by the fxaclient library, not the internal states experienced by lower-level representation of a Firefox Account; those are opaque to us.
 

Functions

Name Summary
accountNeedsReauth fun accountNeedsReauth(): Boolean
Indicates if account needs to be re-authenticated via beginAuthenticationAsync. Most common reason for an account to need re-authentication is a password change.
accountProfile fun accountProfile(): Profile?
authenticatedAccount fun authenticatedAccount(): OAuthAccount?
Main point for interaction with an OAuthAccount instance.
beginAuthenticationAsync fun beginAuthenticationAsync(pairingUrl: String? = null): Deferred<String?>
close open fun close(): Unit
createAccount open fun createAccount(config: ServerConfig): OAuthAccount
createSyncManager open fun createSyncManager(config: SyncConfig): SyncManager
finishAuthenticationAsync fun finishAuthenticationAsync(authData: FxaAuthData): Deferred<Boolean>
Finalize authentication that was started via beginAuthenticationAsync.
getAccountStorage open fun getAccountStorage(): AccountStorage
initAsync fun initAsync(): Deferred<Unit>
Call this after registering your observers, and before interacting with this class.
isSyncActive fun isSyncActive(): Boolean
Indicates if sync is currently running.
logoutAsync fun logoutAsync(): Deferred<Unit>
registerForDeviceEvents fun registerForDeviceEvents(observer: DeviceEventsObserver, owner: LifecycleOwner, autoPause: Boolean): Unit
registerForSyncEvents fun registerForSyncEvents(observer: SyncStatusObserver, owner: LifecycleOwner, autoPause: Boolean): Unit
setSyncConfigAsync fun setSyncConfigAsync(config: SyncConfig): Deferred<Unit>
Allows setting a new SyncConfig, changing sync behaviour.
shareableAccounts fun shareableAccounts(context: <ERROR CLASS>): List<ShareableAccount>
Queries trusted FxA Auth providers available on the device, returning a list of ShareableAccount in an order of preference. Any of the returned ShareableAccount may be used with signInWithShareableAccountAsync to sign-in into an FxA account without any required user input.
signInWithShareableAccountAsync fun signInWithShareableAccountAsync(fromAccount: ShareableAccount): Deferred<Boolean>
Uses a provided fromAccount to sign-in into a corresponding FxA account without any required user input. Once sign-in completes, any registered AccountObserver.onAuthenticated listeners will be notified and authenticatedAccount will refer to the new account. This may fail in case of network errors, or if provided credentials are not valid.
supportedSyncEngines fun supportedSyncEngines(): Set<SyncEngine>?
syncNowAsync fun syncNowAsync(reason: SyncReason, debounce: Boolean = false): Deferred<Unit>
Request an immediate synchronization, as configured according to syncConfig.
updateProfileAsync fun updateProfileAsync(): Deferred<Unit>