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

Commit 74a55700 authored by Gavin Corkery's avatar Gavin Corkery Committed by Android (Google) Code Review
Browse files

Merge "Move last crash to trigger rollback to host side" into sc-dev

parents 78c7be7c c726ac66
Loading
Loading
Loading
Loading
+5 −13
Original line number Diff line number Diff line
@@ -124,22 +124,12 @@ public class StagedRollbackTest {
        Thread.sleep(TimeUnit.SECONDS.toMillis(30));
    }

    /**
     * Test rollbacks of staged installs involving only apks with bad update.
     * Trigger rollback phase.
     */
    @Test
    public void testBadApkOnly_Phase3_Crash() throws Exception {
        // One more crash to trigger rollback
        RollbackUtils.sendCrashBroadcast(TestApp.A, 1);
    }

    /**
     * Test rollbacks of staged installs involving only apks.
     * Confirm rollback phase.
     */
    @Test
    public void testBadApkOnly_Phase4_VerifyRollback() throws Exception {
    public void testBadApkOnly_Phase3_VerifyRollback() throws Exception {
        assertThat(InstallUtils.getInstalledVersion(TestApp.A)).isEqualTo(1);
        InstallUtils.processUserData(TestApp.A);

@@ -447,8 +437,10 @@ public class StagedRollbackTest {
                Rollback.from(TEST_APEX_WITH_APK_V2).to(TEST_APEX_WITH_APK_V1),
                Rollback.from(TestApp.A, 0).to(TestApp.A1));

        // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback
        RollbackUtils.sendCrashBroadcast(TestApp.A, 5);
        // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT-1 times
        RollbackUtils.sendCrashBroadcast(TestApp.A, 4);
        // Sleep for a while to make sure we don't trigger rollback
        Thread.sleep(TimeUnit.SECONDS.toMillis(30));
    }

    @Test
+14 −5
Original line number Diff line number Diff line
@@ -153,13 +153,14 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
        getDevice().reboot();
        runPhase("testBadApkOnly_Phase2_VerifyInstall");

        // Trigger rollback and wait for reboot to happen
        runPhase("testBadApkOnly_Phase3_Crash");
        // Launch the app to crash to trigger rollback
        startActivity(TESTAPP_A);
        // Wait for reboot to happen
        waitForDeviceNotAvailable(2, TimeUnit.MINUTES);

        getDevice().waitForDeviceAvailable();

        runPhase("testBadApkOnly_Phase4_VerifyRollback");
        runPhase("testBadApkOnly_Phase3_VerifyRollback");

        assertThat(mLogger).eventOccurred(ROLLBACK_INITIATE, null, REASON_APP_CRASH, TESTAPP_A);
        assertThat(mLogger).eventOccurred(ROLLBACK_BOOT_TRIGGERED, null, null, null);
@@ -304,8 +305,10 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
        getDevice().reboot();
        // Verify apex was installed and then crash the apk
        runPhase("testRollbackApexWithApkCrashing_Phase2_Crash");
        // Wait for crash to trigger rollback
        waitForDeviceNotAvailable(5, TimeUnit.MINUTES);
        // Launch the app to crash to trigger rollback
        startActivity(TESTAPP_A);
        // Wait for reboot to happen
        waitForDeviceNotAvailable(2, TimeUnit.MINUTES);
        getDevice().waitForDeviceAvailable();
        // Verify rollback occurred due to crash of apk-in-apex
        runPhase("testRollbackApexWithApkCrashing_Phase3_VerifyRollback");
@@ -631,6 +634,12 @@ public class StagedRollbackTest extends BaseHostJUnit4Test {
        }
    }

    private void startActivity(String packageName) throws Exception {
        String cmd = "am start -S -a android.intent.action.MAIN "
                + "-c android.intent.category.LAUNCHER " + packageName;
        getDevice().executeShellCommand(cmd);
    }

    private void crashProcess(String processName, int numberOfCrashes) throws Exception {
        String pid = "";
        String lastPid = "invalid";