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

Commit f0f95045 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:...

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

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



Change-Id: I2027c44f9985a4ddf3669aaf24453d8cd48c3eff
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 4de29716 35ef37cc
Loading
Loading
Loading
Loading
+11 −2
Original line number Original line Diff line number Diff line
@@ -241,6 +241,12 @@ public class TaskInfo {
     */
     */
    public boolean isLetterboxDoubleTapEnabled;
    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
     * If {@link isLetterboxDoubleTapEnabled} it contains the current letterbox vertical position or
     * {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise.
     * {@link TaskInfo.PROPERTY_VALUE_UNSET} otherwise.
@@ -497,7 +503,7 @@ public class TaskInfo {
                && isResizeable == that.isResizeable
                && isResizeable == that.isResizeable
                && supportsMultiWindow == that.supportsMultiWindow
                && supportsMultiWindow == that.supportsMultiWindow
                && displayAreaFeatureId == that.displayAreaFeatureId
                && displayAreaFeatureId == that.displayAreaFeatureId
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxWidth == that.topActivityLetterboxWidth
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
                && topActivityLetterboxHeight == that.topActivityLetterboxHeight
@@ -529,9 +535,9 @@ public class TaskInfo {
        return displayId == that.displayId
        return displayId == that.displayId
                && taskId == that.taskId
                && taskId == that.taskId
                && topActivityInSizeCompat == that.topActivityInSizeCompat
                && topActivityInSizeCompat == that.topActivityInSizeCompat
                && isFromLetterboxDoubleTap == that.isFromLetterboxDoubleTap
                && topActivityEligibleForLetterboxEducation
                && topActivityEligibleForLetterboxEducation
                    == that.topActivityEligibleForLetterboxEducation
                    == that.topActivityEligibleForLetterboxEducation
                && isLetterboxDoubleTapEnabled == that.isLetterboxDoubleTapEnabled
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxVerticalPosition == that.topActivityLetterboxVerticalPosition
                && topActivityLetterboxHorizontalPosition
                && topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
                    == that.topActivityLetterboxHorizontalPosition
@@ -592,6 +598,7 @@ public class TaskInfo {
        displayAreaFeatureId = source.readInt();
        displayAreaFeatureId = source.readInt();
        cameraCompatControlState = source.readInt();
        cameraCompatControlState = source.readInt();
        isLetterboxDoubleTapEnabled = source.readBoolean();
        isLetterboxDoubleTapEnabled = source.readBoolean();
        isFromLetterboxDoubleTap = source.readBoolean();
        topActivityLetterboxVerticalPosition = source.readInt();
        topActivityLetterboxVerticalPosition = source.readInt();
        topActivityLetterboxHorizontalPosition = source.readInt();
        topActivityLetterboxHorizontalPosition = source.readInt();
        topActivityLetterboxWidth = source.readInt();
        topActivityLetterboxWidth = source.readInt();
@@ -644,6 +651,7 @@ public class TaskInfo {
        dest.writeInt(displayAreaFeatureId);
        dest.writeInt(displayAreaFeatureId);
        dest.writeInt(cameraCompatControlState);
        dest.writeInt(cameraCompatControlState);
        dest.writeBoolean(isLetterboxDoubleTapEnabled);
        dest.writeBoolean(isLetterboxDoubleTapEnabled);
        dest.writeBoolean(isFromLetterboxDoubleTap);
        dest.writeInt(topActivityLetterboxVerticalPosition);
        dest.writeInt(topActivityLetterboxVerticalPosition);
        dest.writeInt(topActivityLetterboxHorizontalPosition);
        dest.writeInt(topActivityLetterboxHorizontalPosition);
        dest.writeInt(topActivityLetterboxWidth);
        dest.writeInt(topActivityLetterboxWidth);
@@ -684,6 +692,7 @@ public class TaskInfo {
                + " topActivityEligibleForLetterboxEducation= "
                + " topActivityEligibleForLetterboxEducation= "
                        + topActivityEligibleForLetterboxEducation
                        + topActivityEligibleForLetterboxEducation
                + " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled
                + " topActivityLetterboxed= " + isLetterboxDoubleTapEnabled
                + " isFromDoubleTap= " + isFromLetterboxDoubleTap
                + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
                + " topActivityLetterboxVerticalPosition= " + topActivityLetterboxVerticalPosition
                + " topActivityLetterboxHorizontalPosition= "
                + " topActivityLetterboxHorizontalPosition= "
                        + topActivityLetterboxHorizontalPosition
                        + topActivityLetterboxHorizontalPosition
+3 −7
Original line number Original line Diff line number Diff line
@@ -74,9 +74,7 @@ class ReachabilityEduWindowManager extends CompatUIWindowManagerAbstract {
    private boolean mForceUpdate = false;
    private boolean mForceUpdate = false;


    // We decided to force the visualization of the double-tap animated icons every time the user
    // 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
    // double-taps.
    // mLetterboxVerticalPosition and mLetterboxHorizontalPosition saving the result in this
    // variable.
    private boolean mHasUserDoubleTapped;
    private boolean mHasUserDoubleTapped;


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


        mHasUserDoubleTapped =
        if (taskInfo.isFromLetterboxDoubleTap) {
                mLetterboxVerticalPosition != prevLetterboxVerticalPosition
                        || prevLetterboxHorizontalPosition != mLetterboxHorizontalPosition;
        if (mHasUserDoubleTapped) {
            // In this case we disable the reachability for the following launch of
            // In this case we disable the reachability for the following launch of
            // the current application. Anyway because a double tap event happened,
            // the current application. Anyway because a double tap event happened,
            // the reachability education is displayed
            // the reachability education is displayed
+0 −28
Original line number Original line 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.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.verify;


import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.TaskInfo;
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.DisplayLayout;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.SyncTransactionQueue;


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


    @After
    public void tearDown() {
    }

    @Test
    @Test
    public void testCreateLayout_notEligible_doesNotCreateLayout() {
    public void testCreateLayout_notEligible_doesNotCreateLayout() {
        final ReachabilityEduWindowManager windowManager = createReachabilityEduWindowManager(
        final ReachabilityEduWindowManager windowManager = createReachabilityEduWindowManager(
@@ -85,20 +79,6 @@ public class ReachabilityEduWindowManagerTest extends ShellTestCase {
        assertNull(windowManager.mLayout);
        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) {
    private ReachabilityEduWindowManager createReachabilityEduWindowManager(TaskInfo taskInfo) {
        return new ReachabilityEduWindowManager(mContext, taskInfo,
        return new ReachabilityEduWindowManager(mContext, taskInfo,
                mSyncTransactionQueue, mCallback, mTaskListener, mDisplayLayout,
                mSyncTransactionQueue, mCallback, mTaskListener, mDisplayLayout,
@@ -113,14 +93,6 @@ public class ReachabilityEduWindowManagerTest extends ShellTestCase {
                /* topActivityLetterboxHeight */ -1);
                /* 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,
    private static TaskInfo createTaskInfo(int userId, boolean isLetterboxDoubleTapEnabled,
            int topActivityLetterboxVerticalPosition, int topActivityLetterboxHorizontalPosition,
            int topActivityLetterboxVerticalPosition, int topActivityLetterboxHorizontalPosition,
            int topActivityLetterboxWidth, int topActivityLetterboxHeight) {
            int topActivityLetterboxWidth, int topActivityLetterboxHeight) {
+10 −2
Original line number Original line Diff line number Diff line
@@ -238,6 +238,8 @@ final class LetterboxUiController {


    private boolean mIsRelauchingAfterRequestedOrientationChanged;
    private boolean mIsRelauchingAfterRequestedOrientationChanged;


    private boolean mDoubleTapEvent;

    LetterboxUiController(WindowManagerService wmService, ActivityRecord activityRecord) {
    LetterboxUiController(WindowManagerService wmService, ActivityRecord activityRecord) {
        mLetterboxConfiguration = wmService.mLetterboxConfiguration;
        mLetterboxConfiguration = wmService.mLetterboxConfiguration;
        // Given activityRecord may not be fully constructed since LetterboxUiController
        // 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() {
    SurfaceControl getLetterboxParentSurface() {
        if (mActivityRecord.isInLetterboxAnimation()) {
        if (mActivityRecord.isInLetterboxAnimation()) {
            return mActivityRecord.getTask().getSurfaceControl();
            return mActivityRecord.getTask().getSurfaceControl();
@@ -1037,7 +1045,7 @@ final class LetterboxUiController {
                                : LETTERBOX_POSITION_CHANGED__POSITION_CHANGE__LEFT_TO_CENTER;
                                : LETTERBOX_POSITION_CHANGED__POSITION_CHANGE__LEFT_TO_CENTER;
            logLetterboxPositionChange(changeToLog);
            logLetterboxPositionChange(changeToLog);
        }
        }

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

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