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

Commit 4b092ef6 authored by Richard Uhler's avatar Richard Uhler
Browse files

Use "commit" instead of "execute" for rollbacks.

Which makes more sense for rollback of staged installs, where the caller
will have to reboot the device before the rollback takes effect.

Internal references to "execute" in IRollbackManager.aidl and the
rollback manager service implementation will be renamed in a follow up
CL.

Bug: 112431924
Test: atest RollbackTest
Change-Id: Ic2bb479873b309fc145e4eda3b347849ac219ac9
parent dca7beb7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1702,10 +1702,10 @@ package android.content.rollback {
  }
  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) 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> getRecentlyExecutedRollbacks();
    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();
  }
+15 −16
Original line number Diff line number Diff line
@@ -64,11 +64,11 @@ public final class RollbackManager {
    }

    /**
     * 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
@@ -77,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) {
@@ -91,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 #getAvailableRollbacks()}.
     * 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);
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve
                }
            });
        });
        manager.executeRollback(rollback, rollbackReceiver.getIntentSender());
        manager.commitRollback(rollback, rollbackReceiver.getIntentSender());
    }

    @Override
+14 −14
Original line number Diff line number Diff line
@@ -84,8 +84,8 @@ public class RollbackTest {
                    Manifest.permission.DELETE_PACKAGES,
                    Manifest.permission.MANAGE_ROLLBACKS);

            // Register a broadcast receiver for notification when the rollback is
            // done executing.
            // Register a broadcast receiver for notification when the
            // rollback has been committed.
            RollbackBroadcastReceiver broadcastReceiver = new RollbackBroadcastReceiver();
            RollbackManager rm = RollbackTestUtils.getRollbackManager();

@@ -98,7 +98,7 @@ public class RollbackTest {
            // so that's not the case!
            for (int i = 0; i < 5; ++i) {
                RollbackInfo rollback = getUniqueRollbackInfoForPackage(
                        rm.getRecentlyExecutedRollbacks(), TEST_APP_A);
                        rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
                if (rollback != null) {
                    Log.i(TAG, "Sleeping 1 second to wait for uninstall to take effect.");
                    Thread.sleep(1000);
@@ -112,9 +112,9 @@ public class RollbackTest {
            Thread.sleep(1000);
            assertNull(getUniqueRollbackInfoForPackage(rm.getAvailableRollbacks(), TEST_APP_A));

            // There should be no recently executed rollbacks for this package.
            // There should be no recently committed rollbacks for this package.
            assertNull(getUniqueRollbackInfoForPackage(
                        rm.getRecentlyExecutedRollbacks(), TEST_APP_A));
                        rm.getRecentlyCommittedRollbacks(), TEST_APP_A));

            // Install v1 of the app (without rollbacks enabled).
            RollbackTestUtils.install("RollbackTestAppAv1.apk", false);
@@ -151,7 +151,7 @@ public class RollbackTest {

            // Verify the recent rollback has been recorded.
            rollback = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyExecutedRollbacks(), TEST_APP_A);
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
            assertRollbackInfoEquals(TEST_APP_A, 2, 1, rollback);

            broadcastReceiver.unregister();
@@ -277,10 +277,10 @@ public class RollbackTest {
    }

    /**
     * Test that recently executed rollback data is properly persisted.
     * Test that recently committed rollback data is properly persisted.
     */
    @Test
    public void testRecentlyExecutedRollbackPersistence() throws Exception {
    public void testRecentlyCommittedRollbackPersistence() throws Exception {
        try {
            RollbackTestUtils.adoptShellPermissionIdentity(
                    Manifest.permission.INSTALL_PACKAGES,
@@ -308,7 +308,7 @@ public class RollbackTest {

            // Verify the recent rollback has been recorded.
            rollback = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyExecutedRollbacks(), TEST_APP_A);
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
            assertNotNull(rollback);
            assertRollbackInfoEquals(TEST_APP_A, 2, 1, rollback);

@@ -317,7 +317,7 @@ public class RollbackTest {

            // Verify the recent rollback is still recorded.
            rollback = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyExecutedRollbacks(), TEST_APP_A);
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
            assertNotNull(rollback);
            assertRollbackInfoEquals(TEST_APP_A, 2, 1, rollback);
        } finally {
@@ -535,7 +535,7 @@ public class RollbackTest {
        }

        try {
            rm.getRecentlyExecutedRollbacks();
            rm.getRecentlyCommittedRollbacks();
            fail("expected SecurityException");
        } catch (SecurityException e) {
            // Expected.
@@ -544,7 +544,7 @@ public class RollbackTest {
        try {
            // TODO: What if the implementation checks arguments for non-null
            // first? Then this test isn't valid.
            rm.executeRollback(null, null);
            rm.commitRollback(null, null);
            fail("expected SecurityException");
        } catch (SecurityException e) {
            // Expected.
@@ -605,10 +605,10 @@ public class RollbackTest {
            // We should see recent rollbacks listed for both A and B.
            Thread.sleep(1000);
            RollbackInfo rollbackA = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyExecutedRollbacks(), TEST_APP_A);
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_A);

            RollbackInfo rollbackB = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyExecutedRollbacks(), TEST_APP_B);
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_B);
            assertRollbackInfoForAandB(rollbackB);

            assertEquals(rollbackA.getRollbackId(), rollbackB.getRollbackId());
+2 −2
Original line number Diff line number Diff line
@@ -90,12 +90,12 @@ class RollbackTestUtils {
    }

    /**
     * Execute the given rollback.
     * Commit the given rollback.
     * @throws AssertionError if the rollback fails.
     */
    static void rollback(RollbackInfo rollback) throws InterruptedException {
        RollbackManager rm = getRollbackManager();
        rm.executeRollback(rollback, LocalIntentSender.getIntentSender());
        rm.commitRollback(rollback, LocalIntentSender.getIntentSender());
        assertStatusSuccess(LocalIntentSender.getIntentSenderResult());
    }