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

Commit 68a8f654 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas Committed by Automerger Merge Worker
Browse files

Merge "[2/n] Optimize user aspect ratio button heuristic" into udc-qpr-dev am:...

Merge "[2/n] Optimize user aspect ratio button heuristic" into udc-qpr-dev am: 54234fea am: 2b2a3ff2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24758989



Change-Id: I243ae510691716f48ea6f5f2a11dec1f554ae71a
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4421532a 2b2a3ff2
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -254,6 +254,12 @@ public class TaskInfo {
     */
    public boolean isUserFullscreenOverrideEnabled;

    /**
     * Whether the top activity fillsParent() is false
     * @hide
     */
    public boolean isTopActivityTransparent;

    /**
     * Hint about the letterbox state of the top activity.
     * @hide
@@ -551,7 +557,8 @@ public class TaskInfo {
                && Objects.equals(mTopActivityLocusId, that.mTopActivityLocusId)
                && parentTaskId == that.parentTaskId
                && Objects.equals(topActivity, that.topActivity)
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
                && isTopActivityTransparent == that.isTopActivityTransparent;
    }

    /**
@@ -584,7 +591,8 @@ public class TaskInfo {
                && (!hasCompatUI() || configuration.uiMode == that.configuration.uiMode)
                && (!hasCompatUI() || isVisible == that.isVisible)
                && isFocused == that.isFocused
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled;
                && isUserFullscreenOverrideEnabled == that.isUserFullscreenOverrideEnabled
                && isTopActivityTransparent == that.isTopActivityTransparent;
    }

    /**
@@ -641,6 +649,7 @@ public class TaskInfo {
        topActivityLetterboxWidth = source.readInt();
        topActivityLetterboxHeight = source.readInt();
        isUserFullscreenOverrideEnabled = source.readBoolean();
        isTopActivityTransparent = source.readBoolean();
    }

    /**
@@ -698,6 +707,7 @@ public class TaskInfo {
        dest.writeInt(topActivityLetterboxWidth);
        dest.writeInt(topActivityLetterboxHeight);
        dest.writeBoolean(isUserFullscreenOverrideEnabled);
        dest.writeBoolean(isTopActivityTransparent);
    }

    @Override
@@ -745,6 +755,7 @@ public class TaskInfo {
                + " topActivityLetterboxWidth=" + topActivityLetterboxWidth
                + " topActivityLetterboxHeight=" + topActivityLetterboxHeight
                + " isUserFullscreenOverrideEnabled=" + isUserFullscreenOverrideEnabled
                + " isTopActivityTransparent=" + isTopActivityTransparent
                + " locusId=" + mTopActivityLocusId
                + " displayAreaFeatureId=" + displayAreaFeatureId
                + " cameraCompatControlState="
+2 −1
Original line number Diff line number Diff line
@@ -348,7 +348,8 @@ public class CompatUIController implements OnDisplaysChangedListener,
        // as they are still relevant. Else, if the activity is visible and focused (the one the
        // user can see and is using), the user aspect ratio button can potentially be displayed so
        // start tracking the buttons visibility for this task.
        if (mTopActivityTaskId != taskInfo.taskId && taskInfo.isVisible && taskInfo.isFocused) {
        if (mTopActivityTaskId != taskInfo.taskId && !taskInfo.isTopActivityTransparent
                && taskInfo.isVisible && taskInfo.isFocused) {
            mTopActivityTaskId = taskInfo.taskId;
            setHasShownUserAspectRatioSettingsButton(false);
        }
+45 −1
Original line number Diff line number Diff line
@@ -633,15 +633,58 @@ public class CompatUIControllerTest extends ShellTestCase {
        Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());
    }

    @Test
    public void testUpdateActiveTaskInfo_transparentTask_notUpdated() {
        // Create new task
        final TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID,
                /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN, /* isVisible */ true,
                /* isFocused */ true);

        // Simulate new task being shown
        mController.updateActiveTaskInfo(taskInfo);

        // Check topActivityTaskId is updated to the taskId of the new task and
        // hasShownUserAspectRatioSettingsButton has been reset to false
        Assert.assertEquals(TASK_ID, mController.getTopActivityTaskId());
        Assert.assertFalse(mController.hasShownUserAspectRatioSettingsButton());

        // Simulate user aspect ratio button being shown
        mController.setHasShownUserAspectRatioSettingsButton(true);
        Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());

        final int newTaskId = TASK_ID + 1;

        // Create transparent task
        final TaskInfo taskInfo1 = createTaskInfo(DISPLAY_ID, newTaskId,
                /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN, /* isVisible */ true,
                /* isFocused */ true, /* isTopActivityTransparent */ true);

        // Simulate new task being shown
        mController.updateActiveTaskInfo(taskInfo1);

        // Check topActivityTaskId is NOT updated and hasShownUserAspectRatioSettingsButton
        // remains true
        Assert.assertEquals(TASK_ID, mController.getTopActivityTaskId());
        Assert.assertTrue(mController.hasShownUserAspectRatioSettingsButton());
    }

    private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
            @CameraCompatControlState int cameraCompatControlState) {
        return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState,
                /* isVisible */ false, /* isFocused */ false);
                /* isVisible */ false, /* isFocused */ false,
                /* isTopActivityTransparent */ false);
    }

    private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
            @CameraCompatControlState int cameraCompatControlState, boolean isVisible,
            boolean isFocused) {
        return createTaskInfo(displayId, taskId, hasSizeCompat, cameraCompatControlState,
                isVisible, isFocused, /* isTopActivityTransparent */ false);
    }

    private static TaskInfo createTaskInfo(int displayId, int taskId, boolean hasSizeCompat,
            @CameraCompatControlState int cameraCompatControlState, boolean isVisible,
            boolean isFocused, boolean isTopActivityTransparent) {
        RunningTaskInfo taskInfo = new RunningTaskInfo();
        taskInfo.taskId = taskId;
        taskInfo.displayId = displayId;
@@ -649,6 +692,7 @@ public class CompatUIControllerTest extends ShellTestCase {
        taskInfo.cameraCompatControlState = cameraCompatControlState;
        taskInfo.isVisible = isVisible;
        taskInfo.isFocused = isFocused;
        taskInfo.isTopActivityTransparent = isTopActivityTransparent;
        return taskInfo;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -3494,6 +3494,7 @@ class Task extends TaskFragment {
        info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
        info.isUserFullscreenOverrideEnabled = top != null
                && top.mLetterboxUiController.shouldApplyUserFullscreenOverride();
        info.isTopActivityTransparent = top != null && !top.fillsParent();
        info.isFromLetterboxDoubleTap = top != null && top.mLetterboxUiController.isFromDoubleTap();
        if (info.isLetterboxDoubleTapEnabled) {
            info.topActivityLetterboxWidth = top.getBounds().width();