Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 196437d3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I315e75c3,I23d36950

* changes:
  Commit rollbacks by ID, not by RollbackInfo.
  Stub out API to support rollback of staged installs.
parents b8a51a31 e87368e1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1700,12 +1700,14 @@ package android.content.rollback {
    method public int describeContents();
    method public java.util.List<android.content.rollback.PackageRollbackInfo> getPackages();
    method public int getRollbackId();
    method public int getSessionId();
    method public boolean isStaged();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.content.rollback.RollbackInfo> CREATOR;
  }
  public final class RollbackManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void commitRollback(@NonNull android.content.rollback.RollbackInfo, @NonNull android.content.IntentSender);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void commitRollback(int, @NonNull android.content.IntentSender);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void expireRollbackForPackage(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public java.util.List<android.content.rollback.RollbackInfo> getAvailableRollbacks();
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @NonNull public java.util.List<android.content.rollback.RollbackInfo> getRecentlyCommittedRollbacks();
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ interface IRollbackManager {
    ParceledListSlice getAvailableRollbacks();
    ParceledListSlice getRecentlyExecutedRollbacks();

    void executeRollback(in RollbackInfo rollback, String callerPackageName,
    void commitRollback(int rollbackId, String callerPackageName,
            in IntentSender statusReceiver);

    // Exposed for use from the system server only. Callback from the package
+19 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.rollback;

import android.annotation.SystemApi;
import android.content.pm.PackageInstaller;
import android.os.Parcel;
import android.os.Parcelable;

@@ -38,9 +39,6 @@ public final class RollbackInfo implements Parcelable {

    private final List<PackageRollbackInfo> mPackages;

    // TODO: Add a flag to indicate if reboot is required, when rollback of
    // staged installs is supported.

    /** @hide */
    public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) {
        this.mRollbackId = rollbackId;
@@ -66,6 +64,24 @@ public final class RollbackInfo implements Parcelable {
        return mPackages;
    }

    /**
     * Returns true if this rollback requires reboot to take effect after
     * being committed.
     */
    public boolean isStaged() {
        // TODO: Support rollback of staged installs.
        return false;
    }

    /**
     * Returns the session ID for the committed rollback for staged rollbacks.
     * Only applicable for rollbacks that have been committed.
     */
    public int getSessionId() {
        // TODO: Support rollback of staged installs.
        return PackageInstaller.SessionInfo.INVALID_ID;
    }

    @Override
    public int describeContents() {
        return 0;
+3 −4
Original line number Diff line number Diff line
@@ -102,16 +102,15 @@ public final class RollbackManager {
     * <p>
     * TODO: Specify the returns status codes.
     *
     * @param rollback to commit
     * @param rollbackId ID of the rollback to commit
     * @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(@NonNull RollbackInfo rollback,
            @NonNull IntentSender statusReceiver) {
    public void commitRollback(int rollbackId, @NonNull IntentSender statusReceiver) {
        try {
            mBinder.executeRollback(rollback, mCallerPackageName, statusReceiver);
            mBinder.commitRollback(rollbackId, mCallerPackageName, statusReceiver);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+7 −6
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
    }

    @Override
    public void executeRollback(RollbackInfo rollback, String callerPackageName,
    public void commitRollback(int rollbackId, String callerPackageName,
            IntentSender statusReceiver) {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.MANAGE_ROLLBACKS,
@@ -238,19 +238,19 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
        appOps.checkPackage(callingUid, callerPackageName);

        getHandler().post(() ->
                executeRollbackInternal(rollback, callerPackageName, statusReceiver));
                commitRollbackInternal(rollbackId, callerPackageName, statusReceiver));
    }

    /**
     * Performs the actual work to execute a rollback.
     * Performs the actual work to commit a rollback.
     * The work is done on the current thread. This may be a long running
     * operation.
     */
    private void executeRollbackInternal(RollbackInfo rollback,
    private void commitRollbackInternal(int rollbackId,
            String callerPackageName, IntentSender statusReceiver) {
        Log.i(TAG, "Initiating rollback");

        RollbackData data = getRollbackForId(rollback.getRollbackId());
        RollbackData data = getRollbackForId(rollbackId);
        if (data == null) {
            sendFailure(statusReceiver, "Rollback unavailable");
            return;
@@ -350,7 +350,8 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
                                return;
                            }

                            addRecentlyExecutedRollback(rollback);
                            addRecentlyExecutedRollback(
                                    new RollbackInfo(data.rollbackId, data.packages));
                            sendSuccess(statusReceiver);

                            Intent broadcast = new Intent(Intent.ACTION_ROLLBACK_COMMITTED);
Loading