Don't call onDied() explicitly in MicrodroidTests
This is bad use of the API and isn't needed by any of the tests so get rid
of it. VM will call onDied() when it stop the VM anyway, should a test
need to wait for that (pending b/195765441 for cuttlefish, but we skip
all but one test because of that already). When the test sees onDied()
it lets the test continue as there's no more VM to wait for.
Bug: 220700986
Test: atest MicrodroidTests
Change-Id: I1266f210b960100ebba3ced4d33c9bdd72352575
diff --git a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
index c7bb011..14ea402 100644
--- a/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
+++ b/tests/testapk/src/java/com/android/microdroid/test/MicrodroidTests.java
@@ -142,7 +142,12 @@
}
void forceStop(VirtualMachine vm) {
- this.onDied(vm, VirtualMachineCallback.DEATH_REASON_KILLED);
+ try {
+ vm.stop();
+ mExecutorService.shutdown();
+ } catch (VirtualMachineException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
@@ -160,12 +165,7 @@
@Override
@CallSuper
public void onDied(VirtualMachine vm, @DeathReason int reason) {
- try {
- vm.stop();
- mExecutorService.shutdown();
- } catch (VirtualMachineException e) {
- throw new RuntimeException(e);
- }
+ mExecutorService.shutdown();
}
}