From 1c44de9cdb2be34c72605acbccca202b4dbb117b Mon Sep 17 00:00:00 2001 From: Eghosa Ewansiha-Vlachavas Date: Mon, 13 May 2024 15:07:27 +0000 Subject: [PATCH] [2/n] Unify `DesktopModeStatus` between Shell and Sysui Remove `DesktopModeStatus` from quickstep and instead access through shell/shared to shell/shared. Flag: None Bug: 335401172 Test: atest -c NexusLauncherTests:com.android.quickstep.DesktopSystemShortcutTest Change-Id: I42f8b6e5f97f13fda22ed34bda4aa712ead53349 --- .../android/quickstep/DesktopModeStatus.java | 58 ------------------- .../quickstep/DesktopSystemShortcut.kt | 1 + .../android/quickstep/views/RecentsView.java | 2 +- .../quickstep/DesktopSystemShortcutTest.kt | 1 + 4 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 quickstep/src/com/android/quickstep/DesktopModeStatus.java diff --git a/quickstep/src/com/android/quickstep/DesktopModeStatus.java b/quickstep/src/com/android/quickstep/DesktopModeStatus.java deleted file mode 100644 index b1aae16a66..0000000000 --- a/quickstep/src/com/android/quickstep/DesktopModeStatus.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2024 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.quickstep; - -import android.content.Context; -import android.os.SystemProperties; - -import com.android.internal.annotations.VisibleForTesting; -import com.android.window.flags.Flags; - -// TODO(b/335401172): Explore unifying logic across core and shell -public class DesktopModeStatus { - - /** - * Flag to indicate whether to restrict desktop mode to supported devices. - */ - private static final boolean ENFORCE_DEVICE_RESTRICTIONS = SystemProperties.getBoolean( - "persist.wm.debug.desktop_mode_enforce_device_restrictions", true); - - /** - * Return {@code true} if desktop mode should be restricted to supported devices. - */ - @VisibleForTesting - public static boolean enforceDeviceRestrictions() { - return ENFORCE_DEVICE_RESTRICTIONS; - } - - /** - * Return {@code true} if the current device supports desktop mode. - */ - @VisibleForTesting - public static boolean isDesktopModeSupported(Context context) { - return context.getResources().getBoolean( - com.android.internal.R.bool.config_isDesktopModeSupported); - } - - /** - * Return {@code true} if desktop mode can be entered on the current device. - */ - public static boolean canEnterDesktopMode(Context context) { - return Flags.enableDesktopWindowingMode() - && (!enforceDeviceRestrictions() || isDesktopModeSupported(context)); - } -} diff --git a/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt b/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt index e33ef7f679..fdf4574d47 100644 --- a/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt +++ b/quickstep/src/com/android/quickstep/DesktopSystemShortcut.kt @@ -24,6 +24,7 @@ import com.android.launcher3.popup.SystemShortcut import com.android.quickstep.views.RecentsView import com.android.quickstep.views.RecentsViewContainer import com.android.quickstep.views.TaskView.TaskContainer +import com.android.wm.shell.shared.DesktopModeStatus /** A menu item, "Desktop", that allows the user to bring the current app into Desktop Windowing. */ class DesktopSystemShortcut( diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 731b839dd6..458f937f37 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -168,7 +168,6 @@ import com.android.launcher3.util.TranslateEdgeEffect; import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.util.ViewPool; import com.android.quickstep.BaseContainerInterface; -import com.android.quickstep.DesktopModeStatus; import com.android.quickstep.GestureState; import com.android.quickstep.OverviewCommandHelper; import com.android.quickstep.RecentsAnimationController; @@ -216,6 +215,7 @@ import com.android.systemui.shared.system.PackageManagerWrapper; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.wm.shell.common.pip.IPipAnimationListener; +import com.android.wm.shell.shared.DesktopModeStatus; import java.util.ArrayList; import java.util.Arrays; diff --git a/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt b/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt index d59aafb5de..a85595952f 100644 --- a/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DesktopSystemShortcutTest.kt @@ -34,6 +34,7 @@ import com.android.quickstep.views.TaskView import com.android.systemui.shared.recents.model.Task import com.android.systemui.shared.recents.model.Task.TaskKey import com.android.window.flags.Flags +import com.android.wm.shell.shared.DesktopModeStatus import com.google.common.truth.Truth.assertThat import org.junit.After import org.junit.Before