Merge "Update to new RollbackUtils.sendCrashBroadcast API."

This commit is contained in:
TreeHugger Robot
2019-08-16 11:08:59 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 19 deletions

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
// Crash TestApp.A PackageWatchdog#TRIGGER_FAILURE_COUNT times to trigger rollback
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