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

Commit 98b75e3e authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/35706055',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/35706055', 'googleplex-android-review.googlesource.com/35706536', 'googleplex-android-review.googlesource.com/35706537', 'googleplex-android-review.googlesource.com/35714138', 'googleplex-android-review.googlesource.com/35740913', 'googleplex-android-review.googlesource.com/35832020', 'googleplex-android-review.googlesource.com/35809623', 'googleplex-android-review.googlesource.com/35851753'] into 25Q4-release.

Change-Id: I8f0ebb218a91089bb3e2b078c939214e3bad2a32
parents 391b568c 7f79d00e
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -168,7 +168,9 @@ class DesktopDisplayEventHandler(
        startTransaction: SurfaceControl.Transaction,
        startTransaction: SurfaceControl.Transaction,
        finishTransaction: SurfaceControl.Transaction,
        finishTransaction: SurfaceControl.Transaction,
    ) {
    ) {
        if (info.changes.isEmpty()) return
        val displayId = info.changes[0].endDisplayId
        val displayId = info.changes[0].endDisplayId
        if (displayId !in displayConfigById) return
        val config = displayConfigById[displayId]
        val config = displayConfigById[displayId]
        if (info.type == TRANSIT_CHANGE) {
        if (info.type == TRANSIT_CHANGE) {
            resizeTasksIfPreconditionsSatisfied(displayId, config, true)
            resizeTasksIfPreconditionsSatisfied(displayId, config, true)
+40 −13
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.desktopmode;


import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.view.Display.DEFAULT_DISPLAY;


import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightPx;
import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightPx;
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR;
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.NO_INDICATOR;
@@ -315,14 +316,18 @@ public class DesktopModeVisualIndicator {
        // account for the possibility of the task going off the top of the screen by captionHeight
        // account for the possibility of the task going off the top of the screen by captionHeight
        final int captionHeight = getDesktopViewAppHeaderHeightPx(mContext);
        final int captionHeight = getDesktopViewAppHeaderHeightPx(mContext);
        final int transitionAreaTop = getTransitionAreaTop(captionHeight);
        final int transitionAreaTop = getTransitionAreaTop(captionHeight);
        // Perform a quick check first: any input off the left edge of the display should be split
        if (isSplitAllowedOnDisplay()) {
        // left, and split right for the right edge. This is universal across all drag event types.
            // For task in DEFAULT_DISPLAY, or when NON_DEFAULT_DISPLAY_SPLIT is enabled,
            // Perform a quick check first: any input off the left edge of the display should be
            // split left, and split right for the right edge. This is universal across all drag
            // event types.
            if (inputCoordinates.x < 0 && inputCoordinates.y >= transitionAreaTop) {
            if (inputCoordinates.x < 0 && inputCoordinates.y >= transitionAreaTop) {
                return TO_SPLIT_LEFT_INDICATOR;
                return TO_SPLIT_LEFT_INDICATOR;
            }
            }
            if (inputCoordinates.x > layout.width() && inputCoordinates.y >= transitionAreaTop) {
            if (inputCoordinates.x > layout.width() && inputCoordinates.y >= transitionAreaTop) {
                return TO_SPLIT_RIGHT_INDICATOR;
                return TO_SPLIT_RIGHT_INDICATOR;
            }
            }
        }
        final Region fullscreenRegion = calculateFullscreenRegion(layout, captionHeight);
        final Region fullscreenRegion = calculateFullscreenRegion(layout, captionHeight);
        final Rect splitLeftRegion =
        final Rect splitLeftRegion =
                calculateSplitLeftRegion(layout, transitionAreaWidth, captionHeight);
                calculateSplitLeftRegion(layout, transitionAreaWidth, captionHeight);
@@ -333,12 +338,15 @@ public class DesktopModeVisualIndicator {
        if (fullscreenRegion.contains(x, y)) {
        if (fullscreenRegion.contains(x, y)) {
            result = TO_FULLSCREEN_INDICATOR;
            result = TO_FULLSCREEN_INDICATOR;
        }
        }
        if (isSplitAllowedOnDisplay()) {
            if (splitLeftRegion.contains(x, y)) {
            if (splitLeftRegion.contains(x, y)) {
                result = IndicatorType.TO_SPLIT_LEFT_INDICATOR;
                result = IndicatorType.TO_SPLIT_LEFT_INDICATOR;
            }
            }
            if (splitRightRegion.contains(x, y)) {
            if (splitRightRegion.contains(x, y)) {
                result = IndicatorType.TO_SPLIT_RIGHT_INDICATOR;
                result = IndicatorType.TO_SPLIT_RIGHT_INDICATOR;
            }
            }
        }

        if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()
        if (BubbleAnythingFlagHelper.enableBubbleToFullscreen()
                && mDragStartState == DragStartState.FROM_FULLSCREEN) {
                && mDragStartState == DragStartState.FROM_FULLSCREEN) {
            if (calculateBubbleLeftRegion(layout).contains(x, y)) {
            if (calculateBubbleLeftRegion(layout).contains(x, y)) {
@@ -458,7 +466,7 @@ public class DesktopModeVisualIndicator {
            result.add(new Pair<>(calculateBubbleRightRegion(layout), TO_BUBBLE_RIGHT_INDICATOR));
            result.add(new Pair<>(calculateBubbleRightRegion(layout), TO_BUBBLE_RIGHT_INDICATOR));
        }
        }


        if (isLeftRightSplit) {
        if (isSplitAllowedOnDisplay() && isLeftRightSplit) {
            int splitRegionWidth = mContext.getResources().getDimensionPixelSize(
            int splitRegionWidth = mContext.getResources().getDimensionPixelSize(
                    com.android.wm.shell.shared.R.dimen.drag_zone_h_split_from_app_width_fold);
                    com.android.wm.shell.shared.R.dimen.drag_zone_h_split_from_app_width_fold);
            result.add(new Pair<>(calculateSplitLeftRegion(layout, splitRegionWidth,
            result.add(new Pair<>(calculateSplitLeftRegion(layout, splitRegionWidth,
@@ -466,6 +474,7 @@ public class DesktopModeVisualIndicator {
            result.add(new Pair<>(calculateSplitRightRegion(layout, splitRegionWidth,
            result.add(new Pair<>(calculateSplitRightRegion(layout, splitRegionWidth,
                    /* captionHeight= */ 0), TO_SPLIT_RIGHT_INDICATOR));
                    /* captionHeight= */ 0), TO_SPLIT_RIGHT_INDICATOR));
        }
        }

        // TODO(b/401352409): add support for top/bottom split zones
        // TODO(b/401352409): add support for top/bottom split zones
        // default to fullscreen
        // default to fullscreen
        result.add(new Pair<>(new Rect(), TO_FULLSCREEN_INDICATOR));
        result.add(new Pair<>(new Rect(), TO_FULLSCREEN_INDICATOR));
@@ -504,4 +513,22 @@ public class DesktopModeVisualIndicator {
                                com.android.wm.shell.R.dimen.desktop_mode_split_from_desktop_height)
                                com.android.wm.shell.R.dimen.desktop_mode_split_from_desktop_height)
                : -captionHeight;
                : -captionHeight;
    }
    }

    /**
     * Determines whether split-screen is allowed on the display where the task is located.
     *
     * <p>Split-screen is always allowed on the default display. For non-default (external)
     * displays, it is only allowed if the
     * {@link DesktopExperienceFlags#ENABLE_NON_DEFAULT_DISPLAY_SPLIT} flag is enabled.
     *
     * @return {@code true} if split-screen is allowed on the task's current display,
     *         {@code false} otherwise.
     */
    private boolean isSplitAllowedOnDisplay() {
        if (mTaskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
            return mTaskInfo.displayId == DEFAULT_DISPLAY
                    || DesktopExperienceFlags.ENABLE_NON_DEFAULT_DISPLAY_SPLIT.isTrue();
        }
        return true;
    }
}
}
+17 −0
Original line number Original line Diff line number Diff line
@@ -235,6 +235,10 @@ constructor(
                            override fun onAnimationEnd(animation: Animator) {
                            override fun onAnimationEnd(animation: Animator) {
                                veilAnimT.setAlpha(background, 1f).apply()
                                veilAnimT.setAlpha(background, 1f).apply()
                            }
                            }

                            override fun onAnimationCancel(animation: Animator) {
                                onAnimationEnd(animation)
                            }
                        }
                        }
                    )
                    )
                }
                }
@@ -252,6 +256,10 @@ constructor(
                            override fun onAnimationEnd(animation: Animator) {
                            override fun onAnimationEnd(animation: Animator) {
                                iconAnimT.setAlpha(icon, 1f).apply()
                                iconAnimT.setAlpha(icon, 1f).apply()
                            }
                            }

                            override fun onAnimationCancel(animation: Animator) {
                                onAnimationEnd(animation)
                            }
                        }
                        }
                    )
                    )
                }
                }
@@ -284,6 +292,7 @@ constructor(
            t.reparent(veil, parent)
            t.reparent(veil, parent)
            parentSurface = parent
            parentSurface = parent
        }
        }
        cancelAnimation()
        val backgroundColor =
        val backgroundColor =
            when (decorThemeUtil.getAppTheme(taskInfo)) {
            when (decorThemeUtil.getAppTheme(taskInfo)) {
                Theme.LIGHT -> lightColors.surfaceContainer
                Theme.LIGHT -> lightColors.surfaceContainer
@@ -390,6 +399,10 @@ constructor(
                        override fun onAnimationEnd(animation: Animator) {
                        override fun onAnimationEnd(animation: Animator) {
                            surfaceControlTransactionSupplier.get().hide(background).apply()
                            surfaceControlTransactionSupplier.get().hide(background).apply()
                        }
                        }

                        override fun onAnimationCancel(animation: Animator) {
                            onAnimationEnd(animation)
                        }
                    }
                    }
                )
                )
            }
            }
@@ -407,6 +420,10 @@ constructor(
                        override fun onAnimationEnd(animation: Animator) {
                        override fun onAnimationEnd(animation: Animator) {
                            surfaceControlTransactionSupplier.get().hide(icon).apply()
                            surfaceControlTransactionSupplier.get().hide(icon).apply()
                        }
                        }

                        override fun onAnimationCancel(animation: Animator) {
                            onAnimationEnd(animation)
                        }
                    }
                    }
                )
                )
            }
            }
+28 −0
Original line number Original line Diff line number Diff line
@@ -22,7 +22,9 @@ import android.platform.test.annotations.EnableFlags
import android.testing.AndroidTestingRunner
import android.testing.AndroidTestingRunner
import android.view.Display
import android.view.Display
import android.view.Display.DEFAULT_DISPLAY
import android.view.Display.DEFAULT_DISPLAY
import android.view.WindowManager.TRANSIT_CHANGE
import android.window.DisplayAreaInfo
import android.window.DisplayAreaInfo
import android.window.TransitionInfo
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.server.display.feature.flags.Flags as DisplayFlags
import com.android.server.display.feature.flags.Flags as DisplayFlags
import com.android.window.flags.Flags
import com.android.window.flags.Flags
@@ -60,6 +62,7 @@ import org.mockito.Mockito.spy
import org.mockito.Mockito.times
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verify
import org.mockito.kotlin.any
import org.mockito.kotlin.any
import org.mockito.kotlin.anyOrNull
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.clearInvocations
import org.mockito.kotlin.clearInvocations
import org.mockito.kotlin.eq
import org.mockito.kotlin.eq
@@ -181,6 +184,31 @@ class DesktopDisplayEventHandlerTest : ShellTestCase() {
                .warmUpDefaultDesk(DEFAULT_DISPLAY, mockDesktopRepository.userId)
                .warmUpDefaultDesk(DEFAULT_DISPLAY, mockDesktopRepository.userId)
        }
        }


    @Test
    fun onTransitionReady_emptyChanges_doesNothing() {
        val info = TransitionInfo(TRANSIT_CHANGE, 0)

        handler.onTransitionReady(mock(), info, mock(), mock())

        verify(mockDesktopTasksController, never())
            .onDisplayDpiChanging(any(), anyOrNull(), anyOrNull())
        verify(transitions, never()).unregisterObserver(any())
    }

    @Test
    fun onTransitionReady_displayIdNotInConfig_doesNothing() {
        val info = TransitionInfo(TRANSIT_CHANGE, 0)
        val mockChange: TransitionInfo.Change = mock()
        info.changes.add(mockChange)
        whenever(mockChange.endDisplayId).thenReturn(externalDisplayId)

        handler.onTransitionReady(mock(), info, mock(), mock())

        verify(mockDesktopTasksController, never())
            .onDisplayDpiChanging(any(), anyOrNull(), anyOrNull())
        verify(transitions, never()).unregisterObserver(any())
    }

    @Test
    @Test
    @EnableFlags(
    @EnableFlags(
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
        Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND,
+3 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,9 @@ interface MenuHandler {
    var preference: Preference?
    var preference: Preference?
    var showIconsInPopupMenu: Boolean
    var showIconsInPopupMenu: Boolean


    /** Provides a content description for the menu button. */
    var menuButtonContentDescription: String?

    interface OnMenuItemClickListener {
    interface OnMenuItemClickListener {
        fun onMenuItemClick(item: MenuItem, pref: Preference): Boolean
        fun onMenuItemClick(item: MenuItem, pref: Preference): Boolean
    }
    }
Loading