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

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

Merge changes Ib05902aa,Id7e8efaa,I3408af12,I6cc3b276,I9c94d2f5, ...

* changes:
  Add support for rollback of multiPackage installs.
  Add multi-package support to RollbackData.
  RollbackManagerService: Add getRollbackForPackage helper function.
  Reorganize rollback data storage layout.
  Rename PackageRollbackData RollbackData.
  Make rollbacks available only after session commit.
parents 2baff48b f1910c5a
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -20,17 +20,21 @@ import android.content.rollback.PackageRollbackInfo;

import java.io.File;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;

/**
 * Information about a rollback available for a particular package.
 * This is similar to {@link PackageRollbackInfo}, but extended with
 * additional information for internal bookkeeping.
 * Information about a rollback available for a set of atomically installed
 * packages.
 */
class PackageRollbackData {
    public final PackageRollbackInfo info;
class RollbackData {
    /**
     * The per-package rollback information.
     */
    public final List<PackageRollbackInfo> packages = new ArrayList<>();

    /**
     * The directory where the apk backup is stored.
     * The directory where the rollback data is stored.
     */
    public final File backupDir;

@@ -38,12 +42,9 @@ class PackageRollbackData {
     * The time when the upgrade occurred, for purposes of expiring
     * rollback data.
     */
    public final Instant timestamp;
    public Instant timestamp;

    PackageRollbackData(PackageRollbackInfo info,
            File backupDir, Instant timestamp) {
        this.info = info;
    RollbackData(File backupDir) {
        this.backupDir = backupDir;
        this.timestamp = timestamp;
    }
}
+308 −126

File changed.

Preview size limit exceeded, changes collapsed.

+23 −1
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ public class RollbackTest {
            }

            // The app should not be available for rollback.
            // TODO: See if there is a way to remove this race condition
            // between when the app is uninstalled and when the previously
            // available rollback, if any, is removed.
            Thread.sleep(1000);
            assertNull(rm.getAvailableRollback(TEST_APP_A));
            assertFalse(rm.getPackagesWithAvailableRollbacks().contains(TEST_APP_A));

@@ -125,6 +129,10 @@ public class RollbackTest {
            assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

            // The app should now be available for rollback.
            // TODO: See if there is a way to remove this race condition
            // between when the app is installed and when the rollback
            // is made available.
            Thread.sleep(1000);
            assertTrue(rm.getPackagesWithAvailableRollbacks().contains(TEST_APP_A));
            RollbackInfo rollback = rm.getAvailableRollback(TEST_APP_A);
            assertNotNull(rollback);
@@ -182,6 +190,8 @@ public class RollbackTest {

            RollbackManager rm = RollbackTestUtils.getRollbackManager();

            // TODO: Test this with multi-package rollback, not just single
            // package rollback.
            // Prep installation of TEST_APP_A
            RollbackTestUtils.uninstall(TEST_APP_A);
            RollbackTestUtils.install("RollbackTestAppAv1.apk", false);
@@ -189,6 +199,10 @@ public class RollbackTest {
            assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

            // The app should now be available for rollback.
            // TODO: See if there is a way to remove this race condition
            // between when the app is installed and when the rollback
            // is made available.
            Thread.sleep(1000);
            assertTrue(rm.getPackagesWithAvailableRollbacks().contains(TEST_APP_A));
            RollbackInfo rollback = rm.getAvailableRollback(TEST_APP_A);
            assertNotNull(rollback);
@@ -263,6 +277,10 @@ public class RollbackTest {
            assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

            // The app should now be available for rollback.
            // TODO: See if there is a way to remove this race condition
            // between when the app is installed and when the rollback
            // is made available.
            Thread.sleep(1000);
            assertTrue(rm.getPackagesWithAvailableRollbacks().contains(TEST_APP_A));
            RollbackInfo rollback = rm.getAvailableRollback(TEST_APP_A);
            assertNotNull(rollback);
@@ -405,6 +423,10 @@ public class RollbackTest {

            // Both test apps should now be available for rollback, and the
            // targetPackage returned for rollback should be correct.
            // TODO: See if there is a way to remove this race condition
            // between when the app is installed and when the rollback
            // is made available.
            Thread.sleep(1000);
            RollbackInfo rollbackA = rm.getAvailableRollback(TEST_APP_A);
            assertNotNull(rollbackA);
            assertEquals(TEST_APP_A, rollbackA.targetPackage.packageName);
@@ -491,7 +513,7 @@ public class RollbackTest {
     * TODO: Stop ignoring this test once support for multi-package rollback
     * is implemented.
     */
    @Ignore @Test
    @Test
    public void testMultiPackage() throws Exception {
        try {
            RollbackTestUtils.adoptShellPermissionIdentity(