diff options
| author | Dianne Hackborn <hackbod@google.com> | 2010-03-18 11:29:37 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2010-03-18 11:38:30 -0700 |
| commit | ae07816a3fcae73fbbc4b23ec3f647d4bee473ce (patch) | |
| tree | a0b420610093d950fe7868d80707b0ed9e75d7b5 /core/java | |
| parent | ea3e8e0758b6561917ba35baf934ccbf414144b9 (diff) | |
Fix problem with calling onConfigurationChanged() too much.
We now return the initial configuration for a window when it is
added to the window manager. The view hierarchy would check to
see if it was different than the last one, and not dispatch a
configuration change down itself if not. However, when
ActivityThread received it, it would always dispatch a config
change even if it is the same.
The solution is to only do this in ActivityThread if the config
is actually different; otherwise, we continue to rely only on
the activity manager explicitly telling us when to do a config
change.
Change-Id: I8a6e3565776dd2723c8b791496bb6041463d4b67
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1c980e32392e..fa6abec6d9b1 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3908,16 +3908,16 @@ public final class ActivityThread { } } - final void applyConfigurationToResourcesLocked(Configuration config) { + final boolean applyConfigurationToResourcesLocked(Configuration config) { if (mResConfiguration == null) { mResConfiguration = new Configuration(); } if (!mResConfiguration.isOtherSeqNewer(config)) { if (DEBUG_CONFIGURATION) Log.v(TAG, "Skipping new config: curSeq=" + mResConfiguration.seq + ", newSeq=" + config.seq); - return; + return false; } - mResConfiguration.updateFrom(config); + int changes = mResConfiguration.updateFrom(config); DisplayMetrics dm = getDisplayMetricsLocked(true); // set it for java, this also affects newly created Resources @@ -3948,6 +3948,8 @@ public final class ActivityThread { it.remove(); } } + + return changes != 0; } final void handleConfigurationChanged(Configuration config) { @@ -4522,17 +4524,20 @@ public final class ActivityThread { ViewRoot.addConfigCallback(new ComponentCallbacks() { public void onConfigurationChanged(Configuration newConfig) { synchronized (mPackages) { - if (mPendingConfiguration == null || - mPendingConfiguration.isOtherSeqNewer(newConfig)) { - mPendingConfiguration = newConfig; - - // We need to apply this change to the resources - // immediately, because upon returning the view - // hierarchy will be informed about it. - applyConfigurationToResourcesLocked(newConfig); + // We need to apply this change to the resources + // immediately, because upon returning the view + // hierarchy will be informed about it. + if (applyConfigurationToResourcesLocked(newConfig)) { + // This actually changed the resources! Tell + // everyone about it. + if (mPendingConfiguration == null || + mPendingConfiguration.isOtherSeqNewer(newConfig)) { + mPendingConfiguration = newConfig; + + queueOrSendMessage(H.CONFIGURATION_CHANGED, newConfig); + } } } - queueOrSendMessage(H.CONFIGURATION_CHANGED, newConfig); } public void onLowMemory() { } |
