Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ import com.android.wm.shell.unfold.animation.SplitTaskUnfoldAnimator; import com.android.wm.shell.unfold.animation.UnfoldTaskAnimator; import com.android.wm.shell.unfold.qualifier.UnfoldShellTransition; import com.android.wm.shell.unfold.qualifier.UnfoldTransition; import com.android.wm.shell.windowdecor.CaptionWindowDecorViewModel; import com.android.wm.shell.windowdecor.DesktopModeWindowDecorViewModel; import com.android.wm.shell.windowdecor.WindowDecorViewModel; import java.util.ArrayList; Loading Loading @@ -192,7 +192,7 @@ public abstract class WMShellModule { SyncTransactionQueue syncQueue, Optional<DesktopModeController> desktopModeController, Optional<DesktopTasksController> desktopTasksController) { return new CaptionWindowDecorViewModel( return new DesktopModeWindowDecorViewModel( context, mainHandler, mainChoreographer, Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java→libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +27 −26 Original line number Diff line number Diff line Loading @@ -61,12 +61,12 @@ import java.util.Optional; /** * View model for the window decoration with a caption and shadows. Works with * {@link CaptionWindowDecoration}. * {@link DesktopModeWindowDecoration}. */ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private static final String TAG = "CaptionViewModel"; private final CaptionWindowDecoration.Factory mCaptionWindowDecorFactory; public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { private static final String TAG = "DesktopModeWindowDecorViewModel"; private final DesktopModeWindowDecoration.Factory mDesktopModeWindowDecorFactory; private final ActivityTaskManager mActivityTaskManager; private final ShellTaskOrganizer mTaskOrganizer; private final Context mContext; Loading @@ -81,11 +81,12 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>(); private final SparseArray<CaptionWindowDecoration> mWindowDecorByTaskId = new SparseArray<>(); private final SparseArray<DesktopModeWindowDecoration> mWindowDecorByTaskId = new SparseArray<>(); private final DragStartListenerImpl mDragStartListener = new DragStartListenerImpl(); private InputMonitorFactory mInputMonitorFactory; public CaptionWindowDecorViewModel( public DesktopModeWindowDecorViewModel( Context context, Handler mainHandler, Choreographer mainChoreographer, Loading @@ -103,12 +104,12 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { syncQueue, desktopModeController, desktopTasksController, new CaptionWindowDecoration.Factory(), new DesktopModeWindowDecoration.Factory(), new InputMonitorFactory()); } @VisibleForTesting CaptionWindowDecorViewModel( DesktopModeWindowDecorViewModel( Context context, Handler mainHandler, Choreographer mainChoreographer, Loading @@ -117,7 +118,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SyncTransactionQueue syncQueue, Optional<DesktopModeController> desktopModeController, Optional<DesktopTasksController> desktopTasksController, CaptionWindowDecoration.Factory captionWindowDecorFactory, DesktopModeWindowDecoration.Factory desktopModeWindowDecorFactory, InputMonitorFactory inputMonitorFactory) { mContext = context; mMainHandler = mainHandler; Loading @@ -129,7 +130,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { mDesktopModeController = desktopModeController; mDesktopTasksController = desktopTasksController; mCaptionWindowDecorFactory = captionWindowDecorFactory; mDesktopModeWindowDecorFactory = desktopModeWindowDecorFactory; mInputMonitorFactory = inputMonitorFactory; } Loading @@ -151,7 +152,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void onTaskInfoChanged(RunningTaskInfo taskInfo) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (decoration == null) return; Loading @@ -170,7 +171,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (!shouldShowWindowDecor(taskInfo)) { if (decoration != null) { Loading @@ -191,7 +192,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { RunningTaskInfo taskInfo, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (decoration == null) return; decoration.relayout(taskInfo, startT, finishT); Loading @@ -199,7 +200,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void destroyWindowDecoration(RunningTaskInfo taskInfo) { final CaptionWindowDecoration decoration = final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.removeReturnOld(taskInfo.taskId); if (decoration == null) return; Loading Loading @@ -232,7 +233,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void onClick(View v) { CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); final int id = v.getId(); if (id == R.id.close_window) { WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -373,7 +374,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { boolean handled = false; if (event instanceof MotionEvent) { handled = true; CaptionWindowDecorViewModel.this DesktopModeWindowDecorViewModel.this .handleReceivedMotionEvent((MotionEvent) event, mInputMonitor); } finishInputEvent(event, handled); Loading Loading @@ -433,7 +434,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { */ private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) { if (DesktopModeStatus.isProto2Enabled()) { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) { handleCaptionThroughStatusBar(ev); Loading @@ -460,7 +461,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private void handleEventOutsideFocusedCaption(MotionEvent ev) { int action = ev.getActionMasked(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null) { return; } Loading @@ -480,7 +481,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: { // Begin drag through status bar if applicable. CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor != null) { boolean dragFromStatusBarAllowed = false; if (DesktopModeStatus.isProto2Enabled()) { Loading @@ -499,7 +500,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { break; } case MotionEvent.ACTION_UP: { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null) { mTransitionDragActive = false; return; Loading Loading @@ -529,11 +530,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } @Nullable private CaptionWindowDecoration getFocusedDecor() { private DesktopModeWindowDecoration getFocusedDecor() { int size = mWindowDecorByTaskId.size(); CaptionWindowDecoration focusedDecor = null; DesktopModeWindowDecoration focusedDecor = null; for (int i = 0; i < size; i++) { CaptionWindowDecoration decor = mWindowDecorByTaskId.valueAt(i); DesktopModeWindowDecoration decor = mWindowDecorByTaskId.valueAt(i); if (decor != null && decor.isFocused()) { focusedDecor = decor; break; Loading Loading @@ -571,13 +572,13 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId); DesktopModeWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (oldDecoration != null) { // close the old decoration if it exists to avoid two window decorations being added oldDecoration.close(); } final CaptionWindowDecoration windowDecoration = mCaptionWindowDecorFactory.create( final DesktopModeWindowDecoration windowDecoration = mDesktopModeWindowDecorFactory.create( mContext, mDisplayController, mTaskOrganizer, Loading libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java→libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +6 −6 Original line number Diff line number Diff line Loading @@ -43,12 +43,12 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; /** * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with * {@link CaptionWindowDecorViewModel}. The caption bar contains a handle, back button, and close * button. * {@link DesktopModeWindowDecorViewModel}. The caption bar contains a handle, back button, and * close button. * * The shadow's thickness is 20dp when the window is in focus and 5dp when the window isn't. */ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> { public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> { private final Handler mHandler; private final Choreographer mChoreographer; private final SyncTransactionQueue mSyncQueue; Loading @@ -69,7 +69,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL private AdditionalWindow mHandleMenu; CaptionWindowDecoration( DesktopModeWindowDecoration( Context context, DisplayController displayController, ShellTaskOrganizer taskOrganizer, Loading Loading @@ -424,7 +424,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL static class Factory { CaptionWindowDecoration create( DesktopModeWindowDecoration create( Context context, DisplayController displayController, ShellTaskOrganizer taskOrganizer, Loading @@ -433,7 +433,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL Handler handler, Choreographer choreographer, SyncTransactionQueue syncQueue) { return new CaptionWindowDecoration( return new DesktopModeWindowDecoration( context, displayController, taskOrganizer, Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModelTests.java→libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.java +32 −26 Original line number Diff line number Diff line Loading @@ -60,14 +60,14 @@ import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** Tests of {@link CaptionWindowDecorViewModel} */ /** Tests of {@link DesktopModeWindowDecorViewModel} */ @SmallTest public class CaptionWindowDecorViewModelTests extends ShellTestCase { public class DesktopModeWindowDecorViewModelTests extends ShellTestCase { private static final String TAG = "CaptionWindowDecorViewModelTests"; private static final String TAG = "DesktopModeWindowDecorViewModelTests"; @Mock private CaptionWindowDecoration mCaptionWindowDecoration; @Mock private CaptionWindowDecoration.Factory mCaptionWindowDecorFactory; @Mock private DesktopModeWindowDecoration mDesktopModeWindowDecoration; @Mock private DesktopModeWindowDecoration.Factory mDesktopModeWindowDecorFactory; @Mock private Handler mMainHandler; @Mock private Choreographer mMainChoreographer; Loading @@ -79,17 +79,17 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { @Mock private InputMonitor mInputMonitor; @Mock private InputManager mInputManager; @Mock private CaptionWindowDecorViewModel.InputMonitorFactory mMockInputMonitorFactory; @Mock private DesktopModeWindowDecorViewModel.InputMonitorFactory mMockInputMonitorFactory; private final List<InputManager> mMockInputManagers = new ArrayList<>(); private CaptionWindowDecorViewModel mCaptionWindowDecorViewModel; private DesktopModeWindowDecorViewModel mDesktopModeWindowDecorViewModel; @Before public void setUp() { mMockInputManagers.add(mInputManager); mCaptionWindowDecorViewModel = new CaptionWindowDecorViewModel( mDesktopModeWindowDecorViewModel = new DesktopModeWindowDecorViewModel( mContext, mMainHandler, mMainChoreographer, Loading @@ -98,12 +98,12 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { mSyncQueue, Optional.of(mDesktopModeController), Optional.of(mDesktopTasksController), mCaptionWindowDecorFactory, mDesktopModeWindowDecorFactory, mMockInputMonitorFactory ); doReturn(mCaptionWindowDecoration) .when(mCaptionWindowDecorFactory) doReturn(mDesktopModeWindowDecoration) .when(mDesktopModeWindowDecorFactory) .create(any(), any(), any(), any(), any(), any(), any(), any()); when(mMockInputMonitorFactory.create(any(), any())).thenReturn(mInputMonitor); Loading @@ -123,13 +123,15 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening( taskInfo, surfaceControl, startT, finishT); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_UNDEFINED); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_UNDEFINED); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); }); verify(mCaptionWindowDecorFactory) verify(mDesktopModeWindowDecorFactory) .create( mContext, mDisplayController, Loading @@ -139,7 +141,7 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { mMainHandler, mMainChoreographer, mSyncQueue); verify(mCaptionWindowDecoration).close(); verify(mDesktopModeWindowDecoration).close(); } @Test Loading @@ -153,14 +155,16 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_UNDEFINED); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_STANDARD); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); }); verify(mCaptionWindowDecorFactory, times(1)) verify(mDesktopModeWindowDecorFactory, times(1)) .create( mContext, mDisplayController, Loading @@ -183,9 +187,10 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening( taskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.destroyWindowDecoration(taskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo); }); verify(mMockInputMonitorFactory).create(any(), any()); verify(mInputMonitor).dispose(); Loading Loading @@ -214,13 +219,14 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.onTaskOpening(secondTaskInfo, surfaceControl, mDesktopModeWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening(secondTaskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.onTaskOpening(thirdTaskInfo, surfaceControl, mDesktopModeWindowDecorViewModel.onTaskOpening(thirdTaskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo); mCaptionWindowDecorViewModel.destroyWindowDecoration(taskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo); }); verify(mMockInputMonitorFactory, times(2)).create(any(), any()); verify(mInputMonitor, times(1)).dispose(); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ import com.android.wm.shell.unfold.animation.SplitTaskUnfoldAnimator; import com.android.wm.shell.unfold.animation.UnfoldTaskAnimator; import com.android.wm.shell.unfold.qualifier.UnfoldShellTransition; import com.android.wm.shell.unfold.qualifier.UnfoldTransition; import com.android.wm.shell.windowdecor.CaptionWindowDecorViewModel; import com.android.wm.shell.windowdecor.DesktopModeWindowDecorViewModel; import com.android.wm.shell.windowdecor.WindowDecorViewModel; import java.util.ArrayList; Loading Loading @@ -192,7 +192,7 @@ public abstract class WMShellModule { SyncTransactionQueue syncQueue, Optional<DesktopModeController> desktopModeController, Optional<DesktopTasksController> desktopTasksController) { return new CaptionWindowDecorViewModel( return new DesktopModeWindowDecorViewModel( context, mainHandler, mainChoreographer, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java→libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java +27 −26 Original line number Diff line number Diff line Loading @@ -61,12 +61,12 @@ import java.util.Optional; /** * View model for the window decoration with a caption and shadows. Works with * {@link CaptionWindowDecoration}. * {@link DesktopModeWindowDecoration}. */ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private static final String TAG = "CaptionViewModel"; private final CaptionWindowDecoration.Factory mCaptionWindowDecorFactory; public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel { private static final String TAG = "DesktopModeWindowDecorViewModel"; private final DesktopModeWindowDecoration.Factory mDesktopModeWindowDecorFactory; private final ActivityTaskManager mActivityTaskManager; private final ShellTaskOrganizer mTaskOrganizer; private final Context mContext; Loading @@ -81,11 +81,12 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>(); private final SparseArray<CaptionWindowDecoration> mWindowDecorByTaskId = new SparseArray<>(); private final SparseArray<DesktopModeWindowDecoration> mWindowDecorByTaskId = new SparseArray<>(); private final DragStartListenerImpl mDragStartListener = new DragStartListenerImpl(); private InputMonitorFactory mInputMonitorFactory; public CaptionWindowDecorViewModel( public DesktopModeWindowDecorViewModel( Context context, Handler mainHandler, Choreographer mainChoreographer, Loading @@ -103,12 +104,12 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { syncQueue, desktopModeController, desktopTasksController, new CaptionWindowDecoration.Factory(), new DesktopModeWindowDecoration.Factory(), new InputMonitorFactory()); } @VisibleForTesting CaptionWindowDecorViewModel( DesktopModeWindowDecorViewModel( Context context, Handler mainHandler, Choreographer mainChoreographer, Loading @@ -117,7 +118,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SyncTransactionQueue syncQueue, Optional<DesktopModeController> desktopModeController, Optional<DesktopTasksController> desktopTasksController, CaptionWindowDecoration.Factory captionWindowDecorFactory, DesktopModeWindowDecoration.Factory desktopModeWindowDecorFactory, InputMonitorFactory inputMonitorFactory) { mContext = context; mMainHandler = mainHandler; Loading @@ -129,7 +130,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { mDesktopModeController = desktopModeController; mDesktopTasksController = desktopTasksController; mCaptionWindowDecorFactory = captionWindowDecorFactory; mDesktopModeWindowDecorFactory = desktopModeWindowDecorFactory; mInputMonitorFactory = inputMonitorFactory; } Loading @@ -151,7 +152,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void onTaskInfoChanged(RunningTaskInfo taskInfo) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (decoration == null) return; Loading @@ -170,7 +171,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (!shouldShowWindowDecor(taskInfo)) { if (decoration != null) { Loading @@ -191,7 +192,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { RunningTaskInfo taskInfo, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { final CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (decoration == null) return; decoration.relayout(taskInfo, startT, finishT); Loading @@ -199,7 +200,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void destroyWindowDecoration(RunningTaskInfo taskInfo) { final CaptionWindowDecoration decoration = final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.removeReturnOld(taskInfo.taskId); if (decoration == null) return; Loading Loading @@ -232,7 +233,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { @Override public void onClick(View v) { CaptionWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId); final int id = v.getId(); if (id == R.id.close_window) { WindowContainerTransaction wct = new WindowContainerTransaction(); Loading Loading @@ -373,7 +374,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { boolean handled = false; if (event instanceof MotionEvent) { handled = true; CaptionWindowDecorViewModel.this DesktopModeWindowDecorViewModel.this .handleReceivedMotionEvent((MotionEvent) event, mInputMonitor); } finishInputEvent(event, handled); Loading Loading @@ -433,7 +434,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { */ private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) { if (DesktopModeStatus.isProto2Enabled()) { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) { handleCaptionThroughStatusBar(ev); Loading @@ -460,7 +461,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private void handleEventOutsideFocusedCaption(MotionEvent ev) { int action = ev.getActionMasked(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null) { return; } Loading @@ -480,7 +481,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: { // Begin drag through status bar if applicable. CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor != null) { boolean dragFromStatusBarAllowed = false; if (DesktopModeStatus.isProto2Enabled()) { Loading @@ -499,7 +500,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { break; } case MotionEvent.ACTION_UP: { CaptionWindowDecoration focusedDecor = getFocusedDecor(); DesktopModeWindowDecoration focusedDecor = getFocusedDecor(); if (focusedDecor == null) { mTransitionDragActive = false; return; Loading Loading @@ -529,11 +530,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } @Nullable private CaptionWindowDecoration getFocusedDecor() { private DesktopModeWindowDecoration getFocusedDecor() { int size = mWindowDecorByTaskId.size(); CaptionWindowDecoration focusedDecor = null; DesktopModeWindowDecoration focusedDecor = null; for (int i = 0; i < size; i++) { CaptionWindowDecoration decor = mWindowDecorByTaskId.valueAt(i); DesktopModeWindowDecoration decor = mWindowDecorByTaskId.valueAt(i); if (decor != null && decor.isFocused()) { focusedDecor = decor; break; Loading Loading @@ -571,13 +572,13 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { SurfaceControl taskSurface, SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT) { CaptionWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId); DesktopModeWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId); if (oldDecoration != null) { // close the old decoration if it exists to avoid two window decorations being added oldDecoration.close(); } final CaptionWindowDecoration windowDecoration = mCaptionWindowDecorFactory.create( final DesktopModeWindowDecoration windowDecoration = mDesktopModeWindowDecorFactory.create( mContext, mDisplayController, mTaskOrganizer, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java→libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java +6 −6 Original line number Diff line number Diff line Loading @@ -43,12 +43,12 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; /** * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with * {@link CaptionWindowDecorViewModel}. The caption bar contains a handle, back button, and close * button. * {@link DesktopModeWindowDecorViewModel}. The caption bar contains a handle, back button, and * close button. * * The shadow's thickness is 20dp when the window is in focus and 5dp when the window isn't. */ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> { public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLinearLayout> { private final Handler mHandler; private final Choreographer mChoreographer; private final SyncTransactionQueue mSyncQueue; Loading @@ -69,7 +69,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL private AdditionalWindow mHandleMenu; CaptionWindowDecoration( DesktopModeWindowDecoration( Context context, DisplayController displayController, ShellTaskOrganizer taskOrganizer, Loading Loading @@ -424,7 +424,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL static class Factory { CaptionWindowDecoration create( DesktopModeWindowDecoration create( Context context, DisplayController displayController, ShellTaskOrganizer taskOrganizer, Loading @@ -433,7 +433,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL Handler handler, Choreographer choreographer, SyncTransactionQueue syncQueue) { return new CaptionWindowDecoration( return new DesktopModeWindowDecoration( context, displayController, taskOrganizer, Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModelTests.java→libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.java +32 −26 Original line number Diff line number Diff line Loading @@ -60,14 +60,14 @@ import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; /** Tests of {@link CaptionWindowDecorViewModel} */ /** Tests of {@link DesktopModeWindowDecorViewModel} */ @SmallTest public class CaptionWindowDecorViewModelTests extends ShellTestCase { public class DesktopModeWindowDecorViewModelTests extends ShellTestCase { private static final String TAG = "CaptionWindowDecorViewModelTests"; private static final String TAG = "DesktopModeWindowDecorViewModelTests"; @Mock private CaptionWindowDecoration mCaptionWindowDecoration; @Mock private CaptionWindowDecoration.Factory mCaptionWindowDecorFactory; @Mock private DesktopModeWindowDecoration mDesktopModeWindowDecoration; @Mock private DesktopModeWindowDecoration.Factory mDesktopModeWindowDecorFactory; @Mock private Handler mMainHandler; @Mock private Choreographer mMainChoreographer; Loading @@ -79,17 +79,17 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { @Mock private InputMonitor mInputMonitor; @Mock private InputManager mInputManager; @Mock private CaptionWindowDecorViewModel.InputMonitorFactory mMockInputMonitorFactory; @Mock private DesktopModeWindowDecorViewModel.InputMonitorFactory mMockInputMonitorFactory; private final List<InputManager> mMockInputManagers = new ArrayList<>(); private CaptionWindowDecorViewModel mCaptionWindowDecorViewModel; private DesktopModeWindowDecorViewModel mDesktopModeWindowDecorViewModel; @Before public void setUp() { mMockInputManagers.add(mInputManager); mCaptionWindowDecorViewModel = new CaptionWindowDecorViewModel( mDesktopModeWindowDecorViewModel = new DesktopModeWindowDecorViewModel( mContext, mMainHandler, mMainChoreographer, Loading @@ -98,12 +98,12 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { mSyncQueue, Optional.of(mDesktopModeController), Optional.of(mDesktopTasksController), mCaptionWindowDecorFactory, mDesktopModeWindowDecorFactory, mMockInputMonitorFactory ); doReturn(mCaptionWindowDecoration) .when(mCaptionWindowDecorFactory) doReturn(mDesktopModeWindowDecoration) .when(mDesktopModeWindowDecorFactory) .create(any(), any(), any(), any(), any(), any(), any(), any()); when(mMockInputMonitorFactory.create(any(), any())).thenReturn(mInputMonitor); Loading @@ -123,13 +123,15 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening( taskInfo, surfaceControl, startT, finishT); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_UNDEFINED); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_UNDEFINED); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); }); verify(mCaptionWindowDecorFactory) verify(mDesktopModeWindowDecorFactory) .create( mContext, mDisplayController, Loading @@ -139,7 +141,7 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { mMainHandler, mMainChoreographer, mSyncQueue); verify(mCaptionWindowDecoration).close(); verify(mDesktopModeWindowDecoration).close(); } @Test Loading @@ -153,14 +155,16 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_UNDEFINED); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); taskInfo.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); taskInfo.configuration.windowConfiguration.setActivityType(ACTIVITY_TYPE_STANDARD); mCaptionWindowDecorViewModel.onTaskChanging(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskChanging( taskInfo, surfaceControl, startT, finishT); }); verify(mCaptionWindowDecorFactory, times(1)) verify(mDesktopModeWindowDecorFactory, times(1)) .create( mContext, mDisplayController, Loading @@ -183,9 +187,10 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening( taskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.destroyWindowDecoration(taskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo); }); verify(mMockInputMonitorFactory).create(any(), any()); verify(mInputMonitor).dispose(); Loading Loading @@ -214,13 +219,14 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase { final SurfaceControl.Transaction startT = mock(SurfaceControl.Transaction.class); final SurfaceControl.Transaction finishT = mock(SurfaceControl.Transaction.class); mCaptionWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.onTaskOpening(secondTaskInfo, surfaceControl, mDesktopModeWindowDecorViewModel.onTaskOpening(taskInfo, surfaceControl, startT, finishT); mDesktopModeWindowDecorViewModel.onTaskOpening(secondTaskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.onTaskOpening(thirdTaskInfo, surfaceControl, mDesktopModeWindowDecorViewModel.onTaskOpening(thirdTaskInfo, surfaceControl, startT, finishT); mCaptionWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo); mCaptionWindowDecorViewModel.destroyWindowDecoration(taskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(thirdTaskInfo); mDesktopModeWindowDecorViewModel.destroyWindowDecoration(taskInfo); }); verify(mMockInputMonitorFactory, times(2)).create(any(), any()); verify(mInputMonitor, times(1)).dispose(); Loading