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

Commit 0a308937 authored by Massimo Carli's avatar Massimo Carli Committed by Automerger Merge Worker
Browse files

Merge "Don't force double-tap education on unfold" into tm-qpr-dev am: 8d71de9f am: a6a2209a

parents 7473649b a6a2209a
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -241,6 +241,12 @@ public class TaskInfo {
     */
    public boolean isLetterboxDoubleTapEnabled;

    /**
     * Whether the update comes from a letterbox double-tap action from the user or not.
     * @hide
     */
    public boolean isFromLetterboxDoubleTap;

    /**
     * If {@link isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position or
     * {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise.
@@ -497,7 +503,7 @@ public class TaskInfo {
                && isResizeable == that.isResizeable
                && supportsMultiWindow == that.supportsMultiWindow
                && displayAreaFeatureId == that.displayAreaFeatureId
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
@@ -529,9 +535,9 @@ public class TaskInfo {
        return displayId == that.displayId
                && taskId == that.taskId
                && topActivityInSizeCompat == that.topActivityInSizeCompat
                && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
                && topActivityEligibleForLetterboxEducation
                    == that.topActivityEligibleForLetterboxEducation
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
@@ -592,6 +598,7 @@ public class TaskInfo {
        displayAreaFeatureId = source.readInt();
        cameraCompatControlState = source.readInt();
        isLetterboxDoubleTapEnabled = source.readBoolean();
        isFromLetterboxDoubleTap = source.readBoolean();
        topActivityLetterboxVerticalPosition = source.readInt();
        topActivityLetterboxHorizontalPosition = source.readInt();
        topActivityLetterboxWidth = source.readInt();
@@ -644,6 +651,7 @@ public class TaskInfo {
        dest.writeInt(displayAreaFeatureId);
        dest.writeInt(cameraCompatControlState);
        dest.writeBoolean(isLetterboxDoubleTapEnabled);
        dest.writeBoolean(isFromLetterboxDoubleTap);
        dest.writeInt(topActivityLetterboxVerticalPosition);
        dest.writeInt(topActivityLetterboxHorizontalPosition);
        dest.writeInt(topActivityLetterboxWidth);
@@ -684,6 +692,7 @@ public class TaskInfo {
                + " topActivityEligibleForLetterboxEducation= "
                        + topActivityEligibleForLetterboxEducation
                + " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled
                + " isFromDoubleTap= " + isFromLetterboxDoubleTap
                + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
                + " topActivityLetterboxHorizontalPosition= "
                        + topActivityLetterboxHorizontalPosition
+3 −7
Original line number Diff line number Diff line
@@ -74,9 +74,7 @@ class ReachabilityEduWindowManager extends CompatUIWindowManagerAbstract {
    private boolean mForceUpdate = false;

    // We decided to force the visualization of the double-tap animated icons every time the user
    // double-taps. We detect a double-tap checking the previous and current state of
    // mLetterboxVerticalPosition and mLetterboxHorizontalPosition saving the result in this
    // variable.
    // double-taps.
    private boolean mHasUserDoubleTapped;

    // When the size of the letterboxed app changes and the icons are visible
@@ -155,11 +153,9 @@ class ReachabilityEduWindowManager extends CompatUIWindowManagerAbstract {
        mLetterboxHorizontalPosition = taskInfo.topActivityLetterboxHorizontalPosition;
        mTopActivityLetterboxWidth = taskInfo.topActivityLetterboxWidth;
        mTopActivityLetterboxHeight = taskInfo.topActivityLetterboxHeight;
        mHasUserDoubleTapped = taskInfo.isFromLetterboxDoubleTap;

        mHasUserDoubleTapped =
                mLetterboxVerticalPosition != prevLetterboxVerticalPosition
                        || prevLetterboxHorizontalPosition != mLetterboxHorizontalPosition;
        if (mHasUserDoubleTapped) {
        if (taskInfo.isFromLetterboxDoubleTap) {
            // In this case we disable the reachability for the following launch of
            // the current application. Anyway because a double tap event happened,
            // the reachability education is displayed
+0 −28
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.wm.shell.compatui;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.verify;

import android.app.ActivityManager;
import android.app.TaskInfo;
@@ -32,7 +31,6 @@ import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.SyncTransactionQueue;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,10 +69,6 @@ public class ReachabilityEduWindowManagerTest extends ShellTestCase {
        mExecutor = new TestShellExecutor();
    }

    @After
    public void tearDown() {
    }

    @Test
    public void testCreateLayout_notEligible_doesNotCreateLayout() {
        final ReachabilityEduWindowManager windowManager = createReachabilityEduWindowManager(
@@ -85,20 +79,6 @@ public class ReachabilityEduWindowManagerTest extends ShellTestCase {
        assertNull(windowManager.mLayout);
    }

    @Test
    public void testCreateLayout_letterboxPositionChanged_doubleTapIsDetected() {
        // Initial left position
        final TaskInfo initialTaskInfo = createTaskInfoForHorizontalTapping(USER_ID, 0, 1000);
        final ReachabilityEduWindowManager windowManager =
                createReachabilityEduWindowManager(initialTaskInfo);
        // Move to the right
        final TaskInfo newPositionTaskInfo = createTaskInfoForHorizontalTapping(USER_ID, 1, 1000);
        windowManager.updateCompatInfo(newPositionTaskInfo, mTaskListener, /* canShow */ true);

        verify(mCompatUIConfiguration).setDontShowReachabilityEducationAgain(newPositionTaskInfo);
    }


    private ReachabilityEduWindowManager createReachabilityEduWindowManager(TaskInfo taskInfo) {
        return new ReachabilityEduWindowManager(mContext, taskInfo,
                mSyncTransactionQueue, mCallback, mTaskListener, mDisplayLayout,
@@ -113,14 +93,6 @@ public class ReachabilityEduWindowManagerTest extends ShellTestCase {
                /* topActivityLetterboxHeight */ -1);
    }

    private static TaskInfo createTaskInfoForHorizontalTapping(int userId,
            int topActivityLetterboxHorizontalPosition, int topActivityLetterboxWidth) {
        return createTaskInfo(userId, /* isLetterboxDoubleTapEnabled */ true,
                /* topActivityLetterboxVerticalPosition */ -1,
                topActivityLetterboxHorizontalPosition, topActivityLetterboxWidth,
                /* topActivityLetterboxHeight */ -1);
    }

    private static TaskInfo createTaskInfo(int userId, boolean isLetterboxDoubleTapEnabled,
            int topActivityLetterboxVerticalPosition, int topActivityLetterboxHorizontalPosition,
            int topActivityLetterboxWidth, int topActivityLetterboxHeight) {
+10 −2
Original line number Diff line number Diff line
@@ -238,6 +238,8 @@ final class LetterboxUiController {

    private boolean mIsRelauchingAfterRequestedOrientationChanged;

    private boolean mDoubleTapEvent;

    LetterboxUiController(WindowManagerService wmService, ActivityRecord activityRecord) {
        mLetterboxConfiguration = wmService.mLetterboxConfiguration;
        // Given activityRecord may not be fully constructed since LetterboxUiController
@@ -831,6 +833,12 @@ final class LetterboxUiController {
        }
    }

    boolean isFromDoubleTap() {
        final boolean isFromDoubleTap = mDoubleTapEvent;
        mDoubleTapEvent = false;
        return isFromDoubleTap;
    }

    SurfaceControl getLetterboxParentSurface() {
        if (mActivityRecord.isInLetterboxAnimation()) {
            return mActivityRecord.getTask().getSurfaceControl();
@@ -1037,7 +1045,7 @@ final class LetterboxUiController {
                                : LETTERBOX_POSITION_CHANGED__POSITION_CHANGE__LEFT_TO_CENTER;
            logLetterboxPositionChange(changeToLog);
        }

        mDoubleTapEvent = true;
        // TODO(197549949): Add animation for transition.
        mActivityRecord.recomputeConfiguration();
    }
@@ -1076,7 +1084,7 @@ final class LetterboxUiController {
                                : LETTERBOX_POSITION_CHANGED__POSITION_CHANGE__TOP_TO_CENTER;
            logLetterboxPositionChange(changeToLog);
        }

        mDoubleTapEvent = true;
        // TODO(197549949): Add animation for transition.
        mActivityRecord.recomputeConfiguration();
    }
+1 −0
Original line number Diff line number Diff line
@@ -3427,6 +3427,7 @@ class Task extends TaskFragment {
        info.topActivityLetterboxHorizontalPosition = TaskInfo.PROPERTY_VALUE_UNSET;
        info.topActivityLetterboxWidth = TaskInfo.PROPERTY_VALUE_UNSET;
        info.topActivityLetterboxHeight = TaskInfo.PROPERTY_VALUE_UNSET;
        info.isFromLetterboxDoubleTap = top != null && top.mLetterboxUiController.isFromDoubleTap();
        if (info.isLetterboxDoubleTapEnabled) {
            info.topActivityLetterboxWidth = top.getBounds().width();
            info.topActivityLetterboxHeight = top.getBounds().height();