From 968064bed0a43b019cb7d84bed7493f6f78fda5e Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Tue, 28 May 2019 14:36:18 +0800 Subject: [PATCH] Fix a bug about missing onConfigurationChanged The original logic sends the new configuration to the non-activity components only if there is any public field changed. However, it doesn't use the latest configuration to compare to the current one, which caused ActivityThread dropping some onConfigurationChanged callbacks. This CL uses the latest configuration to compare to the current one. Fix: 132653657 Test: Steps in the bug Change-Id: I969ef189c36ba1903503d8b7de5641103aed8cf3 --- core/java/android/app/ActivityThread.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 1e982bc48c195..3a74f7dc2ea5a 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -5564,15 +5564,9 @@ public final class ActivityThread extends ClientTransactionHandler { private void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) { - int configDiff = 0; + int configDiff; + boolean equivalent; - // This flag tracks whether the new configuration is fundamentally equivalent to the - // existing configuration. This is necessary to determine whether non-activity - // callbacks should receive notice when the only changes are related to non-public fields. - // We do not gate calling {@link #performActivityConfigurationChanged} based on this flag - // as that method uses the same check on the activity config override as well. - final boolean equivalent = config != null && mConfiguration != null - && (0 == mConfiguration.diffPublicOnly(config)); final Theme systemTheme = getSystemContext().getTheme(); final Theme systemUiTheme = getSystemUiContext().getTheme(); @@ -5590,6 +5584,13 @@ public final class ActivityThread extends ClientTransactionHandler { return; } + // This flag tracks whether the new configuration is fundamentally equivalent to the + // existing configuration. This is necessary to determine whether non-activity callbacks + // should receive notice when the only changes are related to non-public fields. + // We do not gate calling {@link #performActivityConfigurationChanged} based on this + // flag as that method uses the same check on the activity config override as well. + equivalent = mConfiguration != null && (0 == mConfiguration.diffPublicOnly(config)); + if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle configuration changed: " + config);