Debugging help for issue #8734824: WATCHDOG KILLING SYSTEM PROCESS
The monkey now gets told about system hangs, and does stuff about it! Most especially, it can collect a bug report. Monkey wins! Change-Id: Ic8350721e715ef21d1ec813c6aff9a83262d5faa
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user