requestPssAllProcsLocked(now, false, mProcessStats.isMemFactorLowered());
}
+ ArrayList<UidRecord> becameIdle = null;
+
// Update from any uid changes.
if (mLocalPowerManager != null) {
mLocalPowerManager.startUidChanges();
}
if (uidRec.idle && !uidRec.setIdle) {
uidChange = UidRecord.CHANGE_IDLE;
+ if (becameIdle == null) {
+ becameIdle = new ArrayList<>();
+ }
+ becameIdle.add(uidRec);
}
} else {
if (uidRec.idle) {
mLocalPowerManager.finishUidChanges();
}
+ if (becameIdle != null) {
+ // If we have any new uids that became idle this time, we need to make sure
+ // they aren't left with running services.
+ for (int i = becameIdle.size() - 1; i >= 0; i--) {
+ mServices.stopInBackgroundLocked(becameIdle.get(i).uid);
+ }
+ }
+
if (mProcessStats.shouldWriteNowLocked(now)) {
mHandler.post(new Runnable() {
@Override public void run() {