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

Commit 5aea1095 authored by Massimo Carli's avatar Massimo Carli
Browse files

Fix translucent in smart linking

This CL fixes the problem with letterboxing for
activities already in history relaunched from a
smart linking using a translucent trampoline activity.
The problem is related to a wrong behaviour with
double-tap which just moves some of the activities
in the task and not all of them.
Ignoring not visible activities as candidate to be
the first opaque activity beneath, fixes the problem.

Fixes: 274765111
Test: Run `atest SizeCompatTests`

Change-Id: I9e0f4f4ff64c6666903a3df5ca162aa5c2705ce6
parent cc03961c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ import java.util.function.Predicate;
final class LetterboxUiController {

    private static final Predicate<ActivityRecord> FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE =
            activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing();
            activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing()
                    && activityRecord.nowVisible;

    private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxUiController" : TAG_ATM;

+44 −0
Original line number Diff line number Diff line
@@ -174,6 +174,44 @@ public class SizeCompatTests extends WindowTestsBase {
        setUpApp(builder.build());
    }

    @Test
    public void testActivityInHistoryAndNotVisibleIsNotUsedAsOpaqueForTranslucentActivities() {
        mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
        setUpDisplaySizeWithApp(2000, 1000);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = false;
        // Translucent Activity
        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
                .setLaunchedFromUid(mActivity.getUid())
                .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT)
                .build();
        doReturn(false).when(translucentActivity).fillsParent();

        mTask.addChild(translucentActivity);

        assertFalse(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior());
    }

    @Test
    public void testActivityInHistoryAndVisibleIsUsedAsOpaqueForTranslucentActivities() {
        mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
        setUpDisplaySizeWithApp(2000, 1000);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        // Translucent Activity
        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
                .setLaunchedFromUid(mActivity.getUid())
                .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT)
                .build();
        doReturn(false).when(translucentActivity).fillsParent();

        mTask.addChild(translucentActivity);

        assertTrue(translucentActivity.mLetterboxUiController.hasInheritedLetterboxBehavior());
    }

    @Test
    public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed() {
        mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
@@ -198,6 +236,7 @@ public class SizeCompatTests extends WindowTestsBase {
    public void testHorizontalReachabilityEnabledForTranslucentActivities() {
        setUpDisplaySizeWithApp(2500, 1000);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        final LetterboxConfiguration config = mWm.mLetterboxConfiguration;
        config.setTranslucentLetterboxingOverrideEnabled(true);
        config.setLetterboxHorizontalPositionMultiplier(0.5f);
@@ -273,6 +312,7 @@ public class SizeCompatTests extends WindowTestsBase {
    public void testVerticalReachabilityEnabledForTranslucentActivities() {
        setUpDisplaySizeWithApp(1000, 2500);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        final LetterboxConfiguration config = mWm.mLetterboxConfiguration;
        config.setTranslucentLetterboxingOverrideEnabled(true);
        config.setLetterboxVerticalPositionMultiplier(0.5f);
@@ -351,6 +391,7 @@ public class SizeCompatTests extends WindowTestsBase {
        prepareUnresizable(mActivity, 1.5f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
        mActivity.info.setMinAspectRatio(1.2f);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        // Translucent Activity
        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
                .setLaunchedFromUid(mActivity.getUid())
@@ -407,6 +448,7 @@ public class SizeCompatTests extends WindowTestsBase {
        prepareUnresizable(mActivity, 1.5f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
        mActivity.info.setMinAspectRatio(1.2f);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        // Translucent Activity
        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
                .setLaunchedFromUid(mActivity.getUid())
@@ -482,6 +524,7 @@ public class SizeCompatTests extends WindowTestsBase {
                true /* ignoreOrientationRequest */);
        mActivity.mWmService.mLetterboxConfiguration.setLetterboxHorizontalPositionMultiplier(
                1.0f /*letterboxVerticalPositionMultiplier*/);
        mActivity.nowVisible = true;
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
        // We launch a transparent activity
        final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
@@ -514,6 +557,7 @@ public class SizeCompatTests extends WindowTestsBase {
        mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
        setUpDisplaySizeWithApp(2800, 1400);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.nowVisible = true;
        prepareUnresizable(mActivity, -1f /* maxAspect */, SCREEN_ORIENTATION_PORTRAIT);
        // Rotate to put activity in size compat mode.
        rotateDisplay(mActivity.mDisplayContent, ROTATION_90);