Fix system watchdog timeout when reading too many usage events.

Symptom:
As issue link:
https://code.google.com/p/android/issues/detail?id=193100

RootCause:
UsageStatsService.onDisplayChanged executed in system main thread,
If calling UsageStatsManager.queryEvents with too many events before it
(i.e. in daily usage event file,
too many activity resume / pause events or configuration change
during monkey test),
System will be blocked then watchdog timeout.

Solution:
Let display listener executed in background thread handler

Change-Id: Ic894d112612400ed8fb7ba843b3309fdc4f66fe1
This commit is contained in:
Mark Lu
2015-11-06 15:26:15 +08:00
parent 7abb36599d
commit 4e59db328d

View File

@@ -218,7 +218,7 @@ public class UsageStatsService extends SystemService implements
synchronized (this) {
mScreenOnTime = readScreenOnTimeLocked();
}
mDisplayManager.registerDisplayListener(mDisplayListener, null);
mDisplayManager.registerDisplayListener(mDisplayListener, mHandler);
synchronized (this) {
updateDisplayLocked();
}