Skip to content

Commit 260fdd3

Browse files
Dianne HackbornThe Android Automerger
authored andcommitted
DO NOT MERGE. Integrate from MR 1 to fix issue #5366535: Lockscreen...
...has wrong layout but corrects itself Maybe fix issue #5405788: Device continuously opening and closing... ...the "Complete action using" dialog I have never been able to reproduce this consistently, but here is another stab in the twilight. It looks like during boot we have a potential race where we could reset the config sequence number after we had gone through a config change, causing ActivityThread to ignore a following config change. Maybe this change will help. Change-Id: I7199b6de370488e8d897d6a78ff6f15624da862c
1 parent 81cab17 commit 260fdd3

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
@@ -1451,6 +1451,7 @@ private ActivityManagerService() {
14511451

14521452
mConfiguration.setToDefaults();
14531453
mConfiguration.locale = Locale.getDefault();
1454+
mConfigurationSeq = mConfiguration.seq = 1;
14541455
mProcessStats.init();
14551456

14561457
mCompatModePackages = new CompatModePackages(this, systemDir);
@@ -2407,7 +2408,7 @@ public void setRequestedOrientation(IBinder token,
24072408
r.mayFreezeScreenLocked(r.app) ? r : null);
24082409
if (config != null) {
24092410
r.frozenBeforeDestroy = true;
2410-
if (!updateConfigurationLocked(config, r, false)) {
2411+
if (!updateConfigurationLocked(config, r, false, false)) {
24112412
mMainStack.resumeTopActivityLocked(null);
24122413
}
24132414
}
@@ -3724,7 +3725,7 @@ private final boolean attachApplicationLocked(IApplicationThread thread,
37243725
app.instrumentationClass, profileFile, profileFd, profileAutoStop,
37253726
app.instrumentationArguments, app.instrumentationWatcher, testMode,
37263727
isRestrictedBackupMode || !normalMode, app.persistent,
3727-
mConfiguration, app.compat, getCommonServicesLocked(),
3728+
new Configuration(mConfiguration), app.compat, getCommonServicesLocked(),
37283729
mCoreSettingsObserver.getCoreSettingsLocked());
37293730
updateLruProcessLocked(app, false, true);
37303731
app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis();
@@ -6633,8 +6634,7 @@ private void retrieveSettings() {
66336634
mAlwaysFinishActivities = alwaysFinishActivities;
66346635
// This happens before any activities are started, so we can
66356636
// change mConfiguration in-place.
6636-
mConfiguration.updateFrom(configuration);
6637-
mConfigurationSeq = mConfiguration.seq = 1;
6637+
updateConfigurationLocked(configuration, null, false, true);
66386638
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Initial config: " + mConfiguration);
66396639
}
66406640
}
@@ -12838,7 +12838,7 @@ public void updatePersistentConfiguration(Configuration values) {
1283812838

1283912839
synchronized(this) {
1284012840
final long origId = Binder.clearCallingIdentity();
12841-
updateConfigurationLocked(values, null, true);
12841+
updateConfigurationLocked(values, null, true, false);
1284212842
Binder.restoreCallingIdentity(origId);
1284312843
}
1284412844
}
@@ -12861,7 +12861,7 @@ public void updateConfiguration(Configuration values) {
1286112861
if (values != null) {
1286212862
Settings.System.clearConfiguration(values);
1286312863
}
12864-
updateConfigurationLocked(values, null, false);
12864+
updateConfigurationLocked(values, null, false, false);
1286512865
Binder.restoreCallingIdentity(origId);
1286612866
}
1286712867
}
@@ -12875,7 +12875,7 @@ public void updateConfiguration(Configuration values) {
1287512875
* @param persistent TODO
1287612876
*/
1287712877
public boolean updateConfigurationLocked(Configuration values,
12878-
ActivityRecord starting, boolean persistent) {
12878+
ActivityRecord starting, boolean persistent, boolean initLocale) {
1287912879
int changes = 0;
1288012880

1288112881
boolean kept = true;
@@ -12890,7 +12890,7 @@ public boolean updateConfigurationLocked(Configuration values,
1289012890

1289112891
EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
1289212892

12893-
if (values.locale != null) {
12893+
if (values.locale != null && !initLocale) {
1289412894
saveLocaleLocked(values.locale,
1289512895
!values.locale.equals(mConfiguration.locale),
1289612896
values.userSetLocale);
@@ -12903,10 +12903,12 @@ public boolean updateConfigurationLocked(Configuration values,
1290312903
newConfig.seq = mConfigurationSeq;
1290412904
mConfiguration = newConfig;
1290512905
Slog.i(TAG, "Config changed: " + newConfig);
12906-
12906+
12907+
final Configuration configCopy = new Configuration(mConfiguration);
12908+
1290712909
AttributeCache ac = AttributeCache.instance();
1290812910
if (ac != null) {
12909-
ac.updateConfiguration(mConfiguration);
12911+
ac.updateConfiguration(configCopy);
1291012912
}
1291112913

1291212914
// Make sure all resources in our process are updated
@@ -12916,11 +12918,11 @@ public boolean updateConfigurationLocked(Configuration values,
1291612918
// boot, where the first config change needs to guarantee
1291712919
// all resources have that config before following boot
1291812920
// code is executed.
12919-
mSystemThread.applyConfigurationToResources(newConfig);
12921+
mSystemThread.applyConfigurationToResources(configCopy);
1292012922

1292112923
if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
1292212924
Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
12923-
msg.obj = new Configuration(mConfiguration);
12925+
msg.obj = new Configuration(configCopy);
1292412926
mHandler.sendMessage(msg);
1292512927
}
1292612928

@@ -12930,7 +12932,7 @@ public boolean updateConfigurationLocked(Configuration values,
1293012932
if (app.thread != null) {
1293112933
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc "
1293212934
+ app.processName + " new config " + mConfiguration);
12933-
app.thread.scheduleConfigurationChanged(mConfiguration);
12935+
app.thread.scheduleConfigurationChanged(configCopy);
1293412936
}
1293512937
} catch (Exception e) {
1293612938
}

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

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

535535
r.app = app;
@@ -591,7 +591,8 @@ final boolean realStartActivityLocked(ActivityRecord r,
591591
}
592592
}
593593
app.thread.scheduleLaunchActivity(new Intent(r.intent), r,
594-
System.identityHashCode(r), r.info, mService.mConfiguration,
594+
System.identityHashCode(r), r.info,
595+
new Configuration(mService.mConfiguration),
595596
r.compat, r.icicle, results, newIntents, !andResume,
596597
mService.isNextTransitionForward(), profileFile, profileFd,
597598
profileAutoStop);
@@ -1453,7 +1454,7 @@ final boolean resumeTopActivityLocked(ActivityRecord prev) {
14531454
if (config != null) {
14541455
next.frozenBeforeDestroy = true;
14551456
}
1456-
updated = mService.updateConfigurationLocked(config, next, false);
1457+
updated = mService.updateConfigurationLocked(config, next, false, false);
14571458
}
14581459
}
14591460
if (!updated) {
@@ -2900,7 +2901,7 @@ final int startActivityMayWait(IApplicationThread caller, int callingUid,
29002901
mConfigWillChange = false;
29012902
if (DEBUG_CONFIGURATION) Slog.v(TAG,
29022903
"Updating to new configuration after starting activity.");
2903-
mService.updateConfigurationLocked(config, null, false);
2904+
mService.updateConfigurationLocked(config, null, false, false);
29042905
}
29052906

29062907
Binder.restoreCallingIdentity(origId);
@@ -4171,7 +4172,7 @@ private final boolean relaunchActivityLocked(ActivityRecord r,
41714172
if (DEBUG_SWITCH) Slog.i(TAG, "Switch is restarting resumed " + r);
41724173
r.forceNewConfig = false;
41734174
r.app.thread.scheduleRelaunchActivity(r, results, newIntents,
4174-
changes, !andResume, mService.mConfiguration);
4175+
changes, !andResume, new Configuration(mService.mConfiguration));
41754176
// Note: don't need to call pauseIfSleepingLocked() here, because
41764177
// the caller will only pass in 'andResume' if this activity is
41774178
// currently resumed, which implies we aren't sleeping.

0 commit comments

Comments
 (0)