Skip to content

Commit e6f6380

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #7196015: system_server deadlock during setup wizard" into jb-mr1-dev
2 parents 314488b + 73c1416 commit e6f6380

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,39 +3638,45 @@ private void handleRequestThumbnail(IBinder token) {
36383638
}
36393639
}
36403640

3641-
ArrayList<ComponentCallbacks2> collectComponentCallbacksLocked(
3641+
ArrayList<ComponentCallbacks2> collectComponentCallbacks(
36423642
boolean allActivities, Configuration newConfig) {
36433643
ArrayList<ComponentCallbacks2> callbacks
36443644
= new ArrayList<ComponentCallbacks2>();
36453645

3646-
if (mActivities.size() > 0) {
3647-
for (ActivityClientRecord ar : mActivities.values()) {
3648-
Activity a = ar.activity;
3649-
if (a != null) {
3650-
Configuration thisConfig = applyConfigCompatMainThread(mCurDefaultDisplayDpi,
3651-
newConfig, ar.packageInfo.mCompatibilityInfo.getIfNeeded());
3652-
if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
3653-
// If the activity is currently resumed, its configuration
3654-
// needs to change right now.
3655-
callbacks.add(a);
3656-
} else if (thisConfig != null) {
3657-
// Otherwise, we will tell it about the change
3658-
// the next time it is resumed or shown. Note that
3659-
// the activity manager may, before then, decide the
3660-
// activity needs to be destroyed to handle its new
3661-
// configuration.
3662-
if (DEBUG_CONFIGURATION) {
3663-
Slog.v(TAG, "Setting activity "
3664-
+ ar.activityInfo.name + " newConfig=" + thisConfig);
3646+
synchronized (mPackages) {
3647+
final int N = mAllApplications.size();
3648+
for (int i=0; i<N; i++) {
3649+
callbacks.add(mAllApplications.get(i));
3650+
}
3651+
if (mActivities.size() > 0) {
3652+
for (ActivityClientRecord ar : mActivities.values()) {
3653+
Activity a = ar.activity;
3654+
if (a != null) {
3655+
Configuration thisConfig = applyConfigCompatMainThread(mCurDefaultDisplayDpi,
3656+
newConfig, ar.packageInfo.mCompatibilityInfo.getIfNeeded());
3657+
if (!ar.activity.mFinished && (allActivities || !ar.paused)) {
3658+
// If the activity is currently resumed, its configuration
3659+
// needs to change right now.
3660+
callbacks.add(a);
3661+
} else if (thisConfig != null) {
3662+
// Otherwise, we will tell it about the change
3663+
// the next time it is resumed or shown. Note that
3664+
// the activity manager may, before then, decide the
3665+
// activity needs to be destroyed to handle its new
3666+
// configuration.
3667+
if (DEBUG_CONFIGURATION) {
3668+
Slog.v(TAG, "Setting activity "
3669+
+ ar.activityInfo.name + " newConfig=" + thisConfig);
3670+
}
3671+
ar.newConfig = thisConfig;
36653672
}
3666-
ar.newConfig = thisConfig;
36673673
}
36683674
}
36693675
}
3670-
}
3671-
if (mServices.size() > 0) {
3672-
for (Service service : mServices.values()) {
3673-
callbacks.add(service);
3676+
if (mServices.size() > 0) {
3677+
for (Service service : mServices.values()) {
3678+
callbacks.add(service);
3679+
}
36743680
}
36753681
}
36763682
synchronized (mProviderMap) {
@@ -3680,10 +3686,6 @@ ArrayList<ComponentCallbacks2> collectComponentCallbacksLocked(
36803686
}
36813687
}
36823688
}
3683-
final int N = mAllApplications.size();
3684-
for (int i=0; i<N; i++) {
3685-
callbacks.add(mAllApplications.get(i));
3686-
}
36873689

36883690
return callbacks;
36893691
}
@@ -3844,7 +3846,6 @@ final Configuration applyCompatConfiguration(int displayDensity) {
38443846

38453847
final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {
38463848

3847-
ArrayList<ComponentCallbacks2> callbacks = null;
38483849
int configDiff = 0;
38493850

38503851
synchronized (mPackages) {
@@ -3875,9 +3876,10 @@ final void handleConfigurationChanged(Configuration config, CompatibilityInfo co
38753876
configDiff = mConfiguration.diff(config);
38763877
mConfiguration.updateFrom(config);
38773878
config = applyCompatConfiguration(mCurDefaultDisplayDpi);
3878-
callbacks = collectComponentCallbacksLocked(false, config);
38793879
}
3880-
3880+
3881+
ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config);
3882+
38813883
// Cleanup hardware accelerated stuff
38823884
WindowManagerGlobal.getInstance().trimLocalMemory();
38833885

@@ -3990,11 +3992,7 @@ final void handleDispatchPackageBroadcast(int cmd, String[] packages) {
39903992
}
39913993

39923994
final void handleLowMemory() {
3993-
ArrayList<ComponentCallbacks2> callbacks;
3994-
3995-
synchronized (mPackages) {
3996-
callbacks = collectComponentCallbacksLocked(true, null);
3997-
}
3995+
ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(true, null);
39983996

39993997
final int N = callbacks.size();
40003998
for (int i=0; i<N; i++) {
@@ -4022,10 +4020,7 @@ final void handleTrimMemory(int level) {
40224020
final WindowManagerGlobal windowManager = WindowManagerGlobal.getInstance();
40234021
windowManager.startTrimMemory(level);
40244022

4025-
ArrayList<ComponentCallbacks2> callbacks;
4026-
synchronized (mPackages) {
4027-
callbacks = collectComponentCallbacksLocked(true, null);
4028-
}
4023+
ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(true, null);
40294024

40304025
final int N = callbacks.size();
40314026
for (int i = 0; i < N; i++) {

0 commit comments

Comments
 (0)