Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java→libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMode.java +58 −0 Original line number Diff line number Diff line Loading @@ -16,16 +16,43 @@ 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 DesktopModeConstants { public class DesktopMode { /** * Flag to indicate whether desktop mode is available on the device */ public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean( 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; } } } libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +5 −17 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; Loading Loading @@ -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); } } } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeConstants.java→libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMode.java +58 −0 Original line number Diff line number Diff line Loading @@ -16,16 +16,43 @@ 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 DesktopModeConstants { public class DesktopMode { /** * Flag to indicate whether desktop mode is available on the device */ public static final boolean IS_FEATURE_ENABLED = SystemProperties.getBoolean( 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; } } }
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +5 −17 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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; Loading Loading @@ -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); } } }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeControllerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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); Loading