Merge "Maybe fix issue #5405788: Device continuously opening and closing..." into ics-mr1

This commit is contained in:
Dianne Hackborn
2011-11-14 18:35:46 -08:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 18 deletions

View File

@ -1479,6 +1479,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mConfiguration.setToDefaults(); mConfiguration.setToDefaults();
mConfiguration.locale = Locale.getDefault(); mConfiguration.locale = Locale.getDefault();
mConfigurationSeq = mConfiguration.seq = 1;
mProcessStats.init(); mProcessStats.init();
mCompatModePackages = new CompatModePackages(this, systemDir); mCompatModePackages = new CompatModePackages(this, systemDir);
@ -2436,7 +2437,7 @@ public final class ActivityManagerService extends ActivityManagerNative
r.mayFreezeScreenLocked(r.app) ? r.appToken : null); r.mayFreezeScreenLocked(r.app) ? r.appToken : null);
if (config != null) { if (config != null) {
r.frozenBeforeDestroy = true; r.frozenBeforeDestroy = true;
if (!updateConfigurationLocked(config, r, false)) { if (!updateConfigurationLocked(config, r, false, false)) {
mMainStack.resumeTopActivityLocked(null); mMainStack.resumeTopActivityLocked(null);
} }
} }
@ -3797,7 +3798,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.instrumentationClass, profileFile, profileFd, profileAutoStop, app.instrumentationClass, profileFile, profileFd, profileAutoStop,
app.instrumentationArguments, app.instrumentationWatcher, testMode, app.instrumentationArguments, app.instrumentationWatcher, testMode,
isRestrictedBackupMode || !normalMode, app.persistent, isRestrictedBackupMode || !normalMode, app.persistent,
mConfiguration, app.compat, getCommonServicesLocked(), new Configuration(mConfiguration), app.compat, getCommonServicesLocked(),
mCoreSettingsObserver.getCoreSettingsLocked()); mCoreSettingsObserver.getCoreSettingsLocked());
updateLruProcessLocked(app, false, true); updateLruProcessLocked(app, false, true);
app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis(); app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis();
@ -6707,8 +6708,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mAlwaysFinishActivities = alwaysFinishActivities; mAlwaysFinishActivities = alwaysFinishActivities;
// This happens before any activities are started, so we can // This happens before any activities are started, so we can
// change mConfiguration in-place. // change mConfiguration in-place.
mConfiguration.updateFrom(configuration); updateConfigurationLocked(configuration, null, false, true);
mConfigurationSeq = mConfiguration.seq = 1;
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Initial config: " + mConfiguration); if (DEBUG_CONFIGURATION) Slog.v(TAG, "Initial config: " + mConfiguration);
} }
} }
@ -12934,7 +12934,7 @@ public final class ActivityManagerService extends ActivityManagerNative
synchronized(this) { synchronized(this) {
final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity();
updateConfigurationLocked(values, null, true); updateConfigurationLocked(values, null, true, false);
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
} }
} }
@ -12957,7 +12957,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (values != null) { if (values != null) {
Settings.System.clearConfiguration(values); Settings.System.clearConfiguration(values);
} }
updateConfigurationLocked(values, null, false); updateConfigurationLocked(values, null, false, false);
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
} }
} }
@ -12971,7 +12971,7 @@ public final class ActivityManagerService extends ActivityManagerNative
* @param persistent TODO * @param persistent TODO
*/ */
public boolean updateConfigurationLocked(Configuration values, public boolean updateConfigurationLocked(Configuration values,
ActivityRecord starting, boolean persistent) { ActivityRecord starting, boolean persistent, boolean initLocale) {
int changes = 0; int changes = 0;
boolean kept = true; boolean kept = true;
@ -12986,7 +12986,7 @@ public final class ActivityManagerService extends ActivityManagerNative
EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes); EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
if (values.locale != null) { if (values.locale != null && !initLocale) {
saveLocaleLocked(values.locale, saveLocaleLocked(values.locale,
!values.locale.equals(mConfiguration.locale), !values.locale.equals(mConfiguration.locale),
values.userSetLocale); values.userSetLocale);
@ -12999,10 +12999,12 @@ public final class ActivityManagerService extends ActivityManagerNative
newConfig.seq = mConfigurationSeq; newConfig.seq = mConfigurationSeq;
mConfiguration = newConfig; mConfiguration = newConfig;
Slog.i(TAG, "Config changed: " + newConfig); Slog.i(TAG, "Config changed: " + newConfig);
final Configuration configCopy = new Configuration(mConfiguration);
AttributeCache ac = AttributeCache.instance(); AttributeCache ac = AttributeCache.instance();
if (ac != null) { if (ac != null) {
ac.updateConfiguration(mConfiguration); ac.updateConfiguration(configCopy);
} }
// Make sure all resources in our process are updated // Make sure all resources in our process are updated
@ -13012,11 +13014,11 @@ public final class ActivityManagerService extends ActivityManagerNative
// boot, where the first config change needs to guarantee // boot, where the first config change needs to guarantee
// all resources have that config before following boot // all resources have that config before following boot
// code is executed. // code is executed.
mSystemThread.applyConfigurationToResources(newConfig); mSystemThread.applyConfigurationToResources(configCopy);
if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) { if (persistent && Settings.System.hasInterestingConfigurationChanges(changes)) {
Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG); Message msg = mHandler.obtainMessage(UPDATE_CONFIGURATION_MSG);
msg.obj = new Configuration(mConfiguration); msg.obj = new Configuration(configCopy);
mHandler.sendMessage(msg); mHandler.sendMessage(msg);
} }
@ -13026,7 +13028,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (app.thread != null) { if (app.thread != null) {
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc " if (DEBUG_CONFIGURATION) Slog.v(TAG, "Sending to proc "
+ app.processName + " new config " + mConfiguration); + app.processName + " new config " + mConfiguration);
app.thread.scheduleConfigurationChanged(mConfiguration); app.thread.scheduleConfigurationChanged(configCopy);
} }
} catch (Exception e) { } catch (Exception e) {
} }

View File

@ -528,7 +528,7 @@ final class ActivityStack {
Configuration config = mService.mWindowManager.updateOrientationFromAppTokens( Configuration config = mService.mWindowManager.updateOrientationFromAppTokens(
mService.mConfiguration, mService.mConfiguration,
r.mayFreezeScreenLocked(app) ? r.appToken : null); r.mayFreezeScreenLocked(app) ? r.appToken : null);
mService.updateConfigurationLocked(config, r, false); mService.updateConfigurationLocked(config, r, false, false);
} }
r.app = app; r.app = app;
@ -590,7 +590,8 @@ final class ActivityStack {
} }
} }
app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken, app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken,
System.identityHashCode(r), r.info, mService.mConfiguration, System.identityHashCode(r), r.info,
new Configuration(mService.mConfiguration),
r.compat, r.icicle, results, newIntents, !andResume, r.compat, r.icicle, results, newIntents, !andResume,
mService.isNextTransitionForward(), profileFile, profileFd, mService.isNextTransitionForward(), profileFile, profileFd,
profileAutoStop); profileAutoStop);
@ -1460,7 +1461,7 @@ final class ActivityStack {
if (config != null) { if (config != null) {
next.frozenBeforeDestroy = true; next.frozenBeforeDestroy = true;
} }
updated = mService.updateConfigurationLocked(config, next, false); updated = mService.updateConfigurationLocked(config, next, false, false);
} }
} }
if (!updated) { if (!updated) {
@ -2917,7 +2918,7 @@ final class ActivityStack {
mConfigWillChange = false; mConfigWillChange = false;
if (DEBUG_CONFIGURATION) Slog.v(TAG, if (DEBUG_CONFIGURATION) Slog.v(TAG,
"Updating to new configuration after starting activity."); "Updating to new configuration after starting activity.");
mService.updateConfigurationLocked(config, null, false); mService.updateConfigurationLocked(config, null, false, false);
} }
Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId);
@ -4190,7 +4191,7 @@ final class ActivityStack {
if (DEBUG_SWITCH) Slog.i(TAG, "Switch is restarting resumed " + r); if (DEBUG_SWITCH) Slog.i(TAG, "Switch is restarting resumed " + r);
r.forceNewConfig = false; r.forceNewConfig = false;
r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents, r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents,
changes, !andResume, mService.mConfiguration); changes, !andResume, new Configuration(mService.mConfiguration));
// Note: don't need to call pauseIfSleepingLocked() here, because // Note: don't need to call pauseIfSleepingLocked() here, because
// the caller will only pass in 'andResume' if this activity is // the caller will only pass in 'andResume' if this activity is
// currently resumed, which implies we aren't sleeping. // currently resumed, which implies we aren't sleeping.