int eventCounter = 0;
int cycleCounter = 0;
+ boolean shouldReportAnrTraces = false;
+ boolean shouldReportDumpsysMemInfo = false;
+ boolean shouldAbort = false;
boolean systemCrashed = false;
while (!systemCrashed && cycleCounter < mCount) {
mRequestProcRank = false;
}
if (mRequestAnrTraces) {
- reportAnrTraces();
mRequestAnrTraces = false;
+ shouldReportAnrTraces = true;
}
if (mRequestDumpsysMemInfo) {
- reportDumpsysMemInfo();
mRequestDumpsysMemInfo = false;
+ shouldReportDumpsysMemInfo = true;
}
if (mMonitorNativeCrashes) {
// first time through, when eventCounter == 0, just set up
}
}
if (mAbort) {
- System.out.println("** Monkey aborted due to error.");
- System.out.println("Events injected: " + eventCounter);
- return eventCounter;
+ shouldAbort = true;
}
}
+ // Report ANR, dumpsys after releasing lock on this.
+ // This ensures the availability of the lock to Activity controller's appNotResponding
+ if (shouldReportAnrTraces) {
+ shouldReportAnrTraces = false;
+ reportAnrTraces();
+ }
+
+ if (shouldReportDumpsysMemInfo) {
+ shouldReportDumpsysMemInfo = false;
+ reportDumpsysMemInfo();
+ }
+
+ if (shouldAbort) {
+ shouldAbort = false;
+ System.out.println("** Monkey aborted due to error.");
+ System.out.println("Events injected: " + eventCounter);
+ return eventCounter;
+ }
+
// In this debugging mode, we never send any events. This is
// primarily here so you can manually test the package or category
// limits, while manually exercising the system.