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

Commit efb4132b authored by Richard Uhler's avatar Richard Uhler Committed by Android (Google) Code Review
Browse files

Merge changes Ic2bb4798,I2a409de2,I88a50a0e,Ia69342a4,Ia6548e4d, ...

* changes:
  Use "commit" instead of "execute" for rollbacks.
  Rename PACKAGE_ROLLBACK_EXECUTED to ROLLBACK_COMMITTED.
  Remove unused RollbackManager APIs.
  Use RollbackManager.getAvailableRollbacks in RollbackTest
  Use new RollbackManager API in RollbackPackageHealthObserver.
  Add RollbackManager.getAvailableRollbacks API.
  Include all relevant packages in RollbackInfo.
parents 71ae5ba4 4b092ef6
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1303,13 +1303,13 @@ package android.content {
    field public static final String ACTION_MANAGE_PERMISSION_APPS = "android.intent.action.MANAGE_PERMISSION_APPS";
    field @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS) public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES = "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
    field public static final String ACTION_MASTER_CLEAR_NOTIFICATION = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
    field public static final String ACTION_PACKAGE_ROLLBACK_EXECUTED = "android.intent.action.PACKAGE_ROLLBACK_EXECUTED";
    field public static final String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED";
    field public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
    field public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
    field @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) public static final String ACTION_REVIEW_APP_PERMISSION_USAGE = "android.intent.action.REVIEW_APP_PERMISSION_USAGE";
    field public static final String ACTION_REVIEW_PERMISSIONS = "android.intent.action.REVIEW_PERMISSIONS";
    field public static final String ACTION_REVIEW_PERMISSION_USAGE = "android.intent.action.REVIEW_PERMISSION_USAGE";
    field public static final String ACTION_ROLLBACK_COMMITTED = "android.intent.action.ROLLBACK_COMMITTED";
    field public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS = "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
    field @Deprecated public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
    field public static final String ACTION_SPLIT_CONFIGURATION_CHANGED = "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
@@ -1695,18 +1695,17 @@ package android.content.rollback {
  public final class RollbackInfo implements android.os.Parcelable {
    method public int describeContents();
    method public java.util.List<android.content.rollback.PackageRollbackInfo> getPackages();
    method public int getRollbackId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.content.rollback.RollbackInfo> CREATOR;
    field public final android.content.rollback.PackageRollbackInfo targetPackage;
  }
  public final class RollbackManager {
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void executeRollback(@NonNull android.content.rollback.RollbackInfo, @NonNull android.content.IntentSender);
    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 expireRollbackForPackage(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @Nullable public android.content.rollback.RollbackInfo getAvailableRollback(@NonNull String);
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @NonNull public java.util.List<java.lang.String> getPackagesWithAvailableRollbacks();
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) @NonNull public java.util.List<android.content.rollback.RollbackInfo> getRecentlyExecutedRollbacks();
    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();
    method @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS) public void reloadPersistedData();
  }
+3 −4
Original line number Diff line number Diff line
@@ -2375,8 +2375,7 @@ public class Intent implements Parcelable, Cloneable {
    public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
            "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
    /**
     * Broadcast Action: An existing version of an application package has been
     * rolled back to a previous version.
     * Broadcast Action: A rollback has been committed.
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
@@ -2385,8 +2384,8 @@ public class Intent implements Parcelable, Cloneable {
     */
    @SystemApi
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_PACKAGE_ROLLBACK_EXECUTED =
            "android.intent.action.PACKAGE_ROLLBACK_EXECUTED";
    public static final String ACTION_ROLLBACK_COMMITTED =
            "android.intent.action.ROLLBACK_COMMITTED";
    /**
     * @hide
     * Broadcast Action: Ask system services if there is any reason to
+1 −5
Original line number Diff line number Diff line
@@ -17,17 +17,13 @@
package android.content.rollback;

import android.content.pm.ParceledListSlice;
import android.content.pm.StringParceledListSlice;
import android.content.rollback.RollbackInfo;
import android.content.IntentSender;

/** {@hide} */
interface IRollbackManager {

    RollbackInfo getAvailableRollback(String packageName);

    StringParceledListSlice getPackagesWithAvailableRollbacks();

    ParceledListSlice getAvailableRollbacks();
    ParceledListSlice getRecentlyExecutedRollbacks();

    void executeRollback(in RollbackInfo rollback, String callerPackageName,
+14 −10
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.List;

/**
 * Information about a set of packages that can be, or already have been
 * rolled back together.
@@ -34,25 +36,20 @@ public final class RollbackInfo implements Parcelable {
     */
    private final int mRollbackId;

    /**
     * The package that needs to be rolled back.
     */
    public final PackageRollbackInfo targetPackage;
    private final List<PackageRollbackInfo> mPackages;

    // TODO: Add a list of additional packages rolled back due to atomic
    // install dependencies when rollback of atomic installs is supported.
    // TODO: Add a flag to indicate if reboot is required, when rollback of
    // staged installs is supported.

    /** @hide */
    public RollbackInfo(int rollbackId, PackageRollbackInfo targetPackage) {
    public RollbackInfo(int rollbackId, List<PackageRollbackInfo> packages) {
        this.mRollbackId = rollbackId;
        this.targetPackage = targetPackage;
        this.mPackages = packages;
    }

    private RollbackInfo(Parcel in) {
        mRollbackId = in.readInt();
        targetPackage = PackageRollbackInfo.CREATOR.createFromParcel(in);
        mPackages = in.createTypedArrayList(PackageRollbackInfo.CREATOR);
    }

    /**
@@ -62,6 +59,13 @@ public final class RollbackInfo implements Parcelable {
        return mRollbackId;
    }

    /**
     * Returns the list of package that are rolled back.
     */
    public List<PackageRollbackInfo> getPackages() {
        return mPackages;
    }

    @Override
    public int describeContents() {
        return 0;
@@ -70,7 +74,7 @@ public final class RollbackInfo implements Parcelable {
    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(mRollbackId);
        targetPackage.writeToParcel(out, flags);
        out.writeTypedList(mPackages);
    }

    public static final Parcelable.Creator<RollbackInfo> CREATOR =
+18 −49
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.content.rollback;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
@@ -50,55 +49,26 @@ public final class RollbackManager {
    }

    /**
     * Returns the rollback currently available to be executed for the given
     * package.
     * <p>
     * The returned RollbackInfo describes what packages would be rolled back,
     * including package version codes before and after rollback. The rollback
     * can be initiated using {@link #executeRollback(RollbackInfo,IntentSender)}.
     * <p>
     * TODO: What if there is no package installed on device for packageName?
     * Returns a list of all currently available rollbacks.
     *
     * @param packageName name of the package to get the availble RollbackInfo for.
     * @return the rollback available for the package, or null if no rollback
     *         is available for the package.
     * @throws SecurityException if the caller does not have the
     *            MANAGE_ROLLBACKS permission.
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS)
    public @Nullable RollbackInfo getAvailableRollback(@NonNull String packageName) {
    public List<RollbackInfo> getAvailableRollbacks() {
        try {
            return mBinder.getAvailableRollback(packageName);
            return mBinder.getAvailableRollbacks().getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets the names of packages that are available for rollback.
     * Call {@link #getAvailableRollback(String)} to get more information
     * about the rollback available for a particular package.
     *
     * @return the names of packages that are available for rollback.
     * @throws SecurityException if the caller does not have the
     *            MANAGE_ROLLBACKS permission.
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS)
    public @NonNull List<String> getPackagesWithAvailableRollbacks() {
        try {
            return mBinder.getPackagesWithAvailableRollbacks().getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }


    /**
     * Gets the list of all recently executed rollbacks.
     * Gets the list of all recently committed rollbacks.
     * This is for the purposes of preventing re-install of a bad version of a
     * package.
     * package and monitoring the status of a staged rollback.
     * <p>
     * Returns an empty list if there are no recently executed rollbacks.
     * Returns an empty list if there are no recently committed rollbacks.
     * <p>
     * To avoid having to keep around complete rollback history forever on a
     * device, the returned list of rollbacks is only guaranteed to include
@@ -107,12 +77,12 @@ public final class RollbackManager {
     * (without the possibility of rollback) to a higher version code than was
     * rolled back from.
     *
     * @return the recently executed rollbacks
     * @return the recently committed rollbacks
     * @throws SecurityException if the caller does not have the
     *            MANAGE_ROLLBACKS permission.
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_ROLLBACKS)
    public @NonNull List<RollbackInfo> getRecentlyExecutedRollbacks() {
    public @NonNull List<RollbackInfo> getRecentlyCommittedRollbacks() {
        try {
            return mBinder.getRecentlyExecutedRollbacks().getList();
        } catch (RemoteException e) {
@@ -121,25 +91,24 @@ public final class RollbackManager {
    }

    /**
     * Execute the given rollback, rolling back all versions of the packages
     * to the last good versions previously installed on the device as
     * specified in the given rollback object. The rollback will fail if any
     * of the installed packages or available rollbacks are inconsistent with
     * the versions specified in the given rollback object, which can happen
     * if a package has been updated or a rollback expired since the rollback
     * object was retrieved from {@link #getAvailableRollback(String)}.
     * Commit the rollback with given id, rolling back all versions of the
     * packages to the last good versions previously installed on the device
     * as specified in the corresponding RollbackInfo object. The
     * rollback will fail if any of the installed packages or available
     * rollbacks are inconsistent with the versions specified in the given
     * rollback object, which can happen if a package has been updated or a
     * rollback expired since the rollback object was retrieved from
     * {@link #getAvailableRollbacks()}.
     * <p>
     * TODO: Specify the returns status codes.
     * TODO: What happens in case reboot is required for the rollback to take
     * effect for staged installs?
     *
     * @param rollback to execute
     * @param 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 executeRollback(@NonNull RollbackInfo rollback,
    public void commitRollback(@NonNull RollbackInfo rollback,
            @NonNull IntentSender statusReceiver) {
        try {
            mBinder.executeRollback(rollback, mCallerPackageName, statusReceiver);
Loading