Skip to content

Commit f10a536

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Maybe fix issue #5405788: Device continuously opening and closing..." into ics-mr1
2 parents d8f5e6b + 813075a commit f10a536

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

services/java/com/android/server/am/ActivityManagerService.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ private ActivityManagerService() {
14791479

14801480
mConfiguration.setToDefaults();
14811481
mConfiguration.locale = Locale.getDefault();
1482+
mConfigurationSeq = mConfiguration.seq = 1;
14821483
mProcessStats.init();
14831484

14841485
mCompatModePackages = new CompatModePackages(this, systemDir);
@@ -2436,7 +2437,7 @@ public void setRequestedOrientation(IBinder token,
24362437
r.mayFreezeScreenLocked(r.app) ? r.appToken : null);
24372438
if (config != null) {
24382439
r.frozenBeforeDestroy = true;
2439-
if (!updateConfigurationLocked(config, r, false)) {
2440+
if (!updateConfigurationLocked(config, r, false, false)) {
24402441
mMainStack.resumeTopActivityLocked(null);
24412442
}
24422443
}
@@ -3797,7 +3798,7 @@ private final boolean attachApplicationLocked(IApplicationThread thread,
37973798
app.instrumentationClass, profileFile, profileFd, profileAutoStop,
37983799
app.instrumentationArguments, app.instrumentationWatcher, testMode,
37993800
isRestrictedBackupMode || !normalMode, app.persistent,
3800-
mConfiguration, app.compat, getCommonServicesLocked(),
3801+
new Configuration(mConfiguration), app.compat, getCommonServicesLocked(),
38013802
mCoreSettingsObserver.getCoreSettingsLocked());
38023803
updateLruProcessLocked(app, false, true);
38033804
app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis();
@@ -6707,8 +6708,7 @@ private void retrieveSettings() {
67076708
mAlwaysFinishActivities = alwaysFinishActivities;
67086709
// This happens before any activities are started, so we can
67096710
// change mConfiguration in-place.
6710-
mConfiguration.updateFrom(configuration);
6711-
mConfigurationSeq = mConfiguration.seq = 1;
6711+
updateConfigurationLocked(configuration, null, false, true);
67126712
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Initial config: " + mConfiguration);
67136713
}
67146714
}
@@ -12934,7 +12934,7 @@ public void updatePersistentConfiguration(Configuration values) {
1293412934

1293512935
synchronized(this) {
1293612936
final long origId = Binder.clearCallingIdentity();
12937-
updateConfigurationLocked(values, null, true);
12937+
updateConfigurationLocked(values, null, true, false);
1293812938
Binder.restoreCallingIdentity(origId);
1293912939
}
1294012940
}
@@ -12957,7 +12957,7 @@ public void updateConfiguration(Configuration values) {
1295712957
if (values != null) {
1295812958
Settings.System.clearConfiguration(values);
1295912959
}
12960-
updateConfigurationLocked(values, null, false);
12960+
updateConfigurationLocked(values, null, false, false);
1296112961
Binder.restoreCallingIdentity(origId);
1296212962
}
1296312963
}
@@ -12971,7 +12971,7 @@ public void updateConfiguration(Configuration values) {
1297112971
* @param persistent TODO
1297212972
*/
1297312973
public boolean updateConfigurationLocked(Configuration values,
12974-
ActivityRecord starting, boolean persistent) {
12974+
ActivityRecord starting, boolean persistent, boolean initLocale) {
1297512975
int changes = 0;
1297612976

1297712977
boolean kept = true;
@@ -12986,7 +12986,7 @@ public boolean updateConfigurationLocked(Configuration values,
1298612986

1298712987
EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
1298812988

12989-
if (values.locale != null) {
12989+
if (values.locale != null && !initLocale) {
1299012990
saveLocaleLocked(values.locale,
1299112991
!values.locale.equals(mConfiguration.locale),
1299212992
values.userSetLocale);
@@ -12999,10 +12999,12 @@ public boolean updateConfigurationLocked(Configuration values,
1299912999
newConfig.seq = mConfigurationSeq;
1300013000
mConfiguration = newConfig;
1300113001
Slog.i(TAG, "Config changed: " + newConfig);
13002-
13002+
13003+
final Configuration configCopy = new Configuration(mConfiguration);
13004+
1300313005
AttributeCache ac = AttributeCache.instance();
1300413006
if (ac != null) {
13005-
ac.updateConfiguration(mConfiguration);
13007+
ac.updateConfiguration(configCopy);
1300613008
}
1300713009

1300813010
// Make sure all resources in our process are updated
@@ -13012,11 +13014,11 @@ public boolean updateConfigurationLocked(Configuration values,
1301213014
// boot, where the first config change needs to guarantee
1301313015
// all resources have that config before following boot
1301413016
// code is executed.
13015-
mSystemThread.applyConfigurationToResources(newConfig);
13017+
mSystemThread.applyConfigurationToResources(configCopy);
1301613018

1301713019
if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
1301813020
Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
13019-
msg.obj = new Configuration(mConfiguration);
13021+
msg.obj = new Configuration(configCopy);
1302013022
mHandler.sendMessage(msg);
1302113023
}
1302213024

@@ -13026,7 +13028,7 @@ public boolean updateConfigurationLocked(Configuration values,
1302613028
if (app.thread != null) {
1302713029
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc "
1302813030
+ app.processName + " new config " + mConfiguration);
13029-
app.thread.scheduleConfigurationChanged(mConfiguration);
13031+
app.thread.scheduleConfigurationChanged(configCopy);
1303013032
}
1303113033
} catch (Exception e) {
1303213034
}

services/java/com/android/server/am/ActivityStack.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ final boolean realStartActivityLocked(ActivityRecord r,
528528
Configuration config = mService.mWindowManager.updateOrientationFromAppTokens(
529529
mService.mConfiguration,
530530
r.mayFreezeScreenLocked(app) ? r.appToken : null);
531-
mService.updateConfigurationLocked(config, r, false);
531+
mService.updateConfigurationLocked(config, r, false, false);
532532
}
533533

534534
r.app = app;
@@ -590,7 +590,8 @@ final boolean realStartActivityLocked(ActivityRecord r,
590590
}
591591
}
592592
app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken,
593-
System.identityHashCode(r), r.info, mService.mConfiguration,
593+
System.identityHashCode(r), r.info,
594+
new Configuration(mService.mConfiguration),
594595
r.compat, r.icicle, results, newIntents, !andResume,
595596
mService.isNextTransitionForward(), profileFile, profileFd,
596597
profileAutoStop);
@@ -1460,7 +1461,7 @@ final boolean resumeTopActivityLocked(ActivityRecord prev) {
14601461
if (config != null) {
14611462
next.frozenBeforeDestroy = true;
14621463
}
1463-
updated = mService.updateConfigurationLocked(config, next, false);
1464+
updated = mService.updateConfigurationLocked(config, next, false, false);
14641465
}
14651466
}
14661467
if (!updated) {
@@ -2917,7 +2918,7 @@ final int startActivityMayWait(IApplicationThread caller, int callingUid,
29172918
mConfigWillChange = false;
29182919
if (DEBUG_CONFIGURATION) Slog.v(TAG,
29192920
"Updating to new configuration after starting activity.");
2920-
mService.updateConfigurationLocked(config, null, false);
2921+
mService.updateConfigurationLocked(config, null, false, false);
29212922
}
29222923

29232924
Binder.restoreCallingIdentity(origId);
@@ -4190,7 +4191,7 @@ private final boolean relaunchActivityLocked(ActivityRecord r,
41904191
if (DEBUG_SWITCH) Slog.i(TAG, "Switch is restarting resumed " + r);
41914192
r.forceNewConfig = false;
41924193
r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents,
4193-
changes, !andResume, mService.mConfiguration);
4194+
changes, !andResume, new Configuration(mService.mConfiguration));
41944195
// Note: don't need to call pauseIfSleepingLocked() here, because
41954196
// the caller will only pass in 'andResume' if this activity is
41964197
// currently resumed, which implies we aren't sleeping.

0 commit comments

Comments
 (0)