Merge "Fix a outer loop iterates on item that is removed by inner loop problem." into udc-dev
This commit is contained in:
@@ -522,6 +522,7 @@ public final class ActiveServices {
|
|||||||
final ArrayList<ServiceRecord> mStartingBackground = new ArrayList<>();
|
final ArrayList<ServiceRecord> mStartingBackground = new ArrayList<>();
|
||||||
|
|
||||||
final ArrayMap<String, ActiveForegroundApp> mActiveForegroundApps = new ArrayMap<>();
|
final ArrayMap<String, ActiveForegroundApp> mActiveForegroundApps = new ArrayMap<>();
|
||||||
|
final ArrayList<String> mPendingRemoveForegroundApps = new ArrayList<>();
|
||||||
|
|
||||||
boolean mActiveForegroundAppsChanged;
|
boolean mActiveForegroundAppsChanged;
|
||||||
|
|
||||||
@@ -1687,13 +1688,14 @@ public final class ActiveServices {
|
|||||||
if (smap != null) {
|
if (smap != null) {
|
||||||
if (DEBUG_FOREGROUND_SERVICE) Slog.d(TAG, "Updating foreground apps for user "
|
if (DEBUG_FOREGROUND_SERVICE) Slog.d(TAG, "Updating foreground apps for user "
|
||||||
+ smap.mUserId);
|
+ smap.mUserId);
|
||||||
|
smap.mPendingRemoveForegroundApps.clear();
|
||||||
for (int i = smap.mActiveForegroundApps.size()-1; i >= 0; i--) {
|
for (int i = smap.mActiveForegroundApps.size()-1; i >= 0; i--) {
|
||||||
ActiveForegroundApp aa = smap.mActiveForegroundApps.valueAt(i);
|
ActiveForegroundApp aa = smap.mActiveForegroundApps.valueAt(i);
|
||||||
if (aa.mEndTime != 0) {
|
if (aa.mEndTime != 0) {
|
||||||
boolean canRemove = foregroundAppShownEnoughLocked(aa, now);
|
boolean canRemove = foregroundAppShownEnoughLocked(aa, now);
|
||||||
if (canRemove) {
|
if (canRemove) {
|
||||||
// This was up for longer than the timeout, so just remove immediately.
|
// This was up for longer than the timeout, so just remove immediately.
|
||||||
smap.mActiveForegroundApps.removeAt(i);
|
smap.mPendingRemoveForegroundApps.add(smap.mActiveForegroundApps.keyAt(i));
|
||||||
smap.mActiveForegroundAppsChanged = true;
|
smap.mActiveForegroundAppsChanged = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1718,6 +1720,9 @@ public final class ActiveServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(int i = smap.mPendingRemoveForegroundApps.size() - 1; i >= 0; i--) {
|
||||||
|
smap.mActiveForegroundApps.remove(smap.mPendingRemoveForegroundApps.get(i));
|
||||||
|
}
|
||||||
smap.removeMessages(ServiceMap.MSG_UPDATE_FOREGROUND_APPS);
|
smap.removeMessages(ServiceMap.MSG_UPDATE_FOREGROUND_APPS);
|
||||||
if (nextUpdateTime < Long.MAX_VALUE) {
|
if (nextUpdateTime < Long.MAX_VALUE) {
|
||||||
if (DEBUG_FOREGROUND_SERVICE) Slog.d(TAG, "Next update time in: "
|
if (DEBUG_FOREGROUND_SERVICE) Slog.d(TAG, "Next update time in: "
|
||||||
|
|||||||
Reference in New Issue
Block a user