android-components / mozilla.components.concept.sync / DeviceConstellation


interface DeviceConstellation : Observable<AccountEventsObserver> (source)

Describes available interactions with the current device and other devices associated with an OAuthAccount.


Name Summary
ensureCapabilitiesAsync abstract fun ensureCapabilitiesAsync(capabilities: Set<DeviceCapability>): Deferred<Boolean>
Ensure that all passed in capabilities are configured. This may involve backend service registration, or other work involving network/disc access.
initDeviceAsync abstract fun initDeviceAsync(name: String, type: DeviceType = DeviceType.MOBILE, capabilities: Set<DeviceCapability>): Deferred<Boolean>
Register current device in the associated DeviceConstellation.
pollForCommandsAsync abstract fun pollForCommandsAsync(): Deferred<Boolean>
Polls for any pending DeviceCommandIncoming commands. In case of new commands, registered AccountEventsObserver observers will be notified.
processRawEventAsync abstract fun processRawEventAsync(payload: String): Deferred<Boolean>
Process a raw event, obtained via a push message or some other out-of-band mechanism.
refreshDevicesAsync abstract fun refreshDevicesAsync(): Deferred<Boolean>
Refreshes ConstellationState. Registered DeviceConstellationObserver observers will be notified.
registerDeviceObserver abstract fun registerDeviceObserver(observer: DeviceConstellationObserver, owner: LifecycleOwner, autoPause: Boolean): Unit
Allows monitoring state of the device constellation via DeviceConstellationObserver. Use this to be notified of changes to the current device or other devices.
sendCommandToDeviceAsync abstract fun sendCommandToDeviceAsync(targetDeviceId: String, outgoingCommand: DeviceCommandOutgoing): Deferred<Boolean>
Send a command to a specified device.
setDeviceNameAsync abstract fun setDeviceNameAsync(name: String, context: <ERROR CLASS>): Deferred<Boolean>
Set name of the current device.
setDevicePushSubscriptionAsync abstract fun setDevicePushSubscriptionAsync(subscription: DevicePushSubscription): Deferred<Boolean>
Set a DevicePushSubscription for the current device.
state abstract fun state(): ConstellationState?
Current state of the constellation. May be missing if state was never queried.

Inherited Functions

Name Summary
isObserved abstract fun isObserved(): Boolean
If the observable has registered observers.
notifyAtLeastOneObserver abstract fun notifyAtLeastOneObserver(block: T.() -> Unit): Unit
Notifies all registered observers about a change. If there is no observer the notification is queued and sent to the first observer that is registered.
notifyObservers abstract fun notifyObservers(block: T.() -> Unit): Unit
Notifies all registered observers about a change.
pauseObserver abstract fun pauseObserver(observer: T): Unit
Pauses the provided observer. No notifications will be sent to this observer until resumeObserver is called.
register abstract fun register(observer: T): Unit
abstract fun register(observer: T, owner: LifecycleOwner, autoPause: Boolean = false): Unit
abstract fun register(observer: T, view: <ERROR CLASS>): Unit
Registers an observer to get notified about changes.
resumeObserver abstract fun resumeObserver(observer: T): Unit
Resumes the provided observer. Notifications sent since it was last paused (see pauseObserver]) are lost and will not be re-delivered.
unregister abstract fun unregister(observer: T): Unit
Unregisters an observer.
unregisterObservers abstract fun unregisterObservers(): Unit
Unregisters all observers.
wrapConsumers abstract fun <R> wrapConsumers(block: T.(R) -> Boolean): List<(R) -> Boolean>
Returns a list of lambdas wrapping a consuming method of an observer.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.


Name Summary
FxaDeviceConstellation class FxaDeviceConstellation : DeviceConstellation, Observable<AccountEventsObserver>
Provides an implementation of DeviceConstellation backed by a FirefoxAccount.