From 27ab8c084b36064543e42c6766a71d83dfdbfb66 Mon Sep 17 00:00:00 2001 From: Patrick Chang Date: Tue, 13 Dec 2022 04:25:15 +0000 Subject: [PATCH] Revert "Implement move to desktop and fullscreen" Revert submission 20653722 Reason for revert: DroidMonitor-triggered revert due to breakage , bug b/262303930. Reverted Changes: BUG: I0435e07a2:Create controller for desktop prototype 2 I9907038ad:Implement move to desktop and fullscreen Ic5de4d431:Implement showDesktopApps Change-Id: Iaf1a524e479ca1c7425d96e947764ce9e401c1a6 --- .../wm/shell/dagger/WMShellModule.java | 6 +- .../desktopmode/DesktopTasksController.kt | 57 ------------- .../CaptionWindowDecorViewModel.java | 85 ++++--------------- .../windowdecor/CaptionWindowDecoration.java | 46 +++------- .../desktopmode/DesktopTasksControllerTest.kt | 81 +++--------------- .../CaptionWindowDecorViewModelTests.java | 4 - 6 files changed, 43 insertions(+), 236 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index 701a3a42fadd3..8a6fe437e652d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -190,8 +190,7 @@ public abstract class WMShellModule { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, - Optional desktopModeController, - Optional desktopTasksController) { + Optional desktopModeController) { return new CaptionWindowDecorViewModel( context, mainHandler, @@ -199,8 +198,7 @@ public abstract class WMShellModule { taskOrganizer, displayController, syncQueue, - desktopModeController, - desktopTasksController); + desktopModeController); } // diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index b075b14fb0a48..8ded092f53830 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -16,11 +16,7 @@ package com.android.wm.shell.desktopmode -import android.app.ActivityManager -import android.app.WindowConfiguration import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME -import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED -import android.app.WindowConfiguration.WindowingMode import android.content.Context import android.view.WindowManager import android.window.WindowContainerTransaction @@ -88,59 +84,6 @@ class DesktopTasksController( } } - /** Move a task with given `taskId` to desktop */ - fun moveToDesktop(taskId: Int) { - shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToDesktop(task) } - } - - /** Move a task to desktop */ - fun moveToDesktop(task: ActivityManager.RunningTaskInfo) { - ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToDesktop: %d", task.taskId) - - val wct = WindowContainerTransaction() - // Bring other apps to front first - bringDesktopAppsToFront(wct) - - wct.setWindowingMode(task.getToken(), WindowConfiguration.WINDOWING_MODE_FREEFORM) - wct.reorder(task.getToken(), true /* onTop */) - - if (Transitions.ENABLE_SHELL_TRANSITIONS) { - transitions.startTransition(WindowManager.TRANSIT_CHANGE, wct, null /* handler */) - } else { - shellTaskOrganizer.applyTransaction(wct) - } - } - - /** Move a task with given `taskId` to fullscreen */ - fun moveToFullscreen(taskId: Int) { - shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToFullscreen(task) } - } - - /** Move a task to fullscreen */ - fun moveToFullscreen(task: ActivityManager.RunningTaskInfo) { - ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId) - - val wct = WindowContainerTransaction() - wct.setWindowingMode(task.getToken(), WindowConfiguration.WINDOWING_MODE_FULLSCREEN) - wct.setBounds(task.getToken(), null) - if (Transitions.ENABLE_SHELL_TRANSITIONS) { - transitions.startTransition(WindowManager.TRANSIT_CHANGE, wct, null /* handler */) - } else { - shellTaskOrganizer.applyTransaction(wct) - } - } - - /** - * Get windowing move for a given `taskId` - * - * @return [WindowingMode] for the task or [WINDOWING_MODE_UNDEFINED] if task is not found - */ - @WindowingMode - fun getTaskWindowingMode(taskId: Int): Int { - return shellTaskOrganizer.getRunningTaskInfo(taskId)?.windowingMode - ?: WINDOWING_MODE_UNDEFINED - } - private fun bringDesktopAppsToFront(wct: WindowContainerTransaction) { val activeTasks = desktopModeTaskRepository.getActiveTasks() diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java index 3cb40c543a821..afefd5dc63442 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java @@ -52,7 +52,6 @@ import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.desktopmode.DesktopModeController; import com.android.wm.shell.desktopmode.DesktopModeStatus; -import com.android.wm.shell.desktopmode.DesktopTasksController; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.transition.Transitions; @@ -77,7 +76,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private final SyncTransactionQueue mSyncQueue; private FreeformTaskTransitionStarter mTransitionStarter; private Optional mDesktopModeController; - private Optional mDesktopTasksController; private boolean mTransitionDragActive; private SparseArray mEventReceiversByDisplay = new SparseArray<>(); @@ -93,8 +91,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, - Optional desktopModeController, - Optional desktopTasksController) { + Optional desktopModeController) { this( context, mainHandler, @@ -103,7 +100,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { displayController, syncQueue, desktopModeController, - desktopTasksController, new CaptionWindowDecoration.Factory(), InputManager::getInstance); } @@ -116,7 +112,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { DisplayController displayController, SyncTransactionQueue syncQueue, Optional desktopModeController, - Optional desktopTasksController, CaptionWindowDecoration.Factory captionWindowDecorFactory, Supplier inputManagerSupplier) { @@ -128,7 +123,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { mDisplayController = displayController; mSyncQueue = syncQueue; mDesktopModeController = desktopModeController; - mDesktopTasksController = desktopTasksController; mCaptionWindowDecorFactory = captionWindowDecorFactory; mInputManagerSupplier = inputManagerSupplier; @@ -254,13 +248,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { decoration.createHandleMenu(); } else if (id == R.id.desktop_button) { mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); - mDesktopTasksController.ifPresent(c -> c.moveToDesktop(mTaskId)); decoration.closeHandleMenu(); } else if (id == R.id.fullscreen_button) { mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); - mDesktopTasksController.ifPresent(c -> c.moveToFullscreen(mTaskId)); decoration.closeHandleMenu(); - decoration.setButtonVisibility(false); + decoration.setButtonVisibility(); } } @@ -313,13 +305,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { */ private void handleEventForMove(MotionEvent e) { RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId); - if (DesktopModeStatus.isProto2Enabled() - && taskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) { - return; - } - if (DesktopModeStatus.isProto1Enabled() && mDesktopModeController.isPresent() - && mDesktopModeController.get().getDisplayAreaWindowingMode( - taskInfo.displayId) + if (mDesktopModeController.isPresent() + && mDesktopModeController.get().getDisplayAreaWindowingMode(taskInfo.displayId) == WINDOWING_MODE_FULLSCREEN) { return; } @@ -343,20 +330,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { .stableInsets().top; mDragResizeCallback.onDragResizeEnd( e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); - if (e.getRawY(dragPointerIdx) <= statusBarHeight) { - if (DesktopModeStatus.isProto2Enabled()) { - if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) { - // Switch a single task to fullscreen - mDesktopTasksController.ifPresent( - c -> c.moveToFullscreen(taskInfo)); - } - } else if (DesktopModeStatus.isProto1Enabled()) { - if (DesktopModeStatus.isActive(mContext)) { - // Turn off desktop mode - mDesktopModeController.ifPresent( - c -> c.setDesktopModeActive(false)); - } - } + if (e.getRawY(dragPointerIdx) <= statusBarHeight + && DesktopModeStatus.isActive(mContext)) { + mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); } break; } @@ -444,27 +420,13 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { * @param ev the {@link MotionEvent} received by {@link EventReceiver} */ private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) { - if (DesktopModeStatus.isProto2Enabled()) { - CaptionWindowDecoration focusedDecor = getFocusedDecor(); - if (focusedDecor == null - || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) { - handleCaptionThroughStatusBar(ev); - } - } else if (DesktopModeStatus.isProto1Enabled()) { - if (!DesktopModeStatus.isActive(mContext)) { - handleCaptionThroughStatusBar(ev); - } + if (!DesktopModeStatus.isActive(mContext)) { + handleCaptionThroughStatusBar(ev); } handleEventOutsideFocusedCaption(ev); // Prevent status bar from reacting to a caption drag. - if (DesktopModeStatus.isProto2Enabled()) { - if (mTransitionDragActive) { - inputMonitor.pilferPointers(); - } - } else if (DesktopModeStatus.isProto1Enabled()) { - if (mTransitionDragActive && !DesktopModeStatus.isActive(mContext)) { - inputMonitor.pilferPointers(); - } + if (mTransitionDragActive && !DesktopModeStatus.isActive(mContext)) { + inputMonitor.pilferPointers(); } } @@ -493,20 +455,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { case MotionEvent.ACTION_DOWN: { // Begin drag through status bar if applicable. CaptionWindowDecoration focusedDecor = getFocusedDecor(); - if (focusedDecor != null) { - boolean dragFromStatusBarAllowed = false; - if (DesktopModeStatus.isProto2Enabled()) { - // In proto2 any full screen task can be dragged to freeform - dragFromStatusBarAllowed = focusedDecor.mTaskInfo.getWindowingMode() - == WINDOWING_MODE_FULLSCREEN; - } else if (DesktopModeStatus.isProto1Enabled()) { - // In proto1 task can be dragged to freeform when not in desktop mode - dragFromStatusBarAllowed = !DesktopModeStatus.isActive(mContext); - } - - if (dragFromStatusBarAllowed && focusedDecor.checkTouchEventInHandle(ev)) { - mTransitionDragActive = true; - } + if (focusedDecor != null && !DesktopModeStatus.isActive(mContext) + && focusedDecor.checkTouchEventInHandle(ev)) { + mTransitionDragActive = true; } break; } @@ -521,13 +472,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { int statusBarHeight = mDisplayController .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top; if (ev.getY() > statusBarHeight) { - if (DesktopModeStatus.isProto2Enabled()) { - mDesktopTasksController.ifPresent( - c -> c.moveToDesktop(focusedDecor.mTaskInfo)); - } else if (DesktopModeStatus.isProto1Enabled()) { - mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); - } - + mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); return; } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java index f7c7a87e66596..037ca2031254f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java @@ -16,9 +16,8 @@ package com.android.wm.shell.windowdecor; -import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; - import android.app.ActivityManager; +import android.app.WindowConfiguration; import android.content.Context; import android.content.res.ColorStateList; import android.content.res.Resources; @@ -118,7 +117,7 @@ public class CaptionWindowDecoration extends WindowDecoration(mMockInputManagers, () -> mock(InputManager.class))); mCaptionWindowDecorViewModel.setEventReceiverFactory(mEventReceiverFactory);