diff options
| author | Narayan Kamath <narayan@google.com> | 2019-01-30 10:15:33 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-01-30 10:15:33 +0000 |
| commit | a3bf162ae44e434cfc59d96f4bcfcb27ffdb2370 (patch) | |
| tree | 3309d787d54a56e16b6677dd0090d7a11885ef1f /core/java | |
| parent | aab0a275aebdaece4ea97add4e151193cddd5e00 (diff) | |
| parent | c034fe9e981961467814cdd04e717df67ce7b2e7 (diff) | |
Merge "Multi-user support for app data snapshot / rollback."
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/rollback/PackageRollbackInfo.java | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/core/java/android/content/rollback/PackageRollbackInfo.java b/core/java/android/content/rollback/PackageRollbackInfo.java index 4644a83de462..d4ed35a9cb71 100644 --- a/core/java/android/content/rollback/PackageRollbackInfo.java +++ b/core/java/android/content/rollback/PackageRollbackInfo.java @@ -16,10 +16,14 @@ package android.content.rollback; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.content.pm.VersionedPackage; import android.os.Parcel; import android.os.Parcelable; +import android.util.IntArray; + +import java.util.ArrayList; /** * Information about a rollback available for a particular package. @@ -33,6 +37,38 @@ public final class PackageRollbackInfo implements Parcelable { private final VersionedPackage mVersionRolledBackTo; /** + * Encapsulates information required to restore a snapshot of an app's userdata. + * + * @hide + */ + public static class RestoreInfo { + public final int userId; + public final int appId; + public final String seInfo; + + public RestoreInfo(int userId, int appId, String seInfo) { + this.userId = userId; + this.appId = appId; + this.seInfo = seInfo; + } + } + + /* + * The list of users for which we need to backup userdata for this package. Backups of + * credential encrypted data are listed as pending if the user hasn't unlocked their device + * with credentials yet. + */ + // NOTE: Not a part of the Parcelable representation of this object. + private final IntArray mPendingBackups; + + /** + * The list of users for which we need to restore userdata for this package. This field is + * non-null only after a rollback for this package has been committed. + */ + // NOTE: Not a part of the Parcelable representation of this object. + private final ArrayList<RestoreInfo> mPendingRestores; + + /** * Returns the name of the package to roll back from. */ public String getPackageName() { @@ -54,15 +90,46 @@ public final class PackageRollbackInfo implements Parcelable { } /** @hide */ + public IntArray getPendingBackups() { + return mPendingBackups; + } + + /** @hide */ + public ArrayList<RestoreInfo> getPendingRestores() { + return mPendingRestores; + } + + /** @hide */ + public RestoreInfo getRestoreInfo(int userId) { + for (RestoreInfo ri : mPendingRestores) { + if (ri.userId == userId) { + return ri; + } + } + + return null; + } + + /** @hide */ + public void removeRestoreInfo(RestoreInfo ri) { + mPendingRestores.remove(ri); + } + + /** @hide */ public PackageRollbackInfo(VersionedPackage packageRolledBackFrom, - VersionedPackage packageRolledBackTo) { + VersionedPackage packageRolledBackTo, + @NonNull IntArray pendingBackups, @NonNull ArrayList<RestoreInfo> pendingRestores) { this.mVersionRolledBackFrom = packageRolledBackFrom; this.mVersionRolledBackTo = packageRolledBackTo; + this.mPendingBackups = pendingBackups; + this.mPendingRestores = pendingRestores; } private PackageRollbackInfo(Parcel in) { this.mVersionRolledBackFrom = VersionedPackage.CREATOR.createFromParcel(in); this.mVersionRolledBackTo = VersionedPackage.CREATOR.createFromParcel(in); + this.mPendingRestores = null; + this.mPendingBackups = null; } @Override |
