From 10f2250f12739c429d3dfe0870265cda8ec8babb Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 17 Aug 2022 14:52:11 -0700 Subject: [PATCH] Hide some options when desktop mode is available When desktop mode is available (flag enabled), hide some freeform specific buttons: - hide freeform from app menu in recents - hide maximize button from window captions Bug: 242906219 Test: test that buttons are not shown when desktop mode is enabled Change-Id: I4c3e3f5ce1221eef853d73e2b395b362037c9cca --- .../wm/shell/dagger/WMShellModule.java | 3 +- .../desktopmode/DesktopModeConstants.java | 31 +++++++++++++++++++ .../desktopmode/DesktopModeController.java | 4 --- .../windowdecor/CaptionWindowDecoration.java | 9 +++++- 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java 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 a7dbc38169c31..2bcc134f9dd53 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 @@ -49,6 +49,7 @@ import com.android.wm.shell.common.TaskStackListenerImpl; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.annotations.ShellBackgroundThread; import com.android.wm.shell.common.annotations.ShellMainThread; +import com.android.wm.shell.desktopmode.DesktopModeConstants; import com.android.wm.shell.desktopmode.DesktopModeController; import com.android.wm.shell.draganddrop.DragAndDropController; import com.android.wm.shell.freeform.FreeformComponents; @@ -587,7 +588,7 @@ public abstract class WMShellModule { RootDisplayAreaOrganizer rootDisplayAreaOrganizer, @ShellMainThread Handler mainHandler ) { - if (DesktopModeController.IS_FEATURE_ENABLED) { + if (DesktopModeConstants.IS_FEATURE_ENABLED) { return Optional.of(new DesktopModeController(context, shellInit, shellTaskOrganizer, rootDisplayAreaOrganizer, mainHandler)); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java new file mode 100644 index 0000000000000..e62a63a910e78 --- /dev/null +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.wm.shell.desktopmode; + +import android.os.SystemProperties; + +/** + * Constants for desktop mode feature + */ +public class DesktopModeConstants { + + /** + * Flag to indicate whether desktop mode is available on the device + */ + public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean( + "persist.wm.debug.desktop_mode", false); +} diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java index c59d0b66168d0..5849e163f0e2f 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java @@ -25,7 +25,6 @@ import android.content.Context; import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; -import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.window.WindowContainerTransaction; @@ -44,9 +43,6 @@ import com.android.wm.shell.sysui.ShellInit; */ public class DesktopModeController { - public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean( - "persist.wm.debug.desktop_mode", false); - private final Context mContext; private final ShellTaskOrganizer mShellTaskOrganizer; private final RootDisplayAreaOrganizer mRootDisplayAreaOrganizer; 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 98b5ee9f0cfb3..dc3deb1a927ce 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 @@ -34,6 +34,7 @@ import com.android.wm.shell.R; import com.android.wm.shell.ShellTaskOrganizer; import com.android.wm.shell.common.DisplayController; import com.android.wm.shell.common.SyncTransactionQueue; +import com.android.wm.shell.desktopmode.DesktopModeConstants; /** * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with @@ -163,7 +164,13 @@ public class CaptionWindowDecoration extends WindowDecoration