Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e9699a2 authored by Patrick Chang's avatar Patrick Chang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "revert-20653722-KTBRNWFPCR" into tm-qpr-dev

* changes:
  Revert "Create controller for desktop prototype 2"
  Revert "Implement showDesktopApps"
  Revert "Implement move to desktop and fullscreen"
parents d7f9b1ca f3c7cc85
Loading
Loading
Loading
Loading
+1 −23
Original line number Original line Diff line number Diff line
@@ -61,7 +61,6 @@ import com.android.wm.shell.desktopmode.DesktopMode;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository;
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository;
import com.android.wm.shell.desktopmode.DesktopTasksController;
import com.android.wm.shell.displayareahelper.DisplayAreaHelper;
import com.android.wm.shell.displayareahelper.DisplayAreaHelper;
import com.android.wm.shell.displayareahelper.DisplayAreaHelperController;
import com.android.wm.shell.displayareahelper.DisplayAreaHelperController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.draganddrop.DragAndDropController;
@@ -678,11 +677,7 @@ public abstract class WMShellBaseModule {
    @WMSingleton
    @WMSingleton
    @Provides
    @Provides
    static Optional<DesktopMode> provideDesktopMode(
    static Optional<DesktopMode> provideDesktopMode(
            Optional<DesktopModeController> desktopModeController,
            Optional<DesktopModeController> desktopModeController) {
            Optional<DesktopTasksController> desktopTasksController) {
        if (DesktopModeStatus.isProto2Enabled()) {
            return desktopTasksController.map(DesktopTasksController::asDesktopMode);
        }
        return desktopModeController.map(DesktopModeController::asDesktopMode);
        return desktopModeController.map(DesktopModeController::asDesktopMode);
    }
    }


@@ -703,23 +698,6 @@ public abstract class WMShellBaseModule {
        return Optional.empty();
        return Optional.empty();
    }
    }


    @BindsOptionalOf
    @DynamicOverride
    abstract DesktopTasksController optionalDesktopTasksController();

    @WMSingleton
    @Provides
    static Optional<DesktopTasksController> providesDesktopTasksController(
            @DynamicOverride Optional<Lazy<DesktopTasksController>> desktopTasksController) {
        // 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.isProto2Enabled()) {
            return desktopTasksController.map(Lazy::get);
        }
        return Optional.empty();
    }

    @BindsOptionalOf
    @BindsOptionalOf
    @DynamicOverride
    @DynamicOverride
    abstract DesktopModeTaskRepository optionalDesktopModeTaskRepository();
    abstract DesktopModeTaskRepository optionalDesktopModeTaskRepository();
+2 −21
Original line number Original line Diff line number Diff line
@@ -50,7 +50,6 @@ import com.android.wm.shell.common.annotations.ShellBackgroundThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.common.annotations.ShellMainThread;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository;
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository;
import com.android.wm.shell.desktopmode.DesktopTasksController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.draganddrop.DragAndDropController;
import com.android.wm.shell.freeform.FreeformComponents;
import com.android.wm.shell.freeform.FreeformComponents;
import com.android.wm.shell.freeform.FreeformTaskListener;
import com.android.wm.shell.freeform.FreeformTaskListener;
@@ -190,8 +189,7 @@ public abstract class WMShellModule {
            ShellTaskOrganizer taskOrganizer,
            ShellTaskOrganizer taskOrganizer,
            DisplayController displayController,
            DisplayController displayController,
            SyncTransactionQueue syncQueue,
            SyncTransactionQueue syncQueue,
            Optional<DesktopModeController> desktopModeController,
            Optional<DesktopModeController> desktopModeController) {
            Optional<DesktopTasksController> desktopTasksController) {
        return new CaptionWindowDecorViewModel(
        return new CaptionWindowDecorViewModel(
                    context,
                    context,
                    mainHandler,
                    mainHandler,
@@ -199,8 +197,7 @@ public abstract class WMShellModule {
                    taskOrganizer,
                    taskOrganizer,
                    displayController,
                    displayController,
                    syncQueue,
                    syncQueue,
                    desktopModeController,
                    desktopModeController);
                    desktopTasksController);
    }
    }


    //
    //
@@ -616,22 +613,6 @@ public abstract class WMShellModule {
                mainExecutor);
                mainExecutor);
    }
    }


    @WMSingleton
    @Provides
    @DynamicOverride
    static DesktopTasksController provideDesktopTasksController(
            Context context,
            ShellInit shellInit,
            ShellController shellController,
            ShellTaskOrganizer shellTaskOrganizer,
            Transitions transitions,
            @DynamicOverride DesktopModeTaskRepository desktopModeTaskRepository,
            @ShellMainThread ShellExecutor mainExecutor
    ) {
        return new DesktopTasksController(context, shellInit, shellController, shellTaskOrganizer,
                transitions, desktopModeTaskRepository, mainExecutor);
    }

    @WMSingleton
    @WMSingleton
    @Provides
    @Provides
    @DynamicOverride
    @DynamicOverride
+1 −5
Original line number Original line Diff line number Diff line
@@ -70,13 +70,9 @@ public class DesktopModeStatus {
     * @return {@code true} if active
     * @return {@code true} if active
     */
     */
    public static boolean isActive(Context context) {
    public static boolean isActive(Context context) {
        if (!isAnyEnabled()) {
        if (!IS_SUPPORTED) {
            return false;
            return false;
        }
        }
        if (isProto2Enabled()) {
            // Desktop mode is always active in prototype 2
            return true;
        }
        try {
        try {
            int result = Settings.System.getIntForUser(context.getContentResolver(),
            int result = Settings.System.getIntForUser(context.getContentResolver(),
                    Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT);
                    Settings.System.DESKTOP_MODE, UserHandle.USER_CURRENT);
+0 −231
Original line number Original line Diff line number Diff line
/*
 * 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.app.ActivityManager
import android.app.WindowConfiguration
import android.app.WindowConfiguration.ACTIVITY_TYPE_HOME
import android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED
import android.app.WindowConfiguration.WindowingMode
import android.content.Context
import android.view.WindowManager
import android.window.WindowContainerTransaction
import androidx.annotation.BinderThread
import com.android.internal.protolog.common.ProtoLog
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.common.ExecutorUtils
import com.android.wm.shell.common.ExternalInterfaceBinder
import com.android.wm.shell.common.RemoteCallable
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.common.annotations.ExternalThread
import com.android.wm.shell.common.annotations.ShellMainThread
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository.VisibleTasksListener
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.sysui.ShellSharedConstants
import com.android.wm.shell.transition.Transitions
import java.util.concurrent.Executor
import java.util.function.Consumer

/** Handles moving tasks in and out of desktop */
class DesktopTasksController(
    private val context: Context,
    shellInit: ShellInit,
    private val shellController: ShellController,
    private val shellTaskOrganizer: ShellTaskOrganizer,
    private val transitions: Transitions,
    private val desktopModeTaskRepository: DesktopModeTaskRepository,
    @ShellMainThread private val mainExecutor: ShellExecutor
) : RemoteCallable<DesktopTasksController> {

    private val desktopMode: DesktopModeImpl

    init {
        desktopMode = DesktopModeImpl()
        if (DesktopModeStatus.isProto2Enabled()) {
            shellInit.addInitCallback({ onInit() }, this)
        }
    }

    private fun onInit() {
        ProtoLog.d(WM_SHELL_DESKTOP_MODE, "Initialize DesktopTasksController")
        shellController.addExternalInterface(
            ShellSharedConstants.KEY_EXTRA_SHELL_DESKTOP_MODE,
            { createExternalInterface() },
            this
        )
    }

    /** Show all tasks, that are part of the desktop, on top of launcher */
    fun showDesktopApps() {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "showDesktopApps")
        val wct = WindowContainerTransaction()

        bringDesktopAppsToFront(wct)

        // Execute transaction if there are pending operations
        if (!wct.isEmpty) {
            if (Transitions.ENABLE_SHELL_TRANSITIONS) {
                transitions.startTransition(WindowManager.TRANSIT_TO_FRONT, wct, null /* handler */)
            } else {
                shellTaskOrganizer.applyTransaction(wct)
            }
        }
    }

    /** Move a task with given `taskId` to desktop */
    fun moveToDesktop(taskId: Int) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToDesktop(task) }
    }

    /** Move a task to desktop */
    fun moveToDesktop(task: ActivityManager.RunningTaskInfo) {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToDesktop: %d", task.taskId)

        val wct = WindowContainerTransaction()
        // Bring other apps to front first
        bringDesktopAppsToFront(wct)

        wct.setWindowingMode(task.getToken(), WindowConfiguration.WINDOWING_MODE_FREEFORM)
        wct.reorder(task.getToken(), true /* onTop */)

        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(WindowManager.TRANSIT_CHANGE, wct, null /* handler */)
        } else {
            shellTaskOrganizer.applyTransaction(wct)
        }
    }

    /** Move a task with given `taskId` to fullscreen */
    fun moveToFullscreen(taskId: Int) {
        shellTaskOrganizer.getRunningTaskInfo(taskId)?.let { task -> moveToFullscreen(task) }
    }

    /** Move a task to fullscreen */
    fun moveToFullscreen(task: ActivityManager.RunningTaskInfo) {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId)

        val wct = WindowContainerTransaction()
        wct.setWindowingMode(task.getToken(), WindowConfiguration.WINDOWING_MODE_FULLSCREEN)
        wct.setBounds(task.getToken(), null)
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            transitions.startTransition(WindowManager.TRANSIT_CHANGE, wct, null /* handler */)
        } else {
            shellTaskOrganizer.applyTransaction(wct)
        }
    }

    /**
     * Get windowing move for a given `taskId`
     *
     * @return [WindowingMode] for the task or [WINDOWING_MODE_UNDEFINED] if task is not found
     */
    @WindowingMode
    fun getTaskWindowingMode(taskId: Int): Int {
        return shellTaskOrganizer.getRunningTaskInfo(taskId)?.windowingMode
            ?: WINDOWING_MODE_UNDEFINED
    }

    private fun bringDesktopAppsToFront(wct: WindowContainerTransaction) {
        val activeTasks = desktopModeTaskRepository.getActiveTasks()

        // Skip if all tasks are already visible
        if (activeTasks.isNotEmpty() && activeTasks.all(desktopModeTaskRepository::isVisibleTask)) {
            ProtoLog.d(
                WM_SHELL_DESKTOP_MODE,
                "bringDesktopAppsToFront: active tasks are already in front, skipping."
            )
            return
        }

        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront")

        // First move home to front and then other tasks on top of it
        moveHomeTaskToFront(wct)

        val allTasksInZOrder = desktopModeTaskRepository.getFreeformTasksInZOrder()
        activeTasks
            // Sort descending as the top task is at index 0. It should be ordered to top last
            .sortedByDescending { taskId -> allTasksInZOrder.indexOf(taskId) }
            .mapNotNull { taskId -> shellTaskOrganizer.getRunningTaskInfo(taskId) }
            .forEach { task -> wct.reorder(task.token, true /* onTop */) }
    }

    private fun moveHomeTaskToFront(wct: WindowContainerTransaction) {
        shellTaskOrganizer
            .getRunningTasks(context.displayId)
            .firstOrNull { task -> task.activityType == ACTIVITY_TYPE_HOME }
            ?.let { homeTask -> wct.reorder(homeTask.getToken(), true /* onTop */) }
    }

    override fun getContext(): Context {
        return context
    }

    override fun getRemoteCallExecutor(): ShellExecutor {
        return mainExecutor
    }

    /** Creates a new instance of the external interface to pass to another process. */
    private fun createExternalInterface(): ExternalInterfaceBinder {
        return IDesktopModeImpl(this)
    }

    /** Get connection interface between sysui and shell */
    fun asDesktopMode(): DesktopMode {
        return desktopMode
    }

    /**
     * Adds a listener to find out about changes in the visibility of freeform tasks.
     *
     * @param listener the listener to add.
     * @param callbackExecutor the executor to call the listener on.
     */
    fun addListener(listener: VisibleTasksListener, callbackExecutor: Executor) {
        desktopModeTaskRepository.addVisibleTasksListener(listener, callbackExecutor)
    }

    /** The interface for calls from outside the shell, within the host process. */
    @ExternalThread
    private inner class DesktopModeImpl : DesktopMode {
        override fun addListener(listener: VisibleTasksListener, callbackExecutor: Executor) {
            mainExecutor.execute {
                this@DesktopTasksController.addListener(listener, callbackExecutor)
            }
        }
    }

    /** The interface for calls from outside the host process. */
    @BinderThread
    private class IDesktopModeImpl(private var controller: DesktopTasksController?) :
        IDesktopMode.Stub(), ExternalInterfaceBinder {
        /** Invalidates this instance, preventing future calls from updating the controller. */
        override fun invalidate() {
            controller = null
        }

        override fun showDesktopApps() {
            ExecutorUtils.executeRemoteCallWithTaskPermission(
                controller,
                "showDesktopApps",
                Consumer(DesktopTasksController::showDesktopApps)
            )
        }
    }
}
+15 −70
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.common.SyncTransactionQueue;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeController;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopModeStatus;
import com.android.wm.shell.desktopmode.DesktopTasksController;
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
import com.android.wm.shell.transition.Transitions;
import com.android.wm.shell.transition.Transitions;


@@ -77,7 +76,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
    private final SyncTransactionQueue mSyncQueue;
    private final SyncTransactionQueue mSyncQueue;
    private FreeformTaskTransitionStarter mTransitionStarter;
    private FreeformTaskTransitionStarter mTransitionStarter;
    private Optional<DesktopModeController> mDesktopModeController;
    private Optional<DesktopModeController> mDesktopModeController;
    private Optional<DesktopTasksController> mDesktopTasksController;
    private boolean mTransitionDragActive;
    private boolean mTransitionDragActive;


    private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>();
    private SparseArray<EventReceiver> mEventReceiversByDisplay = new SparseArray<>();
@@ -93,8 +91,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
            ShellTaskOrganizer taskOrganizer,
            ShellTaskOrganizer taskOrganizer,
            DisplayController displayController,
            DisplayController displayController,
            SyncTransactionQueue syncQueue,
            SyncTransactionQueue syncQueue,
            Optional<DesktopModeController> desktopModeController,
            Optional<DesktopModeController> desktopModeController) {
            Optional<DesktopTasksController> desktopTasksController) {
        this(
        this(
                context,
                context,
                mainHandler,
                mainHandler,
@@ -103,7 +100,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                displayController,
                displayController,
                syncQueue,
                syncQueue,
                desktopModeController,
                desktopModeController,
                desktopTasksController,
                new CaptionWindowDecoration.Factory(),
                new CaptionWindowDecoration.Factory(),
                InputManager::getInstance);
                InputManager::getInstance);
    }
    }
@@ -116,7 +112,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
            DisplayController displayController,
            DisplayController displayController,
            SyncTransactionQueue syncQueue,
            SyncTransactionQueue syncQueue,
            Optional<DesktopModeController> desktopModeController,
            Optional<DesktopModeController> desktopModeController,
            Optional<DesktopTasksController> desktopTasksController,
            CaptionWindowDecoration.Factory captionWindowDecorFactory,
            CaptionWindowDecoration.Factory captionWindowDecorFactory,
            Supplier<InputManager> inputManagerSupplier) {
            Supplier<InputManager> inputManagerSupplier) {


@@ -128,7 +123,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
        mDisplayController = displayController;
        mDisplayController = displayController;
        mSyncQueue = syncQueue;
        mSyncQueue = syncQueue;
        mDesktopModeController = desktopModeController;
        mDesktopModeController = desktopModeController;
        mDesktopTasksController = desktopTasksController;


        mCaptionWindowDecorFactory = captionWindowDecorFactory;
        mCaptionWindowDecorFactory = captionWindowDecorFactory;
        mInputManagerSupplier = inputManagerSupplier;
        mInputManagerSupplier = inputManagerSupplier;
@@ -254,13 +248,11 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                decoration.createHandleMenu();
                decoration.createHandleMenu();
            } else if (id == R.id.desktop_button) {
            } else if (id == R.id.desktop_button) {
                mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true));
                mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true));
                mDesktopTasksController.ifPresent(c -> c.moveToDesktop(mTaskId));
                decoration.closeHandleMenu();
                decoration.closeHandleMenu();
            } else if (id == R.id.fullscreen_button) {
            } else if (id == R.id.fullscreen_button) {
                mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false));
                mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false));
                mDesktopTasksController.ifPresent(c -> c.moveToFullscreen(mTaskId));
                decoration.closeHandleMenu();
                decoration.closeHandleMenu();
                decoration.setButtonVisibility(false);
                decoration.setButtonVisibility();
            }
            }
        }
        }


@@ -313,13 +305,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
         */
         */
        private void handleEventForMove(MotionEvent e) {
        private void handleEventForMove(MotionEvent e) {
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            if (DesktopModeStatus.isProto2Enabled()
            if (mDesktopModeController.isPresent()
                    && taskInfo.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
                    && mDesktopModeController.get().getDisplayAreaWindowingMode(taskInfo.displayId)
                return;
            }
            if (DesktopModeStatus.isProto1Enabled() && mDesktopModeController.isPresent()
                    && mDesktopModeController.get().getDisplayAreaWindowingMode(
                    taskInfo.displayId)
                    == WINDOWING_MODE_FULLSCREEN) {
                    == WINDOWING_MODE_FULLSCREEN) {
                return;
                return;
            }
            }
@@ -343,20 +330,9 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                            .stableInsets().top;
                            .stableInsets().top;
                    mDragResizeCallback.onDragResizeEnd(
                    mDragResizeCallback.onDragResizeEnd(
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                            e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
                    if (e.getRawY(dragPointerIdx) <= statusBarHeight) {
                    if (e.getRawY(dragPointerIdx) <= statusBarHeight
                        if (DesktopModeStatus.isProto2Enabled()) {
                            && DesktopModeStatus.isActive(mContext)) {
                            if (taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
                        mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(false));
                                // Switch a single task to fullscreen
                                mDesktopTasksController.ifPresent(
                                        c -> c.moveToFullscreen(taskInfo));
                            }
                        } else if (DesktopModeStatus.isProto1Enabled()) {
                            if (DesktopModeStatus.isActive(mContext)) {
                                // Turn off desktop mode
                                mDesktopModeController.ifPresent(
                                        c -> c.setDesktopModeActive(false));
                            }
                        }
                    }
                    }
                    break;
                    break;
                }
                }
@@ -444,29 +420,15 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
     * @param ev the {@link MotionEvent} received by {@link EventReceiver}
     * @param ev the {@link MotionEvent} received by {@link EventReceiver}
     */
     */
    private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) {
    private void handleReceivedMotionEvent(MotionEvent ev, InputMonitor inputMonitor) {
        if (DesktopModeStatus.isProto2Enabled()) {
            CaptionWindowDecoration focusedDecor = getFocusedDecor();
            if (focusedDecor == null
                    || focusedDecor.mTaskInfo.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                handleCaptionThroughStatusBar(ev);
            }
        } else if (DesktopModeStatus.isProto1Enabled()) {
        if (!DesktopModeStatus.isActive(mContext)) {
        if (!DesktopModeStatus.isActive(mContext)) {
            handleCaptionThroughStatusBar(ev);
            handleCaptionThroughStatusBar(ev);
        }
        }
        }
        handleEventOutsideFocusedCaption(ev);
        handleEventOutsideFocusedCaption(ev);
        // Prevent status bar from reacting to a caption drag.
        // Prevent status bar from reacting to a caption drag.
        if (DesktopModeStatus.isProto2Enabled()) {
            if (mTransitionDragActive) {
                inputMonitor.pilferPointers();
            }
        } else if (DesktopModeStatus.isProto1Enabled()) {
        if (mTransitionDragActive && !DesktopModeStatus.isActive(mContext)) {
        if (mTransitionDragActive && !DesktopModeStatus.isActive(mContext)) {
            inputMonitor.pilferPointers();
            inputMonitor.pilferPointers();
        }
        }
    }
    }
    }


    // If an UP/CANCEL action is received outside of caption bounds, turn off handle menu
    // If an UP/CANCEL action is received outside of caption bounds, turn off handle menu
    private void handleEventOutsideFocusedCaption(MotionEvent ev) {
    private void handleEventOutsideFocusedCaption(MotionEvent ev) {
@@ -493,21 +455,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
            case MotionEvent.ACTION_DOWN: {
            case MotionEvent.ACTION_DOWN: {
                // Begin drag through status bar if applicable.
                // Begin drag through status bar if applicable.
                CaptionWindowDecoration focusedDecor = getFocusedDecor();
                CaptionWindowDecoration focusedDecor = getFocusedDecor();
                if (focusedDecor != null) {
                if (focusedDecor != null && !DesktopModeStatus.isActive(mContext)
                    boolean dragFromStatusBarAllowed = false;
                        && focusedDecor.checkTouchEventInHandle(ev)) {
                    if (DesktopModeStatus.isProto2Enabled()) {
                        // In proto2 any full screen task can be dragged to freeform
                        dragFromStatusBarAllowed = focusedDecor.mTaskInfo.getWindowingMode()
                                == WINDOWING_MODE_FULLSCREEN;
                    } else if (DesktopModeStatus.isProto1Enabled()) {
                        // In proto1 task can be dragged to freeform when not in desktop mode
                        dragFromStatusBarAllowed = !DesktopModeStatus.isActive(mContext);
                    }

                    if (dragFromStatusBarAllowed && focusedDecor.checkTouchEventInHandle(ev)) {
                    mTransitionDragActive = true;
                    mTransitionDragActive = true;
                }
                }
                }
                break;
                break;
            }
            }
            case MotionEvent.ACTION_UP: {
            case MotionEvent.ACTION_UP: {
@@ -521,13 +472,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel {
                    int statusBarHeight = mDisplayController
                    int statusBarHeight = mDisplayController
                            .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top;
                            .getDisplayLayout(focusedDecor.mTaskInfo.displayId).stableInsets().top;
                    if (ev.getY() > statusBarHeight) {
                    if (ev.getY() > statusBarHeight) {
                        if (DesktopModeStatus.isProto2Enabled()) {
                            mDesktopTasksController.ifPresent(
                                    c -> c.moveToDesktop(focusedDecor.mTaskInfo));
                        } else if (DesktopModeStatus.isProto1Enabled()) {
                        mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true));
                        mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true));
                        }

                        return;
                        return;
                    }
                    }
                }
                }
Loading