Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +12 −6 Original line number Diff line number Diff line Loading @@ -687,10 +687,13 @@ public abstract class WMShellBaseModule { @WMSingleton @Provides static Optional<DesktopModeController> providesDesktopModeController( @DynamicOverride Optional<DesktopModeController> desktopModeController) { static Optional<DesktopModeController> provideDesktopModeController( @DynamicOverride Optional<Lazy<DesktopModeController>> desktopModeController) { // Use optional-of-lazy for the dependency that this provider relies on. // Lazy ensures that this provider will not be the cause the dependency is created // when it will not be returned due to the condition below. if (DesktopModeStatus.IS_SUPPORTED) { return desktopModeController; return desktopModeController.map(Lazy::get); } return Optional.empty(); } Loading @@ -701,10 +704,13 @@ public abstract class WMShellBaseModule { @WMSingleton @Provides static Optional<DesktopModeTaskRepository> providesDesktopTaskRepository( @DynamicOverride Optional<DesktopModeTaskRepository> desktopModeTaskRepository) { static Optional<DesktopModeTaskRepository> provideDesktopTaskRepository( @DynamicOverride Optional<Lazy<DesktopModeTaskRepository>> desktopModeTaskRepository) { // Use optional-of-lazy for the dependency that this provider relies on. // Lazy ensures that this provider will not be the cause the dependency is created // when it will not be returned due to the condition below. if (DesktopModeStatus.IS_SUPPORTED) { return desktopModeTaskRepository; return desktopModeTaskRepository.map(Lazy::get); } return Optional.empty(); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +1 −1 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ public abstract class WMShellModule { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, @DynamicOverride DesktopModeController desktopModeController) { Optional<DesktopModeController> desktopModeController) { return new CaptionWindowDecorViewModel( context, mainHandler, Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +3 −1 Original line number Diff line number Diff line Loading @@ -100,8 +100,10 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll mDesktopModeTaskRepository = desktopModeTaskRepository; mMainExecutor = mainExecutor; mSettingsObserver = new SettingsObserver(mContext, mainHandler); if (DesktopModeStatus.isSupported()) { shellInit.addInitCallback(this::onInit, this); } } private void onInit() { ProtoLog.d(WM_SHELL_DESKTOP_MODE, "Initialize DesktopModeController"); Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java +8 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,13 @@ public class DesktopModeStatus { public static final boolean IS_SUPPORTED = SystemProperties.getBoolean( "persist.wm.debug.desktop_mode", false); /** * Return {@code true} if desktop mode support is enabled */ public static boolean isSupported() { return IS_SUPPORTED; } /** * Check if desktop mode is active * Loading @@ -54,4 +61,5 @@ public class DesktopModeStatus { return false; } } } libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +11 −10 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.transition.Transitions; import java.util.Optional; import java.util.function.Supplier; /** Loading @@ -74,7 +75,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private final DisplayController mDisplayController; private final SyncTransactionQueue mSyncQueue; private FreeformTaskTransitionStarter mTransitionStarter; private DesktopModeController mDesktopModeController; private Optional<DesktopModeController> mDesktopModeController; private boolean mTransitionDragActive; private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>(); Loading @@ -90,7 +91,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, DesktopModeController desktopModeController) { Optional<DesktopModeController> desktopModeController) { this( context, mainHandler, Loading @@ -110,7 +111,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, DesktopModeController desktopModeController, Optional<DesktopModeController> desktopModeController, CaptionWindowDecoration.Factory captionWindowDecorFactory, Supplier<InputManager> inputManagerSupplier) { Loading Loading @@ -246,10 +247,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } else if (id == R.id.caption_handle) { decoration.createHandleMenu(); } else if (id == R.id.desktop_button) { mDesktopModeController.setDesktopModeActive(true); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); decoration.closeHandleMenu(); } else if (id == R.id.fullscreen_button) { mDesktopModeController.setDesktopModeActive(false); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); decoration.closeHandleMenu(); decoration.setButtonVisibility(); } Loading Loading @@ -304,9 +305,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { */ private void handleEventForMove(MotionEvent e) { RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId); int windowingMode = mDesktopModeController .getDisplayAreaWindowingMode(taskInfo.displayId); if (windowingMode == WINDOWING_MODE_FULLSCREEN) { if (mDesktopModeController.isPresent() && mDesktopModeController.get().getDisplayAreaWindowingMode(taskInfo.displayId) == WINDOWING_MODE_FULLSCREEN) { return; } switch (e.getActionMasked()) { Loading @@ -331,7 +332,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); if (e.getRawY(dragPointerIdx) <= statusBarHeight && DesktopModeStatus.isActive(mContext)) { mDesktopModeController.setDesktopModeActive(false); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); } break; } Loading Loading @@ -471,7 +472,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { int statusBarHeight = mDisplayController .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top; if (ev.getY() > statusBarHeight) { mDesktopModeController.setDesktopModeActive(true); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); return; } } Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellBaseModule.java +12 −6 Original line number Diff line number Diff line Loading @@ -687,10 +687,13 @@ public abstract class WMShellBaseModule { @WMSingleton @Provides static Optional<DesktopModeController> providesDesktopModeController( @DynamicOverride Optional<DesktopModeController> desktopModeController) { static Optional<DesktopModeController> provideDesktopModeController( @DynamicOverride Optional<Lazy<DesktopModeController>> desktopModeController) { // Use optional-of-lazy for the dependency that this provider relies on. // Lazy ensures that this provider will not be the cause the dependency is created // when it will not be returned due to the condition below. if (DesktopModeStatus.IS_SUPPORTED) { return desktopModeController; return desktopModeController.map(Lazy::get); } return Optional.empty(); } Loading @@ -701,10 +704,13 @@ public abstract class WMShellBaseModule { @WMSingleton @Provides static Optional<DesktopModeTaskRepository> providesDesktopTaskRepository( @DynamicOverride Optional<DesktopModeTaskRepository> desktopModeTaskRepository) { static Optional<DesktopModeTaskRepository> provideDesktopTaskRepository( @DynamicOverride Optional<Lazy<DesktopModeTaskRepository>> desktopModeTaskRepository) { // Use optional-of-lazy for the dependency that this provider relies on. // Lazy ensures that this provider will not be the cause the dependency is created // when it will not be returned due to the condition below. if (DesktopModeStatus.IS_SUPPORTED) { return desktopModeTaskRepository; return desktopModeTaskRepository.map(Lazy::get); } return Optional.empty(); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +1 −1 Original line number Diff line number Diff line Loading @@ -189,7 +189,7 @@ public abstract class WMShellModule { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, @DynamicOverride DesktopModeController desktopModeController) { Optional<DesktopModeController> desktopModeController) { return new CaptionWindowDecorViewModel( context, mainHandler, Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +3 −1 Original line number Diff line number Diff line Loading @@ -100,8 +100,10 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll mDesktopModeTaskRepository = desktopModeTaskRepository; mMainExecutor = mainExecutor; mSettingsObserver = new SettingsObserver(mContext, mainHandler); if (DesktopModeStatus.isSupported()) { shellInit.addInitCallback(this::onInit, this); } } private void onInit() { ProtoLog.d(WM_SHELL_DESKTOP_MODE, "Initialize DesktopModeController"); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeStatus.java +8 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,13 @@ public class DesktopModeStatus { public static final boolean IS_SUPPORTED = SystemProperties.getBoolean( "persist.wm.debug.desktop_mode", false); /** * Return {@code true} if desktop mode support is enabled */ public static boolean isSupported() { return IS_SUPPORTED; } /** * Check if desktop mode is active * Loading @@ -54,4 +61,5 @@ public class DesktopModeStatus { return false; } } }
libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +11 −10 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; import com.android.wm.shell.freeform.FreeformTaskTransitionStarter; import com.android.wm.shell.transition.Transitions; import java.util.Optional; import java.util.function.Supplier; /** Loading @@ -74,7 +75,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private final DisplayController mDisplayController; private final SyncTransactionQueue mSyncQueue; private FreeformTaskTransitionStarter mTransitionStarter; private DesktopModeController mDesktopModeController; private Optional<DesktopModeController> mDesktopModeController; private boolean mTransitionDragActive; private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>(); Loading @@ -90,7 +91,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, DesktopModeController desktopModeController) { Optional<DesktopModeController> desktopModeController) { this( context, mainHandler, Loading @@ -110,7 +111,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { ShellTaskOrganizer taskOrganizer, DisplayController displayController, SyncTransactionQueue syncQueue, DesktopModeController desktopModeController, Optional<DesktopModeController> desktopModeController, CaptionWindowDecoration.Factory captionWindowDecorFactory, Supplier<InputManager> inputManagerSupplier) { Loading Loading @@ -246,10 +247,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } else if (id == R.id.caption_handle) { decoration.createHandleMenu(); } else if (id == R.id.desktop_button) { mDesktopModeController.setDesktopModeActive(true); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); decoration.closeHandleMenu(); } else if (id == R.id.fullscreen_button) { mDesktopModeController.setDesktopModeActive(false); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); decoration.closeHandleMenu(); decoration.setButtonVisibility(); } Loading Loading @@ -304,9 +305,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { */ private void handleEventForMove(MotionEvent e) { RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId); int windowingMode = mDesktopModeController .getDisplayAreaWindowingMode(taskInfo.displayId); if (windowingMode == WINDOWING_MODE_FULLSCREEN) { if (mDesktopModeController.isPresent() && mDesktopModeController.get().getDisplayAreaWindowingMode(taskInfo.displayId) == WINDOWING_MODE_FULLSCREEN) { return; } switch (e.getActionMasked()) { Loading @@ -331,7 +332,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx)); if (e.getRawY(dragPointerIdx) <= statusBarHeight && DesktopModeStatus.isActive(mContext)) { mDesktopModeController.setDesktopModeActive(false); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false)); } break; } Loading Loading @@ -471,7 +472,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { int statusBarHeight = mDisplayController .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top; if (ev.getY() > statusBarHeight) { mDesktopModeController.setDesktopModeActive(true); mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true)); return; } } Loading