# UpdateInfoManager

Artifact: [androidx.security:security-state-provider](https://developer.android.com/jetpack/androidx/releases/security) [View Source](https://cs.android.com/search?q=file:androidx/security/state/provider/UpdateInfoManager.kt+class:androidx.security.state.provider.UpdateInfoManager) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

*** ** * ** ***


```
class UpdateInfoManager
```

<br />

*** ** * ** ***

Manages the persistent storage of security update information.

This class acts as the local database for the `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoService`. It is responsible for:

1. Storing the list of available `https://developer.android.com/reference/kotlin/androidx/security/state/UpdateInfo` objects (persisted in SharedPreferences).

2. Storing metadata about the update checks (e.g., `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#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 `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#registerUpdate(androidx.security.state.UpdateInfo)` when they are discovered, and the `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoService` querying `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#getAllUpdates()` to return them to consumers.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#UpdateInfoManager(android.content.Context,androidx.security.state.SecurityPatchState)( context: https://developer.android.com/reference/android/content/Context.html, customSecurityState: https://developer.android.com/reference/kotlin/androidx/security/state/SecurityPatchState? )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#getLastCheckTimeMillis()()` Retrieves the timestamp of the last successful update check. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#registerUpdate(androidx.security.state.UpdateInfo)(updateInfo: https://developer.android.com/reference/kotlin/androidx/security/state/UpdateInfo)` Registers information about an available update for the specified component. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#setLastCheckTimeMillis(kotlin.Long)(timestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Updates the timestamp of the last successful update check. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/security/state/provider/UpdateInfoManager#unregisterUpdate(androidx.security.state.UpdateInfo)(updateInfo: https://developer.android.com/reference/kotlin/androidx/security/state/UpdateInfo)` Unregisters information about an available update for the specified component. |

## Public constructors

### UpdateInfoManager

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

```
UpdateInfoManager(
    context: Context,
    customSecurityState: SecurityPatchState? = null
)
```

## Public functions

### getLastCheckTimeMillis

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

```
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 |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The time of the last check in milliseconds since the epoch (`https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()`), or 0 if no check has ever occurred. |

### registerUpdate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

```
fun registerUpdate(updateInfo: UpdateInfo): Unit
```

Registers information about an available update for the specified component.

| Parameters |
|---|---|
| `updateInfo: https://developer.android.com/reference/kotlin/androidx/security/state/UpdateInfo` | Update information structure. |

### setLastCheckTimeMillis

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

```
fun setLastCheckTimeMillis(timestampMillis: Long): Unit
```

Updates the timestamp of the last successful update check.

**Usage Note for Hosts:** The `https://developer.android.com/reference/kotlin/androidx/security/state/provider/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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The current time in milliseconds (`https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()`). |

### unregisterUpdate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/security#1.0.0)

```
fun unregisterUpdate(updateInfo: UpdateInfo): Unit
```

Unregisters information about an available update for the specified component.

| Parameters |
|---|---|
| `updateInfo: https://developer.android.com/reference/kotlin/androidx/security/state/UpdateInfo` | Update information structure. |