diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java index 78632206e..d34c3132e 100644 --- a/apps/Development/src/com/android/development/BadBehaviorActivity.java +++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java @@ -107,6 +107,10 @@ public class BadBehaviorActivity extends Activity { public int appNotResponding(String proc, int pid, String st) { return 0; } + + public int systemNotResponding(String message) { + return 0; + } } @Override diff --git a/cmds/monkey/src/com/android/commands/monkey/Monkey.java b/cmds/monkey/src/com/android/commands/monkey/Monkey.java index 5e86a79c8..a2655e159 100644 --- a/cmds/monkey/src/com/android/commands/monkey/Monkey.java +++ b/cmds/monkey/src/com/android/commands/monkey/Monkey.java @@ -132,6 +132,18 @@ public class Monkey { */ private boolean mRequestAnrBugreport = false; + /** + * This is set by the ActivityController thread to request a + * bugreport after a system watchdog report + */ + private boolean mRequestWatchdogBugreport = false; + + /** + * Synchronization for the ActivityController callback to block + * until we are done handling the reporting of the watchdog error. + */ + private boolean mWatchdogWaiting = false; + /** * This is set by the ActivityController thread to request a * bugreport after java application crash @@ -355,6 +367,31 @@ public class Monkey { } return (mKillProcessAfterError) ? -1 : 1; } + + public int systemNotResponding(String message) { + StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskWrites(); + System.err.println("// WATCHDOG: " + message); + StrictMode.setThreadPolicy(savedPolicy); + + synchronized (Monkey.this) { + if (!mIgnoreCrashes) { + mAbort = true; + } + if (mRequestBugreport) { + mRequestWatchdogBugreport = true; + } + mWatchdogWaiting = true; + } + synchronized (Monkey.this) { + while (mWatchdogWaiting) { + try { + Monkey.this.wait(); + } catch (InterruptedException e) { + } + } + } + return (mKillProcessAfterError) ? -1 : 1; + } } /** @@ -635,6 +672,11 @@ public class Monkey { getBugreport("anr_" + mReportProcessName + "_"); mRequestAnrBugreport = false; } + if (mRequestWatchdogBugreport) { + System.out.println("Print the watchdog report"); + getBugreport("anr_watchdog_"); + mRequestWatchdogBugreport = false; + } if (mRequestAppCrashBugreport){ getBugreport("app_crash" + mReportProcessName + "_"); mRequestAppCrashBugreport = false; @@ -647,6 +689,10 @@ public class Monkey { getBugreport("Bugreport_"); mRequestPeriodicBugreport = false; } + if (mWatchdogWaiting) { + mWatchdogWaiting = false; + notifyAll(); + } } if (mGenerateHprof) { @@ -1027,6 +1073,11 @@ public class Monkey { getBugreport("anr_" + mReportProcessName + "_"); mRequestAnrBugreport = false; } + if (mRequestWatchdogBugreport) { + System.out.println("Print the watchdog report"); + getBugreport("anr_watchdog_"); + mRequestWatchdogBugreport = false; + } if (mRequestAppCrashBugreport){ getBugreport("app_crash" + mReportProcessName + "_"); mRequestAppCrashBugreport = false; @@ -1053,6 +1104,10 @@ public class Monkey { if (mAbort) { shouldAbort = true; } + if (mWatchdogWaiting) { + mWatchdogWaiting = false; + notifyAll(); + } } // Report ANR, dumpsys after releasing lock on this.