diff options
| author | Charles Chen <charlesccchen@google.com> | 2022-01-25 12:46:24 +0800 |
|---|---|---|
| committer | Charles Chen <charlesccchen@google.com> | 2022-01-26 18:14:34 +0800 |
| commit | 286845eb3eecf1647f2536d525234d9cda342d82 (patch) | |
| tree | cb4a18bc74a69b940679bc1484fbee12c85110c1 /core/java | |
| parent | 490be11e8b111e4d74ac54749b179a654020828e (diff) | |
Report Activity config changes only if it handles the change
In S, we don't dispatch #onConfigurationChanged callback if the screen
size changes doesn't corss size buckets. However,user may still want
to know the change even if it's very small.
This CL changes to dispatch the callback if the Activity handles
the config changes.
Also clean-up the unused code.
Bug: 202468254
Test: atest AppConfigurationTests
Change-Id: Ief68922ed80a0fcfc05c7ccb5e3692334352a2c3
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 11 | ||||
| -rw-r--r-- | core/java/android/window/ConfigurationHelper.java | 18 |
2 files changed, 5 insertions, 24 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index ea6271412289..17c097408967 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -31,7 +31,6 @@ import static android.content.ContentResolver.DEPRECATE_DATA_COLUMNS; import static android.content.ContentResolver.DEPRECATE_DATA_PREFIX; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; -import static android.window.ConfigurationHelper.diffPublicWithSizeBuckets; import static android.window.ConfigurationHelper.freeTextLayoutCachesIfNeeded; import static android.window.ConfigurationHelper.isDifferentDisplay; import static android.window.ConfigurationHelper.shouldUpdateResources; @@ -5940,15 +5939,15 @@ public final class ActivityThread extends ClientTransactionHandler final boolean movedToDifferentDisplay = isDifferentDisplay(activity.getDisplayId(), displayId); - final ActivityClientRecord r = mActivities.get(activityToken); - final int diff = diffPublicWithSizeBuckets(activity.mCurrentConfig, - newConfig, r != null ? r.mSizeConfigurations : null); + final Configuration currentConfig = activity.mCurrentConfig; + final int diff = (currentConfig == null) ? 0xffffffff + : currentConfig.diffPublicOnly(newConfig); final boolean hasPublicConfigChange = diff != 0; // TODO(b/173090263): Use diff instead after the improvement of AssetManager and // ResourcesImpl constructions. final boolean shouldUpdateResources = hasPublicConfigChange - || shouldUpdateResources(activityToken, activity.mCurrentConfig, newConfig, - amOverrideConfig, movedToDifferentDisplay, hasPublicConfigChange); + || shouldUpdateResources(activityToken, currentConfig, newConfig, amOverrideConfig, + movedToDifferentDisplay, hasPublicConfigChange); final boolean shouldReportChange = hasPublicConfigChange // If this activity doesn't handle any of the config changes, then don't bother // calling onConfigurationChanged. Otherwise, report to the activity for the diff --git a/core/java/android/window/ConfigurationHelper.java b/core/java/android/window/ConfigurationHelper.java index 9a079751553f..843712f0434a 100644 --- a/core/java/android/window/ConfigurationHelper.java +++ b/core/java/android/window/ConfigurationHelper.java @@ -47,24 +47,6 @@ public class ConfigurationHelper { } /** - * A helper method to filter out {@link ActivityInfo#CONFIG_SCREEN_SIZE} if the - * {@link Configuration#diffPublicOnly(Configuration) diff} of two {@link Configuration} - * doesn't cross the boundary. - * - * @see SizeConfigurationBuckets#filterDiff(int, Configuration, Configuration, - * SizeConfigurationBuckets) - */ - public static int diffPublicWithSizeBuckets(@Nullable Configuration currentConfig, - @NonNull Configuration newConfig, @Nullable SizeConfigurationBuckets buckets) { - // If current configuration is null, it is definitely different from updated Configuration. - if (currentConfig == null) { - return 0xffffffff; - } - int publicDiff = currentConfig.diffPublicOnly(newConfig); - return SizeConfigurationBuckets.filterDiff(publicDiff, currentConfig, newConfig, buckets); - } - - /** * Returns {@code true} if the {@link android.content.res.Resources} associated with * a {@code token} needs to be updated. * |
