class UpdateInfoManager


Manages the persistent storage of security update information.

This class acts as the local database for the UpdateInfoService. It is responsible for:

  1. Storing the list of available UpdateInfo objects (persisted in SharedPreferences).

  2. Storing metadata about the update checks (e.g., getLastCheckTimeMillis).

  3. Cleaning up outdated updates by comparing them against the device's current state.

Typical usage involves an update client (like GOTA (Google Over-The-Air) or Play Store) registering new updates via registerUpdate when they are discovered, and the UpdateInfoService querying getAllUpdates to return them to consumers.

Summary

Public constructors

UpdateInfoManager(
    context: Context,
    customSecurityState: SecurityPatchState?
)

Public functions

Long

Retrieves the timestamp of the last successful update check.

Unit

Registers information about an available update for the specified component.

Unit
setLastCheckTimeMillis(timestampMillis: Long)

Updates the timestamp of the last successful update check.

Unit

Unregisters information about an available update for the specified component.

Public constructors

UpdateInfoManager

Added in 1.0.0-alpha03
UpdateInfoManager(
    context: Context,
    customSecurityState: SecurityPatchState? = null
)

Public functions

getLastCheckTimeMillis

Added in 1.0.0-alpha03
fun getLastCheckTimeMillis(): Long

Retrieves the timestamp of the last successful update check.

This metadata is stored separately from the update list. The value represents "Wall Clock Time" to ensure it remains meaningful across device reboots.

Returns
Long

The time of the last check in milliseconds since the epoch (System.currentTimeMillis), or 0 if no check has ever occurred.

registerUpdate

Added in 1.0.0-alpha03
fun registerUpdate(updateInfo: UpdateInfo): Unit

Registers information about an available update for the specified component.

Parameters
updateInfo: UpdateInfo

Update information structure.

setLastCheckTimeMillis

Added in 1.0.0-alpha03
fun setLastCheckTimeMillis(timestampMillis: Long): Unit

Updates the timestamp of the last successful update check.

Usage Note for Hosts: The UpdateInfoService base class automatically calls this method after a successful network fetch triggered by a client request. Host applications should only call this method manually if they are performing out-of-band synchronizations (e.g., via a background JobService or WorkManager).

Parameters
timestampMillis: Long

The current time in milliseconds (System.currentTimeMillis).

unregisterUpdate

Added in 1.0.0-alpha03
fun unregisterUpdate(updateInfo: UpdateInfo): Unit

Unregisters information about an available update for the specified component.

Parameters
updateInfo: UpdateInfo

Update information structure.