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

Commit cceba8e2 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Do not apply letterbox when entering PiP" into udc-dev

parents a85de1fb ca20e306
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -8301,6 +8301,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }


        mIsAspectRatioApplied = false;
        mIsAspectRatioApplied = false;
        mIsEligibleForFixedOrientationLetterbox = false;
        mLetterboxBoundsForFixedOrientationAndAspectRatio = null;


        // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be
        // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be
        // different from windowing mode of the task (PiP) during transition from fullscreen to PiP
        // different from windowing mode of the task (PiP) during transition from fullscreen to PiP
@@ -8310,8 +8312,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final boolean isFixedOrientationLetterboxAllowed =
        final boolean isFixedOrientationLetterboxAllowed =
                parentWindowingMode == WINDOWING_MODE_MULTI_WINDOW
                parentWindowingMode == WINDOWING_MODE_MULTI_WINDOW
                        || parentWindowingMode == WINDOWING_MODE_FULLSCREEN
                        || parentWindowingMode == WINDOWING_MODE_FULLSCREEN
                        // Switching from PiP to fullscreen.
                        // When starting to switch between PiP and fullscreen, the task is pinned
                        || (parentWindowingMode == WINDOWING_MODE_PINNED
                        // and the activity is fullscreen. But only allow to apply letterbox if the
                        // activity is exiting PiP because an entered PiP should fill the task.
                        || (!mWaitForEnteringPinnedMode
                                && parentWindowingMode == WINDOWING_MODE_PINNED
                                && resolvedConfig.windowConfiguration.getWindowingMode()
                                && resolvedConfig.windowConfiguration.getWindowingMode()
                                        == WINDOWING_MODE_FULLSCREEN);
                                        == WINDOWING_MODE_FULLSCREEN);
        // TODO(b/181207944): Consider removing the if condition and always run
        // TODO(b/181207944): Consider removing the if condition and always run
@@ -8705,8 +8710,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
     * in this method.
     * in this method.
     */
     */
    private void resolveFixedOrientationConfiguration(@NonNull Configuration newParentConfig) {
    private void resolveFixedOrientationConfiguration(@NonNull Configuration newParentConfig) {
        mLetterboxBoundsForFixedOrientationAndAspectRatio = null;
        mIsEligibleForFixedOrientationLetterbox = false;
        final Rect parentBounds = newParentConfig.windowConfiguration.getBounds();
        final Rect parentBounds = newParentConfig.windowConfiguration.getBounds();
        final Rect stableBounds = new Rect();
        final Rect stableBounds = new Rect();
        // If orientation is respected when insets are applied, then stableBounds will be empty.
        // If orientation is respected when insets are applied, then stableBounds will be empty.
+4 −1
Original line number Original line Diff line number Diff line
@@ -2013,7 +2013,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            // from doing work and changing the activity visuals while animating
            // from doing work and changing the activity visuals while animating
            // TODO(task-org): Figure-out more structured way to do this long term.
            // TODO(task-org): Figure-out more structured way to do this long term.
            r.setWindowingMode(r.getWindowingMode());
            r.setWindowingMode(r.getWindowingMode());
            r.mWaitForEnteringPinnedMode = true;


            final TaskFragment organizedTf = r.getOrganizedTaskFragment();
            final TaskFragment organizedTf = r.getOrganizedTaskFragment();
            final boolean singleActivity = task.getNonFinishingActivityCount() == 1;
            final boolean singleActivity = task.getNonFinishingActivityCount() == 1;
@@ -2140,6 +2139,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            }
            }
            rootTask.setDeferTaskAppear(false);
            rootTask.setDeferTaskAppear(false);


            // After setting this, it is not expected to change activity configuration until the
            // transition animation is finished. So the activity can keep consistent appearance
            // when animating.
            r.mWaitForEnteringPinnedMode = true;
            // Reset the state that indicates it can enter PiP while pausing after we've moved it
            // Reset the state that indicates it can enter PiP while pausing after we've moved it
            // to the root pinned task
            // to the root pinned task
            r.supportsEnterPipOnTaskSwitch = false;
            r.supportsEnterPipOnTaskSwitch = false;
+1 −3
Original line number Original line Diff line number Diff line
@@ -3883,15 +3883,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }
    }


    /**
    /**
     * @return {@code true} if activity bounds are letterboxed or letterboxed for display cutout.
     * Returns {@code true} if activity bounds are letterboxed or letterboxed for display cutout.
     * Note that it's always {@code false} if the activity is in pip mode.
     *
     *
     * <p>Note that letterbox UI may not be shown even when this returns {@code true}. See {@link
     * <p>Note that letterbox UI may not be shown even when this returns {@code true}. See {@link
     * LetterboxUiController#shouldShowLetterboxUi} for more context.
     * LetterboxUiController#shouldShowLetterboxUi} for more context.
     */
     */
    boolean areAppWindowBoundsLetterboxed() {
    boolean areAppWindowBoundsLetterboxed() {
        return mActivityRecord != null
        return mActivityRecord != null
                && !mActivityRecord.inPinnedWindowingMode()
                && (mActivityRecord.areBoundsLetterboxed() || isLetterboxedForDisplayCutout());
                && (mActivityRecord.areBoundsLetterboxed() || isLetterboxedForDisplayCutout());
    }
    }


+11 −0
Original line number Original line Diff line number Diff line
@@ -337,6 +337,17 @@ public class RootWindowContainerTests extends WindowTestsBase {
        // Ensure a task has moved over.
        // Ensure a task has moved over.
        ensureTaskPlacement(task, activity);
        ensureTaskPlacement(task, activity);
        assertTrue(task.inPinnedWindowingMode());
        assertTrue(task.inPinnedWindowingMode());

        // The activity with fixed orientation should not apply letterbox when entering PiP.
        final int requestedOrientation = task.getConfiguration().orientation
                == Configuration.ORIENTATION_PORTRAIT
                ? Configuration.ORIENTATION_LANDSCAPE : Configuration.ORIENTATION_PORTRAIT;
        doReturn(requestedOrientation).when(activity).getRequestedConfigurationOrientation();
        doReturn(false).when(activity).handlesOrientationChangeFromDescendant(anyInt());
        final Rect bounds = new Rect(task.getBounds());
        bounds.scale(0.5f);
        task.setBounds(bounds);
        assertFalse(activity.isLetterboxedForFixedOrientationAndAspectRatio());
    }
    }


    /**
    /**