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

Commit a6b4e3d6 authored by Massimo Carli's avatar Massimo Carli
Browse files

Fix exit transition from PIP

We skip to apply the TransparentPolicy when the opaque activity
below is not letterboxed.

Flag: EXEMPT Small fix
Fix: 376200414
Test: atest WmTests:TransparentPolicyTest

Change-Id: I392f821f55dc268cdaf508c05bcf53fd84dc8bb8
parent d8e5981d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -196,10 +196,11 @@ class TransparentPolicy {

    // We evaluate the case when the policy should not be applied.
    private boolean shouldSkipTransparentPolicy(@Nullable ActivityRecord opaqueActivity) {
        if (opaqueActivity == null || opaqueActivity.isEmbedded()) {
        if (opaqueActivity == null || opaqueActivity.isEmbedded()
                || !opaqueActivity.areBoundsLetterboxed()) {
            // We skip letterboxing if the translucent activity doesn't have any
            // opaque activities beneath or the activity below is embedded which
            // never has letterbox.
            // never has letterbox or the activity is not letterboxed at all.
            return true;
        }
        final AppCompatSizeCompatModePolicy scmPolicy = mActivityRecord.mAppCompatController
+4 −0
Original line number Diff line number Diff line
@@ -259,6 +259,10 @@ class AppCompatActivityRobot {
        doReturn(embedded).when(mActivityStack.top()).isEmbedded();
    }

    void setTopActivityHasLetterboxedBounds(boolean letterboxed) {
        doReturn(letterboxed).when(mActivityStack.top()).areBoundsLetterboxed();
    }

    void setTopActivityVisible(boolean isVisible) {
        doReturn(isVisible).when(mActivityStack.top()).isVisible();
    }
+14 −0
Original line number Diff line number Diff line
@@ -217,6 +217,19 @@ public class TransparentPolicyTest extends WindowTestsBase {
        });
    }

    @Test
    public void testNotApplyStrategyToTranslucentActivitiesOverNotLetterboxedActivities() {
        runTestScenario((robot) -> {
            robot.transparentActivity((ta) -> {
                ta.activity().setTopActivityHasLetterboxedBounds(false);
                ta.launchTransparentActivityInTask();

                ta.checkTopActivityTransparentPolicyStartNotInvoked();
                ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false);
            });
        });
    }

    @EnableFlags(com.android.window.flags.Flags.FLAG_RESPECT_NON_TOP_VISIBLE_FIXED_ORIENTATION)
    @Test
    public void testNotRunStrategyToTranslucentActivitiesIfRespectOrientation() {
@@ -388,6 +401,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
            mTransparentActivityRobot = new AppCompatTransparentActivityRobot(activity());
            // We always create at least an opaque activity in a Task
            activity().createNewTaskWithBaseActivity();
            activity().setTopActivityHasLetterboxedBounds(true);
        }

        @Override