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

DeviceConstellation

interface DeviceConstellation : Observable<DeviceEventsObserver> (source)

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

Functions

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.
pollForEventsAsync abstract fun pollForEventsAsync(): Deferred<Boolean>
Polls for any pending DeviceEvent events. In case of new events, registered DeviceEventsObserver 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.
sendEventToDeviceAsync abstract fun sendEventToDeviceAsync(targetDeviceId: String, outgoingEvent: DeviceEventOutgoing): Deferred<Boolean>
Send an event 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.

Inheritors

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