Fix ActivityManagerAppExitInfoTest#testAnr Failure

Handle the unexpected crash as well within the app controller.

Bug: 153513514
Test: Manual - induce another crash in within this CTS test case
Change-Id: I5fd7e595e01bf9320b8b9583e9a3233d5a9a7a2a
diff --git a/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java b/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
index 6b11ba6..c49e89a 100644
--- a/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
+++ b/tests/app/AppExitTest/src/android/app/cts/ActivityManagerAppExitInfoTest.java
@@ -1145,6 +1145,7 @@
     private static class Monitor {
         static final String WAIT_FOR_EARLY_ANR = "Waiting after early ANR...  available commands:";
         static final String WAIT_FOR_ANR = "Waiting after ANR...  available commands:";
+        static final String WAIT_FOR_CRASHED = "Waiting after crash...  available commands:";
         static final String CMD_CONTINUE = "c";
         static final String CMD_KILL = "k";
 
@@ -1194,6 +1195,13 @@
                     String line = mPendingLines.remove(0);
                     if (TextUtils.equals(line, expected)) {
                         break;
+                    } else if (TextUtils.equals(line, WAIT_FOR_EARLY_ANR)
+                            || TextUtils.equals(line, WAIT_FOR_ANR)
+                            || TextUtils.equals(line, WAIT_FOR_CRASHED)) {
+                        // If we are getting any of the unexpected state,
+                        // for example, get a crash while waiting for an ANR,
+                        // it could be from another unrelated process, kill it directly.
+                        sendCommand(CMD_KILL);
                     }
                 }
             }