diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 81d87659cbcbb..67ecf5b319833 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3638,39 +3638,45 @@ public final class ActivityThread { } } - ArrayList collectComponentCallbacksLocked( + ArrayList collectComponentCallbacks( boolean allActivities, Configuration newConfig) { ArrayList callbacks = new ArrayList(); - if (mActivities.size() > 0) { - for (ActivityClientRecord ar : mActivities.values()) { - Activity a = ar.activity; - if (a != null) { - Configuration thisConfig = applyConfigCompatMainThread(mCurDefaultDisplayDpi, - newConfig, ar.packageInfo.mCompatibilityInfo.getIfNeeded()); - if (!ar.activity.mFinished && (allActivities || !ar.paused)) { - // If the activity is currently resumed, its configuration - // needs to change right now. - callbacks.add(a); - } else if (thisConfig != null) { - // Otherwise, we will tell it about the change - // the next time it is resumed or shown. Note that - // the activity manager may, before then, decide the - // activity needs to be destroyed to handle its new - // configuration. - if (DEBUG_CONFIGURATION) { - Slog.v(TAG, "Setting activity " - + ar.activityInfo.name + " newConfig=" + thisConfig); + synchronized (mPackages) { + final int N = mAllApplications.size(); + for (int i=0; i 0) { + for (ActivityClientRecord ar : mActivities.values()) { + Activity a = ar.activity; + if (a != null) { + Configuration thisConfig = applyConfigCompatMainThread(mCurDefaultDisplayDpi, + newConfig, ar.packageInfo.mCompatibilityInfo.getIfNeeded()); + if (!ar.activity.mFinished && (allActivities || !ar.paused)) { + // If the activity is currently resumed, its configuration + // needs to change right now. + callbacks.add(a); + } else if (thisConfig != null) { + // Otherwise, we will tell it about the change + // the next time it is resumed or shown. Note that + // the activity manager may, before then, decide the + // activity needs to be destroyed to handle its new + // configuration. + if (DEBUG_CONFIGURATION) { + Slog.v(TAG, "Setting activity " + + ar.activityInfo.name + " newConfig=" + thisConfig); + } + ar.newConfig = thisConfig; } - ar.newConfig = thisConfig; } } } - } - if (mServices.size() > 0) { - for (Service service : mServices.values()) { - callbacks.add(service); + if (mServices.size() > 0) { + for (Service service : mServices.values()) { + callbacks.add(service); + } } } synchronized (mProviderMap) { @@ -3680,10 +3686,6 @@ public final class ActivityThread { } } } - final int N = mAllApplications.size(); - for (int i=0; i callbacks = null; int configDiff = 0; synchronized (mPackages) { @@ -3875,9 +3876,10 @@ public final class ActivityThread { configDiff = mConfiguration.diff(config); mConfiguration.updateFrom(config); config = applyCompatConfiguration(mCurDefaultDisplayDpi); - callbacks = collectComponentCallbacksLocked(false, config); } - + + ArrayList callbacks = collectComponentCallbacks(false, config); + // Cleanup hardware accelerated stuff WindowManagerGlobal.getInstance().trimLocalMemory(); @@ -3990,11 +3992,7 @@ public final class ActivityThread { } final void handleLowMemory() { - ArrayList callbacks; - - synchronized (mPackages) { - callbacks = collectComponentCallbacksLocked(true, null); - } + ArrayList callbacks = collectComponentCallbacks(true, null); final int N = callbacks.size(); for (int i=0; i callbacks; - synchronized (mPackages) { - callbacks = collectComponentCallbacksLocked(true, null); - } + ArrayList callbacks = collectComponentCallbacks(true, null); final int N = callbacks.size(); for (int i = 0; i < N; i++) {