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

Commit d49ccf4b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Skip applying legacy insets for app bubbles behind flags." into main

parents 3ce37e89 030001ce
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.activityTypeToString;
import static android.app.WindowConfiguration.isFloating;
import static android.content.Context.CONTEXT_RESTRICTED;
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_HOME;
@@ -7534,8 +7535,21 @@ final class ActivityRecord extends WindowToken {
        final AppCompatSafeRegionPolicy safeRegionPolicy =
                mAppCompatController.getSafeRegionPolicy();
        mAppCompatController.getLetterboxPolicy().resetFixedOrientationLetterboxEligibility();

        boolean shouldApplyLegacyInsets =
                !isFloating(newParentConfiguration.windowConfiguration.getWindowingMode());
        if (com.android.wm.shell.Flags.enableCreateAnyBubble()
                && com.android.wm.shell.Flags.enableBubbleAppCompatFixes()) {
            final Task task = getTask();
            if (task != null) {
                // Similar to floating windows, an app bubble should not apply legacy insets.
                // TODO(b/407669465): Update isAppBubble usage once migrated to the new approach.
                shouldApplyLegacyInsets &= !task.getTaskInfo().isAppBubble;
            }
        }
        mResolveConfigHint.resolveTmpOverrides(mDisplayContent, newParentConfiguration,
                isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds());
                isFixedRotationTransforming(), safeRegionPolicy.getLatestSafeRegionBounds(),
                shouldApplyLegacyInsets);

        // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be
        // different from windowing mode of the task (PiP) during transition from fullscreen to PiP
+3 −3
Original line number Diff line number Diff line
@@ -2314,7 +2314,8 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        boolean mUseOverrideInsetsForConfig;

        void resolveTmpOverrides(DisplayContent dc, Configuration parentConfig,
                boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds) {
                boolean isFixedRotationTransforming, @Nullable Rect safeRegionBounds,
                boolean shouldApplyLegacyInsets) {
            mParentAppBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect(
                    parentConfig.windowConfiguration.getAppBounds());
            mParentBoundsOverride = safeRegionBounds != null ? safeRegionBounds : new Rect(
@@ -2326,8 +2327,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
                mTmpOverrideConfigOrientation =
                        mParentAppBoundsOverride.height() >= mParentAppBoundsOverride.width()
                                ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
            } else if (mUseOverrideInsetsForConfig && dc != null
                    && !isFloating(parentConfig.windowConfiguration.getWindowingMode())) {
            } else if (shouldApplyLegacyInsets && mUseOverrideInsetsForConfig && dc != null) {
                // Insets are decoupled from configuration by default from V+, use legacy
                // compatibility behaviour for apps targeting SDK earlier than 35
                // (see applySizeOverrideIfNeeded).
+29 −0
Original line number Diff line number Diff line
@@ -751,6 +751,35 @@ public class SizeCompatTests extends WindowTestsBase {
        assertFalse(mActivity.areBoundsLetterboxed());
    }

    @Test
    @EnableFlags({com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE,
            com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_APP_COMPAT_FIXES})
    // Enable to prevent any non-legacy override insets from being added.
    @EnableCompatChanges({ActivityInfo.INSETS_DECOUPLED_CONFIGURATION_ENFORCED})
    public void testLegacyInsetOverride_isAppBubble_notApplied() {
        // Set up app.
        final int notchHeight = 100;
        final DisplayContent display =
                new TestDisplayContent.Builder(mAtm, 1000, 2800)
                        .setNotch(notchHeight)
                        .build();
        setUpApp(display);

        // Simulate inset override for legacy app bound behaviour.
        mActivity.mResolveConfigHint.mUseOverrideInsetsForConfig = true;

        // Set up activity task to be in app bubble.
        mTask.mLaunchNextToBubble = true;
        mTask.setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);

        Rect bounds = new Rect(mActivity.getWindowConfiguration().getBounds());
        Rect appBounds = new Rect(mActivity.getWindowConfiguration().getAppBounds());
        // App bounds should not include insets and should match bounds.
        assertEquals(new Rect(0, 0, 1000, 2800), appBounds);
        assertEquals(new Rect(0, 0, 1000, 2800), bounds);
    }

    @Test
    public void testAspectRatioMatchParentBoundsAndImeAttachable() {
        setUpApp(new TestDisplayContent.Builder(mAtm, 1000, 2000).build());