ComponentUpdateHandler

Base class for handling updates for one or more updatable components, configured by config.

One or more handlers can be provided to a HandlerBasedUpdaterService instance.

See SingleComponentUpdateHandler to implement a ComponentUpdateHandler that only handles a single updatable component. For updating APKs, use SimpleApkUpdateHandler if it fulfills the requirements. Otherwise, consider to use ApkComponentUpdateHandler as a base class.

Handler implementations can optionally use scheduleDetectUpdate to periodically call detectUpdate.

Inheritors

Constructors

Link copied to clipboard
constructor(config: ComponentUpdateHandler.Config)

Types

Link copied to clipboard
data class Config(val defaultUpdatePolicy: UpdatePolicy)

The config of an ComponentUpdateHandler.

Properties

Link copied to clipboard

Unique identifier of this handler. This ID must be stable across restarts.

Link copied to clipboard
open val isReady: Flow<Boolean>

Indicates if the component update handler is ready. While the component update handler is not ready, the checkForUpdates, startDownload, startInstallation, detectUpdate and onReceiveBroadcast are not invoked or delayed.

Link copied to clipboard

Collection of UpdateComponentInfo. A new value is emitted each time any value of any entry changes.

Functions

Link copied to clipboard
open suspend fun checkForUpdates()

Allows the user to check for new updates.

Link copied to clipboard
open suspend fun detectUpdate()

Invoked by DetectUpdateTriggerWorker and by the default implementation of checkForUpdates to allow the handler to detect if a new update is available.

Link copied to clipboard
@VisibleForTesting(otherwise = 3)
suspend fun init(handlerContext: ComponentUpdateHandlerContext)

Initializes the handler with the given handlerContext and calls initInner.

Link copied to clipboard
open fun onReceiveBroadcast(intent: Intent)

Invoked when UpdaterServiceBroadcastReceiver receives an intent.

Link copied to clipboard
abstract fun removeFinishedUpdate(updateId: UpdateId)

Removes a finished update identified by updateId.

Link copied to clipboard
abstract fun startDownload(updateId: UpdateId)

Starts the download of an update identified by updateId.

Link copied to clipboard
abstract fun startInstallation(updateId: UpdateId)

Starts the installation of an update identified by updateId.

Inherited functions

Link copied to clipboard

Schedules the invocation of ComponentUpdateHandler.detectUpdate periodically based on the detectUpdateTriggerWorkConfig with the handlerContext of this ComponentUpdateHandler.