Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18ef32b5 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Report Activity config changes only if it handles the change"

parents 659f944f 286845eb
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -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;
@@ -5880,15 +5879,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
+0 −18
Original line number Diff line number Diff line
@@ -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.