Add a way to record causePackages for rollbacks.
By passing a new causePackages list of VersionedPackage to
commitRollback and adding a RollbackInfo.getCausePackages() method to
retrieve the cause packages for committed rollbacks.
Bug: 112431924
Test: atest RollbackTest
Change-Id: I3b52511fd7e31b6304e7a7c34180dbb4d20f6dbf
diff --git a/core/java/android/content/rollback/RollbackInfo.java b/core/java/android/content/rollback/RollbackInfo.java
index 812f995..1111b43 100644
--- a/core/java/android/content/rollback/RollbackInfo.java
+++ b/core/java/android/content/rollback/RollbackInfo.java
@@ -18,6 +18,7 @@
import android.annotation.SystemApi;
import android.content.pm.PackageInstaller;
+import android.content.pm.VersionedPackage;
import android.os.Parcel;
import android.os.Parcelable;
@@ -39,15 +40,20 @@
private final List<PackageRollbackInfo> mPackages;
+ private final List<VersionedPackage> mCausePackages;
+
/** @hide */
- public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) {
+ public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages,
+ List<VersionedPackage> causePackages) {
this.mRollbackId = rollbackId;
this.mPackages = packages;
+ this.mCausePackages = causePackages;
}
private RollbackInfo(Parcel in) {
mRollbackId = in.readInt();
mPackages = in.createTypedArrayList(PackageRollbackInfo.CREATOR);
+ mCausePackages = in.createTypedArrayList(VersionedPackage.CREATOR);
}
/**
@@ -82,6 +88,15 @@
return PackageInstaller.SessionInfo.INVALID_ID;
}
+ /**
+ * Gets the list of package versions that motivated this rollback.
+ * As provided to {@link #commitRollback} when the rollback was committed.
+ * This is only applicable for rollbacks that have been committed.
+ */
+ public List<VersionedPackage> getCausePackages() {
+ return mCausePackages;
+ }
+
@Override
public int describeContents() {
return 0;
@@ -91,6 +106,7 @@
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mRollbackId);
out.writeTypedList(mPackages);
+ out.writeTypedList(mCausePackages);
}
public static final Parcelable.Creator<RollbackInfo> CREATOR =