diff options
| author | 2019-08-15 10:54:00 +0100 | |
|---|---|---|
| committer | 2019-08-16 09:03:02 +0100 | |
| commit | 0c03aaae84e5536593526d3d3dfab17b0175654a (patch) | |
| tree | 8b10491e360fb79b49963b8550adcfd2a2c78656 | |
| parent | ae26d1ebf9b06cd0c8f93de57a9c246f76c8d371 (diff) | |
Update to new RollbackUtils.sendCrashBroadcast API.
Bug: 139108668
Test: atest StagedRollbackTest:com.android.tests.rollback.host.StagedRollbackTest#testBadApkOnly
2
Change-Id: Iaaa728aa58d894ba546677e8295faba2ebfc5e64
| -rw-r--r-- | tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java | 8 | ||||
| -rw-r--r-- | tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java | 16 |
2 files changed, 5 insertions, 19 deletions
diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java index 2c0432aeed50..720c1af906ff 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/RollbackTest.java @@ -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); - } } } diff --git a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java index db8183124f59..9e6ac8ef679b 100644 --- a/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java +++ b/tests/RollbackTest/RollbackTest/src/com/android/tests/rollback/StagedRollbackTest.java @@ -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 |