Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +4 −2 Original line number Diff line number Diff line Loading @@ -700,13 +700,15 @@ public abstract class WMShellModule { ShellTaskOrganizer shellTaskOrganizer, Transitions transitions, Optional<RecentTasksController> recentTasksController, HomeTransitionObserver homeTransitionObserver) { HomeTransitionObserver homeTransitionObserver, DisplayController displayController) { return new RecentsTransitionHandler( shellInit, shellTaskOrganizer, transitions, recentTasksController.orElse(null), homeTransitionObserver); homeTransitionObserver, displayController); } // Loading libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java +13 −5 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.internal.os.IResultReceiver; import com.android.internal.protolog.ProtoLog; import com.android.wm.shell.Flags; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.R; Loading Loading @@ -121,18 +122,21 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, private final HomeTransitionObserver mHomeTransitionObserver; private @Nullable Color mBackgroundColor; private final DisplayController mDisplayController; public RecentsTransitionHandler( @NonNull ShellInit shellInit, @NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull Transitions transitions, @Nullable RecentTasksController recentTasksController, @NonNull HomeTransitionObserver homeTransitionObserver) { @NonNull HomeTransitionObserver homeTransitionObserver, @NonNull DisplayController displayController) { mShellTaskOrganizer = shellTaskOrganizer; mTransitions = transitions; mExecutor = transitions.getMainExecutor(); mRecentTasksController = recentTasksController; mHomeTransitionObserver = homeTransitionObserver; mDisplayController = displayController; if (recentTasksController == null) return; shellInit.addInitCallback(this::onInit, this); } Loading Loading @@ -1636,24 +1640,28 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, } } private static void setCornerRadiusForFreeformTasks( private void setCornerRadiusForFreeformTasks( Context context, SurfaceControl.Transaction t, ArrayList<TaskState> tasks) { if (!ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX.isTrue()) { return; } int cornerRadius = getCornerRadius(context); for (int i = 0; i < tasks.size(); ++i) { TaskState task = tasks.get(i); if (task.mTaskInfo != null && task.mTaskInfo.isFreeform()) { int cornerRadius = getCornerRadius(context, task.mTaskInfo.displayId); t.setCornerRadius(task.mTaskSurface, cornerRadius); } } } private static int getCornerRadius(Context context) { return context.getResources().getDimensionPixelSize( private int getCornerRadius(Context context, int displayId) { Context displayContext = mDisplayController.getDisplayContext(displayId); if (displayContext == null) { displayContext = context; } return displayContext.getResources().getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java +40 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.TestRunningTaskInfoBuilder; import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.desktopmode.DesktopRepository; Loading Loading @@ -102,6 +103,8 @@ import java.util.Optional; public class RecentsTransitionHandlerTest extends ShellTestCase { private static final int FREEFORM_TASK_CORNER_RADIUS = 32; private static final int FREEFORM_TASK_CORNER_RADIUS_ON_CD = 24; private static final int CONNECTED_DISPLAY_ID = 1; @Mock private Context mContext; Loading @@ -125,6 +128,9 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { private UserManager mUserManager; @Mock private DesktopRepository mDesktopRepository; @Mock private DisplayController mDisplayController; @Mock private Context mConnectedDisplayContext; @Mock private Resources mConnectedDisplayResources; private ShellTaskOrganizer mShellTaskOrganizer; private RecentTasksController mRecentTasksController; Loading @@ -151,6 +157,12 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { when(mResources.getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius) ).thenReturn(FREEFORM_TASK_CORNER_RADIUS); when(mDisplayController.getDisplayContext(CONNECTED_DISPLAY_ID)).thenReturn( mConnectedDisplayContext); when(mConnectedDisplayContext.getResources()).thenReturn(mConnectedDisplayResources); when(mConnectedDisplayResources.getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius) ).thenReturn(FREEFORM_TASK_CORNER_RADIUS_ON_CD); mShellInit = spy(new ShellInit(mMainExecutor)); mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler, mDisplayInsetsController, mUserManager, mMainExecutor)); Loading @@ -165,7 +177,8 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { doReturn(mMainExecutor).when(mTransitions).getMainExecutor(); mRecentsTransitionHandler = new RecentsTransitionHandler(mShellInit, mShellTaskOrganizer, mTransitions, mRecentTasksController, mock(HomeTransitionObserver.class)); mTransitions, mRecentTasksController, mock(HomeTransitionObserver.class), mDisplayController); // By default use a mock finish transaction since we are sending transitions that don't have // real surface controls mRecentsTransitionHandler.setFinishTransactionSupplier( Loading Loading @@ -440,6 +453,32 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS); } @Test @EnableFlags(FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX) public void testFinish_returningToFreeformTasks_setsCornerRadiusOnConnectedDisplay() { ActivityManager.RunningTaskInfo freeformTask = new TestRunningTaskInfoBuilder().setWindowingMode( WINDOWING_MODE_FREEFORM).setDisplayId(CONNECTED_DISPLAY_ID).build(); TransitionInfo transitionInfo = new TransitionInfoBuilder(TRANSIT_CLOSE) .addChange(TRANSIT_CLOSE, freeformTask) .build(); SurfaceControl leash = transitionInfo.getChanges().get(0).getLeash(); final IBinder transition = startRecentsTransition(/* synthetic= */ false); SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mRecentsTransitionHandler.setFinishTransactionSupplier(() -> finishT); mRecentsTransitionHandler.startAnimation( transition, transitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); mRecentsTransitionHandler.findController(transition).finish(/* toHome= */ false, false /* sendUserLeaveHint */, mock(IResultReceiver.class)); mMainExecutor.flushAll(); verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS_ON_CD); } private IBinder startRecentsTransition(boolean synthetic) { return startRecentsTransition(synthetic, mock(IRecentsAnimationRunner.class)); } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +2 −1 Original line number Diff line number Diff line Loading @@ -1325,7 +1325,8 @@ public class ShellTransitionTests extends ShellTestCase { doReturn(mContext).when(mockRecentsTaskController).getContext(); final RecentsTransitionHandler recentsHandler = new RecentsTransitionHandler(shellInit, mock(ShellTaskOrganizer.class), transitions, mockRecentsTaskController, mock(HomeTransitionObserver.class)); mockRecentsTaskController, mock(HomeTransitionObserver.class), mock(DisplayController.class)); recentsHandler.setFinishTransactionSupplier( () -> mock(SurfaceControl.Transaction.class)); transitions.replaceDefaultHandlerForTest(mDefaultHandler); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +4 −2 Original line number Diff line number Diff line Loading @@ -700,13 +700,15 @@ public abstract class WMShellModule { ShellTaskOrganizer shellTaskOrganizer, Transitions transitions, Optional<RecentTasksController> recentTasksController, HomeTransitionObserver homeTransitionObserver) { HomeTransitionObserver homeTransitionObserver, DisplayController displayController) { return new RecentsTransitionHandler( shellInit, shellTaskOrganizer, transitions, recentTasksController.orElse(null), homeTransitionObserver); homeTransitionObserver, displayController); } // Loading
libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java +13 −5 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.internal.os.IResultReceiver; import com.android.internal.protolog.ProtoLog; import com.android.wm.shell.Flags; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.protolog.ShellProtoLogGroup; import com.android.wm.shell.shared.R; Loading Loading @@ -121,18 +122,21 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, private final HomeTransitionObserver mHomeTransitionObserver; private @Nullable Color mBackgroundColor; private final DisplayController mDisplayController; public RecentsTransitionHandler( @NonNull ShellInit shellInit, @NonNull ShellTaskOrganizer shellTaskOrganizer, @NonNull Transitions transitions, @Nullable RecentTasksController recentTasksController, @NonNull HomeTransitionObserver homeTransitionObserver) { @NonNull HomeTransitionObserver homeTransitionObserver, @NonNull DisplayController displayController) { mShellTaskOrganizer = shellTaskOrganizer; mTransitions = transitions; mExecutor = transitions.getMainExecutor(); mRecentTasksController = recentTasksController; mHomeTransitionObserver = homeTransitionObserver; mDisplayController = displayController; if (recentTasksController == null) return; shellInit.addInitCallback(this::onInit, this); } Loading Loading @@ -1636,24 +1640,28 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler, } } private static void setCornerRadiusForFreeformTasks( private void setCornerRadiusForFreeformTasks( Context context, SurfaceControl.Transaction t, ArrayList<TaskState> tasks) { if (!ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX.isTrue()) { return; } int cornerRadius = getCornerRadius(context); for (int i = 0; i < tasks.size(); ++i) { TaskState task = tasks.get(i); if (task.mTaskInfo != null && task.mTaskInfo.isFreeform()) { int cornerRadius = getCornerRadius(context, task.mTaskInfo.displayId); t.setCornerRadius(task.mTaskSurface, cornerRadius); } } } private static int getCornerRadius(Context context) { return context.getResources().getDimensionPixelSize( private int getCornerRadius(Context context, int displayId) { Context displayContext = mDisplayController.getDisplayContext(displayId); if (displayContext == null) { displayContext = context; } return displayContext.getResources().getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/recents/RecentsTransitionHandlerTest.java +40 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.TestRunningTaskInfoBuilder; import com.android.wm.shell.TestShellExecutor; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.DisplayInsetsController; import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.desktopmode.DesktopRepository; Loading Loading @@ -102,6 +103,8 @@ import java.util.Optional; public class RecentsTransitionHandlerTest extends ShellTestCase { private static final int FREEFORM_TASK_CORNER_RADIUS = 32; private static final int FREEFORM_TASK_CORNER_RADIUS_ON_CD = 24; private static final int CONNECTED_DISPLAY_ID = 1; @Mock private Context mContext; Loading @@ -125,6 +128,9 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { private UserManager mUserManager; @Mock private DesktopRepository mDesktopRepository; @Mock private DisplayController mDisplayController; @Mock private Context mConnectedDisplayContext; @Mock private Resources mConnectedDisplayResources; private ShellTaskOrganizer mShellTaskOrganizer; private RecentTasksController mRecentTasksController; Loading @@ -151,6 +157,12 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { when(mResources.getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius) ).thenReturn(FREEFORM_TASK_CORNER_RADIUS); when(mDisplayController.getDisplayContext(CONNECTED_DISPLAY_ID)).thenReturn( mConnectedDisplayContext); when(mConnectedDisplayContext.getResources()).thenReturn(mConnectedDisplayResources); when(mConnectedDisplayResources.getDimensionPixelSize( R.dimen.desktop_windowing_freeform_rounded_corner_radius) ).thenReturn(FREEFORM_TASK_CORNER_RADIUS_ON_CD); mShellInit = spy(new ShellInit(mMainExecutor)); mShellController = spy(new ShellController(mContext, mShellInit, mShellCommandHandler, mDisplayInsetsController, mUserManager, mMainExecutor)); Loading @@ -165,7 +177,8 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { doReturn(mMainExecutor).when(mTransitions).getMainExecutor(); mRecentsTransitionHandler = new RecentsTransitionHandler(mShellInit, mShellTaskOrganizer, mTransitions, mRecentTasksController, mock(HomeTransitionObserver.class)); mTransitions, mRecentTasksController, mock(HomeTransitionObserver.class), mDisplayController); // By default use a mock finish transaction since we are sending transitions that don't have // real surface controls mRecentsTransitionHandler.setFinishTransactionSupplier( Loading Loading @@ -440,6 +453,32 @@ public class RecentsTransitionHandlerTest extends ShellTestCase { verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS); } @Test @EnableFlags(FLAG_ENABLE_DESKTOP_RECENTS_TRANSITIONS_CORNERS_BUGFIX) public void testFinish_returningToFreeformTasks_setsCornerRadiusOnConnectedDisplay() { ActivityManager.RunningTaskInfo freeformTask = new TestRunningTaskInfoBuilder().setWindowingMode( WINDOWING_MODE_FREEFORM).setDisplayId(CONNECTED_DISPLAY_ID).build(); TransitionInfo transitionInfo = new TransitionInfoBuilder(TRANSIT_CLOSE) .addChange(TRANSIT_CLOSE, freeformTask) .build(); SurfaceControl leash = transitionInfo.getChanges().get(0).getLeash(); final IBinder transition = startRecentsTransition(/* synthetic= */ false); SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mRecentsTransitionHandler.setFinishTransactionSupplier(() -> finishT); mRecentsTransitionHandler.startAnimation( transition, transitionInfo, new StubTransaction(), new StubTransaction(), mock(Transitions.TransitionFinishCallback.class)); mRecentsTransitionHandler.findController(transition).finish(/* toHome= */ false, false /* sendUserLeaveHint */, mock(IResultReceiver.class)); mMainExecutor.flushAll(); verify(finishT).setCornerRadius(leash, FREEFORM_TASK_CORNER_RADIUS_ON_CD); } private IBinder startRecentsTransition(boolean synthetic) { return startRecentsTransition(synthetic, mock(IRecentsAnimationRunner.class)); } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +2 −1 Original line number Diff line number Diff line Loading @@ -1325,7 +1325,8 @@ public class ShellTransitionTests extends ShellTestCase { doReturn(mContext).when(mockRecentsTaskController).getContext(); final RecentsTransitionHandler recentsHandler = new RecentsTransitionHandler(shellInit, mock(ShellTaskOrganizer.class), transitions, mockRecentsTaskController, mock(HomeTransitionObserver.class)); mockRecentsTaskController, mock(HomeTransitionObserver.class), mock(DisplayController.class)); recentsHandler.setFinishTransactionSupplier( () -> mock(SurfaceControl.Transaction.class)); transitions.replaceDefaultHandlerForTest(mDefaultHandler); Loading