Move potentially blocking operation out of the activity controller.

http://b/viewIssue?id=2497953
before this CL, call to reportProcRank() in the controller waited for the
procrank process to finish, which potentially would block the activity
manager and cause deadlock between the activity manager and the window manager.

Change-Id: Ie5a6aae7c8dbe43ac725abdb04f2426f54dd6740
diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
index ff2a587..af8ca95 100644
--- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java
+++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java
@@ -118,6 +118,11 @@
      */
     private boolean mRequestDumpsysMemInfo = false;
 
+    /**
+     * This is set by the ActivityController thread to request a "procrank"
+     */
+    private boolean mRequestProcRank = false;
+
     /** Kill the process after a timeout or crash. */
     private boolean mKillProcessAfterError;
 
@@ -261,10 +266,10 @@
         public int appNotResponding(String processName, int pid, String processStats) {
             System.err.println("// NOT RESPONDING: " + processName + " (pid " + pid + ")");
             System.err.println(processStats);
-            reportProcRank();
             synchronized (Monkey.this) {
                 mRequestAnrTraces = true;
                 mRequestDumpsysMemInfo = true;
+                mRequestProcRank = true;
             }
             if (!mIgnoreTimeouts) {
                 synchronized (Monkey.this) {
@@ -852,6 +857,10 @@
 
         while (!systemCrashed && cycleCounter < mCount) {
             synchronized (this) {
+                if (mRequestProcRank) {
+                    reportProcRank();
+                    mRequestProcRank = false;
+                }
                 if (mRequestAnrTraces) {
                     reportAnrTraces();
                     mRequestAnrTraces = false;