Do not filter out the size configs if no configuration buckets

Otherwise, the activity may not be relaunched in the right
configuration.

Bug: 235449822
Bug: 235774601
Test: start Settings
Test: atest SizeConfigurationBucketsTest
Change-Id: I3c1d63114b570e1f740408a4381888b0697c2c94
This commit is contained in:
Louis Chang
2022-06-13 18:05:13 +08:00
parent e0d6f903b9
commit 8ec32dd023

View File

@@ -104,24 +104,15 @@ public final class SizeConfigurationBuckets implements Parcelable {
/** /**
* Get the changes between two configurations but don't count changes in sizes if they don't * Get the changes between two configurations but don't count changes in sizes if they don't
* cross boundaries that are important to the app. * cross boundaries that are important to the app.
*
* This is a static helper to deal with null `buckets`. When no buckets have been specified,
* this actually filters out all 3 size-configs. This is legacy behavior.
*/ */
public static int filterDiff(int diff, @NonNull Configuration oldConfig, public static int filterDiff(int diff, @NonNull Configuration oldConfig,
@NonNull Configuration newConfig, @Nullable SizeConfigurationBuckets buckets) { @NonNull Configuration newConfig, @Nullable SizeConfigurationBuckets buckets) {
if (buckets == null) {
return diff;
}
final boolean nonSizeLayoutFieldsUnchanged = final boolean nonSizeLayoutFieldsUnchanged =
areNonSizeLayoutFieldsUnchanged(oldConfig.screenLayout, newConfig.screenLayout); areNonSizeLayoutFieldsUnchanged(oldConfig.screenLayout, newConfig.screenLayout);
if (buckets == null) {
// Only unflip CONFIG_SCREEN_LAYOUT if non-size-related attributes of screen layout do
// not change.
if (nonSizeLayoutFieldsUnchanged) {
return diff & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE
| CONFIG_SCREEN_LAYOUT);
} else {
return diff & ~(CONFIG_SCREEN_SIZE | CONFIG_SMALLEST_SCREEN_SIZE);
}
}
if ((diff & CONFIG_SCREEN_SIZE) != 0) { if ((diff & CONFIG_SCREEN_SIZE) != 0) {
final boolean crosses = buckets.crossesHorizontalSizeThreshold(oldConfig.screenWidthDp, final boolean crosses = buckets.crossesHorizontalSizeThreshold(oldConfig.screenWidthDp,
newConfig.screenWidthDp) newConfig.screenWidthDp)