Merge "Move check for 'desktop mode active' to helper" into tm-qpr-dev
This commit is contained in:
@@ -49,7 +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.DesktopMode;
|
||||
import com.android.wm.shell.desktopmode.DesktopModeController;
|
||||
import com.android.wm.shell.draganddrop.DragAndDropController;
|
||||
import com.android.wm.shell.freeform.FreeformComponents;
|
||||
@@ -599,7 +599,7 @@ public abstract class WMShellModule {
|
||||
RootDisplayAreaOrganizer rootDisplayAreaOrganizer,
|
||||
@ShellMainThread Handler mainHandler
|
||||
) {
|
||||
if (DesktopModeConstants.IS_FEATURE_ENABLED) {
|
||||
if (DesktopMode.IS_SUPPORTED) {
|
||||
return Optional.of(new DesktopModeController(context, shellInit, shellTaskOrganizer,
|
||||
rootDisplayAreaOrganizer,
|
||||
mainHandler));
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.protolog.common.ProtoLog;
|
||||
|
||||
/**
|
||||
* Constants for desktop mode feature
|
||||
*/
|
||||
public class DesktopMode {
|
||||
|
||||
/**
|
||||
* Flag to indicate whether desktop mode is available on the device
|
||||
*/
|
||||
public static final boolean IS_SUPPORTED = SystemProperties.getBoolean(
|
||||
"persist.wm.debug.desktop_mode", false);
|
||||
|
||||
/**
|
||||
* Check if desktop mode is active
|
||||
*
|
||||
* @return {@code true} if active
|
||||
*/
|
||||
public static boolean isActive(Context context) {
|
||||
if (!IS_SUPPORTED) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int result = Settings.System.getIntForUser(context.getContentResolver(),
|
||||
Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT);
|
||||
ProtoLog.d(WM_SHELL_DESKTOP_MODE, "isDesktopModeEnabled=%s", result);
|
||||
return result != 0;
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
ProtoLog.e(WM_SHELL_DESKTOP_MODE, "Failed to read DESKTOP_MODE setting %s", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
@@ -65,8 +65,8 @@ public class DesktopModeController {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void updateDesktopModeEnabled(boolean enabled) {
|
||||
ProtoLog.d(WM_SHELL_DESKTOP_MODE, "updateDesktopModeState: enabled=%s", enabled);
|
||||
void updateDesktopModeActive(boolean active) {
|
||||
ProtoLog.d(WM_SHELL_DESKTOP_MODE, "updateDesktopModeActive: active=%s", active);
|
||||
|
||||
int displayId = mContext.getDisplayId();
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DesktopModeController {
|
||||
// container value)
|
||||
wct.merge(mShellTaskOrganizer.prepareClearFreeformForTasks(displayId), true /* transfer */);
|
||||
int targetWindowingMode;
|
||||
if (enabled) {
|
||||
if (active) {
|
||||
targetWindowingMode = WINDOWING_MODE_FREEFORM;
|
||||
} else {
|
||||
targetWindowingMode = WINDOWING_MODE_FULLSCREEN;
|
||||
@@ -118,20 +118,8 @@ public class DesktopModeController {
|
||||
}
|
||||
|
||||
private void desktopModeSettingChanged() {
|
||||
boolean enabled = isDesktopModeEnabled();
|
||||
updateDesktopModeEnabled(enabled);
|
||||
}
|
||||
|
||||
private boolean isDesktopModeEnabled() {
|
||||
try {
|
||||
int result = Settings.System.getIntForUser(mContext.getContentResolver(),
|
||||
Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT);
|
||||
ProtoLog.d(WM_SHELL_DESKTOP_MODE, "isDesktopModeEnabled=%s", result);
|
||||
return result != 0;
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
ProtoLog.e(WM_SHELL_DESKTOP_MODE, "Failed to read DESKTOP_MODE setting %s", e);
|
||||
return false;
|
||||
}
|
||||
boolean enabled = DesktopMode.isActive(mContext);
|
||||
updateDesktopModeActive(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +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;
|
||||
import com.android.wm.shell.desktopmode.DesktopMode;
|
||||
|
||||
/**
|
||||
* Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with
|
||||
@@ -164,7 +164,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL
|
||||
View caption = mResult.mRootView.findViewById(R.id.caption);
|
||||
caption.setOnTouchListener(mOnCaptionTouchListener);
|
||||
View maximize = caption.findViewById(R.id.maximize_window);
|
||||
if (DesktopModeConstants.IS_FEATURE_ENABLED) {
|
||||
if (DesktopMode.IS_SUPPORTED) {
|
||||
// Hide maximize button when desktop mode is available
|
||||
maximize.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DesktopModeControllerTest extends ShellTestCase {
|
||||
WINDOWING_MODE_FREEFORM)).thenReturn(displayWct);
|
||||
|
||||
// The test
|
||||
mController.updateDesktopModeEnabled(true);
|
||||
mController.updateDesktopModeActive(true);
|
||||
|
||||
ArgumentCaptor<WindowContainerTransaction> arg = ArgumentCaptor.forClass(
|
||||
WindowContainerTransaction.class);
|
||||
@@ -144,7 +144,7 @@ public class DesktopModeControllerTest extends ShellTestCase {
|
||||
WINDOWING_MODE_FULLSCREEN)).thenReturn(displayWct);
|
||||
|
||||
// The test
|
||||
mController.updateDesktopModeEnabled(false);
|
||||
mController.updateDesktopModeActive(false);
|
||||
|
||||
ArgumentCaptor<WindowContainerTransaction> arg = ArgumentCaptor.forClass(
|
||||
WindowContainerTransaction.class);
|
||||
|
||||
Reference in New Issue
Block a user