Merge "Add a way to record causePackages for rollbacks."
This commit is contained in:
committed by
Android (Google) Code Review
commit
66a23d0504
@@ -26,8 +26,8 @@ interface IRollbackManager {
|
||||
ParceledListSlice getAvailableRollbacks();
|
||||
ParceledListSlice getRecentlyExecutedRollbacks();
|
||||
|
||||
void commitRollback(int rollbackId, String callerPackageName,
|
||||
in IntentSender statusReceiver);
|
||||
void commitRollback(int rollbackId, in ParceledListSlice causePackages,
|
||||
String callerPackageName, in IntentSender statusReceiver);
|
||||
|
||||
// Exposed for use from the system server only. Callback from the package
|
||||
// manager during the install flow when user data can be restored for a given
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.content.rollback;
|
||||
|
||||
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 @@ public final class RollbackInfo implements Parcelable {
|
||||
|
||||
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 @@ public final class RollbackInfo implements Parcelable {
|
||||
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 final class RollbackInfo implements Parcelable {
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeInt(mRollbackId);
|
||||
out.writeTypedList(mPackages);
|
||||
out.writeTypedList(mCausePackages);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<RollbackInfo> CREATOR =
|
||||
|
||||
@@ -22,6 +22,8 @@ import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.content.Context;
|
||||
import android.content.IntentSender;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.content.pm.VersionedPackage;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import java.util.List;
|
||||
@@ -103,14 +105,18 @@ public final class RollbackManager {
|
||||
* TODO: Specify the returns status codes.
|
||||
*
|
||||
* @param rollbackId ID of the rollback to commit
|
||||
* @param causePackages package versions to record as the motivation for this
|
||||
* rollback.
|
||||
* @param statusReceiver where to deliver the results
|
||||
* @throws SecurityException if the caller does not have the
|
||||
* MANAGE_ROLLBACKS permission.
|
||||
*/
|
||||
@RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS)
|
||||
public void commitRollback(int rollbackId, @NonNull IntentSender statusReceiver) {
|
||||
public void commitRollback(int rollbackId, @NonNull List<VersionedPackage> causePackages,
|
||||
@NonNull IntentSender statusReceiver) {
|
||||
try {
|
||||
mBinder.commitRollback(rollbackId, mCallerPackageName, statusReceiver);
|
||||
mBinder.commitRollback(rollbackId, new ParceledListSlice(causePackages),
|
||||
mCallerPackageName, statusReceiver);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user