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

Commit fa4ae8d7 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

Apply stable config compat override after othe compats

Moving the size override after other compat overrides to make sure the
letterbox overrides can be applied correctly. The fields overridden by
letterbox doesn't need extra override regarding the stable configuration
as all insets are already in consideration.

Besides, check shouldCreateCompatDisplayInsets() before applying the
override to avoid inconsistency when the compat display insets is not
yet created.

Bug: 332468995
Bug: 340970172
Bug: 336687188
Test: See reproduce steps in b/332468995
Test: CtsWindowManagerDeviceWindow:WindowMetricsActivityTests
Test: CtsWindowManagerSdk25TestCases:AspectRatioSdk25Tests
Test: v2/android-crystalball-eng/health/microbench/startup/hscapps/compile-speed-profile/open-maps
Change-Id: Iee7ae3ea7e483e6f80fa6ef4659627d620653081
parent b0f4faad
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -2141,14 +2141,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mWmService.mFlags.mInsetsDecoupledConfiguration) {
            // When the stable configuration is the default behavior, override for the legacy apps
            // without forward override flag.
            mResolveConfigHint.mUseOverrideInsetsForStableBounds =
            mResolveConfigHint.mUseOverrideInsetsForConfig =
                    !info.isChangeEnabled(INSETS_DECOUPLED_CONFIGURATION_ENFORCED)
                            && !info.isChangeEnabled(
                                    OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION);
        } else {
            // When the stable configuration is not the default behavior, forward overriding the
            // listed apps.
            mResolveConfigHint.mUseOverrideInsetsForStableBounds =
            mResolveConfigHint.mUseOverrideInsetsForConfig =
                    info.isChangeEnabled(OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION);
        }
@@ -8513,7 +8513,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mCompatDisplayInsets =
                new CompatDisplayInsets(
                        mDisplayContent, this, letterboxedContainerBounds,
                        mResolveConfigHint.mUseOverrideInsetsForStableBounds);
                        mResolveConfigHint.mUseOverrideInsetsForConfig);
    }
    private void clearSizeCompatModeAttributes() {
@@ -8593,8 +8593,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final int parentWindowingMode =
                newParentConfiguration.windowConfiguration.getWindowingMode();
        applySizeOverrideIfNeeded(newParentConfiguration, parentWindowingMode, resolvedConfig);
        // Bubble activities should always fill their parent and should not be letterboxed.
        final boolean isFixedOrientationLetterboxAllowed = !getLaunchedFromBubble()
                && (parentWindowingMode == WINDOWING_MODE_MULTI_WINDOW
@@ -8694,6 +8692,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            resolvedConfig.windowConfiguration.setMaxBounds(mTmpBounds);
        }
        applySizeOverrideIfNeeded(newParentConfiguration, parentWindowingMode, resolvedConfig);
        logAppCompatState();
    }
@@ -8706,6 +8706,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * The override contains all potentially affected fields in Configuration, including
     * screenWidthDp, screenHeightDp, smallestScreenWidthDp, and orientation.
     * All overrides to those fields should be in this method.
     *
     * TODO: Consider integrate this with computeConfigByResolveHint()
     */
    private void applySizeOverrideIfNeeded(Configuration newParentConfiguration,
            int parentWindowingMode, Configuration inOutConfig) {
@@ -8717,9 +8719,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (rotation == ROTATION_UNDEFINED && !isFixedRotationTransforming()) {
            rotation = mDisplayContent.getRotation();
        }
        if (!mOptOutEdgeToEdge && (!mResolveConfigHint.mUseOverrideInsetsForStableBounds
                || getCompatDisplayInsets() != null || isFloating(parentWindowingMode)
                || rotation == ROTATION_UNDEFINED)) {
        if (!mOptOutEdgeToEdge && (!mResolveConfigHint.mUseOverrideInsetsForConfig
                || getCompatDisplayInsets() != null || shouldCreateCompatDisplayInsets()
                || isFloating(parentWindowingMode) || rotation == ROTATION_UNDEFINED)) {
            // If the insets configuration decoupled logic is not enabled for the app, or the app
            // already has a compat override, or the context doesn't contain enough info to
            // calculate the override, skip the override.
@@ -9038,7 +9040,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mDisplayContent == null) {
            return true;
        }
        if (!mResolveConfigHint.mUseOverrideInsetsForStableBounds) {
        if (!mResolveConfigHint.mUseOverrideInsetsForConfig) {
            // No insets should be considered any more.
            return true;
        }
@@ -9057,7 +9059,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final Task task = getTask();
        task.calculateInsetFrames(outNonDecorBounds /* outNonDecorBounds */,
                outStableBounds /* outStableBounds */, parentBounds /* bounds */, di,
                mResolveConfigHint.mUseOverrideInsetsForStableBounds);
                mResolveConfigHint.mUseOverrideInsetsForConfig);
        final int orientationWithInsets = outStableBounds.height() >= outStableBounds.width()
                ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
        // If orientation does not match the orientation with insets applied, then a
@@ -9114,7 +9116,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                getResolvedOverrideConfiguration().windowConfiguration.getBounds();
        final int stableBoundsOrientation = stableBounds.width() > stableBounds.height()
                ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT;
        final int parentOrientation = mResolveConfigHint.mUseOverrideInsetsForStableBounds
        final int parentOrientation = mResolveConfigHint.mUseOverrideInsetsForConfig
                ? stableBoundsOrientation : newParentConfig.orientation;
        // If the activity requires a different orientation (either by override or activityInfo),
@@ -9139,7 +9141,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }
        final Rect parentAppBounds = mResolveConfigHint.mUseOverrideInsetsForStableBounds
        final Rect parentAppBounds = mResolveConfigHint.mUseOverrideInsetsForConfig
                ? outNonDecorBounds : newParentConfig.windowConfiguration.getAppBounds();
        // TODO(b/182268157): Explore using only one type of parentBoundsWithInsets, either app
        // bounds or stable bounds to unify aspect ratio logic.
+4 −4
Original line number Diff line number Diff line
@@ -2222,7 +2222,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
    static class ConfigOverrideHint {
        @Nullable DisplayInfo mTmpOverrideDisplayInfo;
        @Nullable ActivityRecord.CompatDisplayInsets mTmpCompatInsets;
        boolean mUseOverrideInsetsForStableBounds;
        boolean mUseOverrideInsetsForConfig;
    }

    void computeConfigResourceOverrides(@NonNull Configuration inOutConfig,
@@ -2255,11 +2255,11 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            @NonNull Configuration parentConfig, @Nullable ConfigOverrideHint overrideHint) {
        DisplayInfo overrideDisplayInfo = null;
        ActivityRecord.CompatDisplayInsets compatInsets = null;
        boolean useOverrideInsetsForStableBounds = false;
        boolean useOverrideInsetsForConfig = false;
        if (overrideHint != null) {
            overrideDisplayInfo = overrideHint.mTmpOverrideDisplayInfo;
            compatInsets = overrideHint.mTmpCompatInsets;
            useOverrideInsetsForStableBounds = overrideHint.mUseOverrideInsetsForStableBounds;
            useOverrideInsetsForConfig = overrideHint.mUseOverrideInsetsForConfig;
            if (overrideDisplayInfo != null) {
                // Make sure the screen related configs can be computed by the provided
                // display info.
@@ -2339,7 +2339,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                // The non decor inset are areas that could never be removed in Honeycomb. See
                // {@link WindowManagerPolicy#getNonDecorInsetsLw}.
                calculateInsetFrames(mTmpNonDecorBounds, mTmpStableBounds, mTmpFullBounds, di,
                        useOverrideInsetsForStableBounds);
                        useOverrideInsetsForConfig);
            } else {
                // Apply the given non-decor and stable insets to calculate the corresponding bounds
                // for screen size of configuration.