summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Merissa Mitchell <liyingtan@google.com> 2022-12-21 12:00:48 -0800
committer Merissa Mitchell <liyingtan@google.com> 2022-12-22 15:23:09 -0800
commit492e3399d252113aa24f26e8164f536e08759cd7 (patch)
tree4a1e44148be90e130a784405c8749f303c8c639f
parent42153dae5ac7b22a7e8762674931b8cd2efeee8a (diff)
Rename WindowDecor classes for Desktop Mode.
Bug: 260276028 Test: atest DesktopModeWindowDecorViewModelTests Change-Id: I5c6fbf8efd7d00a7f0fd6bb0d1339d31a66d53b7
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java (renamed from libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java)53
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java (renamed from libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java)12
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.java (renamed from libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModelTests.java)58
4 files changed, 67 insertions, 60 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 701a3a42fadd..d3b9fa5e628d 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
@@ -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;
@@ -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,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
index 299284f5bda6..b500f5fb0155 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
@@ -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;
@@ -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,
@@ -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,
@@ -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;
@@ -129,7 +130,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
mDesktopModeController = desktopModeController;
mDesktopTasksController = desktopTasksController;
- mCaptionWindowDecorFactory = captionWindowDecorFactory;
+ mDesktopModeWindowDecorFactory = desktopModeWindowDecorFactory;
mInputMonitorFactory = inputMonitorFactory;
}
@@ -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;
@@ -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) {
@@ -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);
@@ -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;
@@ -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();
@@ -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);
@@ -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);
@@ -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;
}
@@ -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()) {
@@ -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;
@@ -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;
@@ -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,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
index f7c7a87e6659..467f374f2110 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
@@ -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;
@@ -69,7 +69,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
private AdditionalWindow mHandleMenu;
- CaptionWindowDecoration(
+ DesktopModeWindowDecoration(
Context context,
DisplayController displayController,
ShellTaskOrganizer taskOrganizer,
@@ -424,7 +424,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
static class Factory {
- CaptionWindowDecoration create(
+ DesktopModeWindowDecoration create(
Context context,
DisplayController displayController,
ShellTaskOrganizer taskOrganizer,
@@ -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,
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModelTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.java
index 487583262011..a5e3a2e76ce5 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModelTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.java
@@ -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;
@@ -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,
@@ -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);
@@ -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,
@@ -139,7 +141,7 @@ public class CaptionWindowDecorViewModelTests extends ShellTestCase {
mMainHandler,
mMainChoreographer,
mSyncQueue);
- verify(mCaptionWindowDecoration).close();
+ verify(mDesktopModeWindowDecoration).close();
}
@Test
@@ -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,
@@ -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();
@@ -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();