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

Commit 0c03aaae authored by Richard Uhler's avatar Richard Uhler
Browse files

Update to new RollbackUtils.sendCrashBroadcast API.

Bug: 139108668
Test: atest StagedRollbackTest:com.android.tests.rollback.host.StagedRollbackTest#testBadApkOnly
2
Change-Id: Iaaa728aa58d894ba546677e8295faba2ebfc5e64
parent ae26d1eb
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -929,7 +929,6 @@ public class RollbackTest {
     */
    @Test
    public void testBadUpdateRollback() throws Exception {
        BroadcastReceiver crashCountReceiver = null;
        Context context = InstrumentationRegistry.getContext();
        try {
            InstallUtils.adoptShellPermissionIdentity(
@@ -937,7 +936,7 @@ public class RollbackTest {
                    Manifest.permission.DELETE_PACKAGES,
                    Manifest.permission.MANAGE_ROLLBACKS,
                    Manifest.permission.TEST_MANAGE_ROLLBACKS,
                    Manifest.permission.KILL_BACKGROUND_PROCESSES,
                    Manifest.permission.FORCE_STOP_PACKAGES,
                    Manifest.permission.RESTART_PACKAGES);
            RollbackManager rm = RollbackUtils.getRollbackManager();

@@ -967,7 +966,7 @@ public class RollbackTest {
            RollbackBroadcastReceiver rollbackReceiver = new RollbackBroadcastReceiver();

            // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback
            crashCountReceiver = RollbackUtils.sendCrashBroadcast(context, TestApp.A, 5);
            RollbackUtils.sendCrashBroadcast(TestApp.A, 5);

            // Verify we received a broadcast for the rollback.
            rollbackReceiver.take();
@@ -981,9 +980,6 @@ public class RollbackTest {
            assertThat(InstallUtils.getInstalledVersion(TestApp.B)).isEqualTo(2);
        } finally {
            InstallUtils.dropShellPermissionIdentity();
            if (crashCountReceiver != null) {
                context.unregisterReceiver(crashCountReceiver);
            }
        }
    }

+3 −13
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static org.junit.Assert.fail;

import android.Manifest;
import android.annotation.Nullable;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -77,7 +76,7 @@ public class StagedRollbackTest {
                Manifest.permission.INSTALL_PACKAGES,
                Manifest.permission.DELETE_PACKAGES,
                Manifest.permission.TEST_MANAGE_ROLLBACKS,
                Manifest.permission.KILL_BACKGROUND_PROCESSES);
                Manifest.permission.FORCE_STOP_PACKAGES);
    }

    /**
@@ -135,17 +134,8 @@ public class StagedRollbackTest {
     */
    @Test
    public void testBadApkOnlyTriggerRollback() throws Exception {
        BroadcastReceiver crashCountReceiver = null;
        Context context = InstrumentationRegistry.getContext();

        try {
        // Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback
            crashCountReceiver = RollbackUtils.sendCrashBroadcast(context, TestApp.A, 5);
        } finally {
            if (crashCountReceiver != null) {
                context.unregisterReceiver(crashCountReceiver);
            }
        }
        RollbackUtils.sendCrashBroadcast(TestApp.A, 5);

        // We expect the device to be rebooted automatically. Wait for that to
        // happen. At that point, the host test driver will wait for the