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

Commit 5f11264d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use DesktopExperienceFlags for shell transition flag" into main

parents fdd1508b d40331d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1546,7 +1546,7 @@ class DesktopTasksController(

        val activationRunnable = addDeskActivationChanges(destinationDeskId, wct, task)

        if (Flags.enableDisplayFocusInShellTransitions()) {
        if (DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) {
            // Bring the destination display to top with includingParents=true, so that the
            // destination display gains the display focus, which makes the top task in the display
            // gains the global focus.
+11 −9
Original line number Diff line number Diff line
@@ -21,10 +21,10 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.window.DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS;
import static android.window.TransitionInfo.FLAG_IS_DISPLAY;
import static android.window.TransitionInfo.FLAG_MOVED_TO_TOP;

import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static com.android.wm.shell.transition.Transitions.TransitionObserver;

import android.annotation.NonNull;
@@ -68,7 +68,7 @@ public class FocusTransitionObserver {
     * Update display/window focus state from the given transition info and notifies changes if any.
     */
    public void updateFocusState(@NonNull TransitionInfo info) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return;
        }
        final SparseArray<RunningTaskInfo> lastTransitionFocusedTasks =
@@ -149,7 +149,7 @@ public class FocusTransitionObserver {
     */
    public void setLocalFocusTransitionListener(FocusTransitionListener listener,
            Executor executor) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return;
        }
        mLocalListeners.put(listener, executor);
@@ -165,7 +165,7 @@ public class FocusTransitionObserver {
     *
     */
    public void unsetLocalFocusTransitionListener(FocusTransitionListener listener) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return;
        }
        mLocalListeners.remove(listener);
@@ -177,7 +177,7 @@ public class FocusTransitionObserver {
     */
    public void setRemoteFocusTransitionListener(Transitions transitions,
            IFocusTransitionListener listener) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return;
        }
        mRemoteListener = listener;
@@ -211,7 +211,7 @@ public class FocusTransitionObserver {
    }

    private boolean isFocusedOnDisplay(@NonNull RunningTaskInfo task) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return task.isFocused;
        }
        final RunningTaskInfo focusedTaskOnDisplay = mFocusedTaskOnDisplay.get(task.displayId);
@@ -220,7 +220,8 @@ public class FocusTransitionObserver {

    /** Returns the globally focused display id. */
    public int getGloballyFocusedDisplayId() {
        if (!enableDisplayFocusInShellTransitions() || mFocusedDisplayId == INVALID_DISPLAY) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()
                || mFocusedDisplayId == INVALID_DISPLAY) {
            return INVALID_DISPLAY;
        }
        return mFocusedDisplayId;
@@ -230,7 +231,8 @@ public class FocusTransitionObserver {
     * Gets the globally focused task ID.
     */
    public int getGloballyFocusedTaskId() {
        if (!enableDisplayFocusInShellTransitions() || mFocusedDisplayId == INVALID_DISPLAY) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()
                || mFocusedDisplayId == INVALID_DISPLAY) {
            return INVALID_TASK_ID;
        }
        final RunningTaskInfo globallyFocusedTask = mFocusedTaskOnDisplay.get(mFocusedDisplayId);
@@ -242,7 +244,7 @@ public class FocusTransitionObserver {
     * (Note {@link RunningTaskInfo#isFocused} represents per-display focus.)
     */
    public boolean hasGlobalFocus(@NonNull RunningTaskInfo task) {
        if (!enableDisplayFocusInShellTransitions()) {
        if (!ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            return task.isFocused;
        }
        return task.displayId == mFocusedDisplayId && isFocusedOnDisplay(task);
+2 −3
Original line number Diff line number Diff line
@@ -23,8 +23,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.content.pm.PackageManager.FEATURE_PC;
import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON_EXTERNAL_DISPLAYS;
import static android.view.WindowManager.TRANSIT_CHANGE;

import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static android.window.DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS;

import android.annotation.NonNull;
import android.app.ActivityManager.RunningTaskInfo;
@@ -210,7 +209,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
            return;
        }

        if (enableDisplayFocusInShellTransitions()) {
        if (ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            // Pass the current global focus status to avoid updates outside of a ShellTransition.
            decoration.relayout(taskInfo, decoration.mHasGlobalFocus, decoration.mExclusionRegion);
        } else {
+2 −2
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import static android.view.MotionEvent.ACTION_HOVER_EXIT;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.WindowInsets.Type.statusBars;
import static android.window.DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS;

import static com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_MODE_APP_HANDLE_MENU;
import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.InputMethod;
import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.MinimizeReason;
import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger;
@@ -590,7 +590,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            removeTaskFromEventReceiver(oldTaskInfo.displayId);
            incrementEventReceiverTasks(taskInfo.displayId);
        }
        if (enableDisplayFocusInShellTransitions()) {
        if (ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue()) {
            // Pass the current global focus status to avoid updates outside of a ShellTransition.
            decoration.relayout(taskInfo, decoration.mHasGlobalFocus, decoration.mExclusionRegion);
        } else {
+7 −7
Original line number Diff line number Diff line
@@ -32,13 +32,13 @@ import android.view.WindowManager.TRANSIT_OPEN
import android.view.WindowManager.TRANSIT_PIP
import android.view.WindowManager.TRANSIT_TO_BACK
import android.view.WindowManager.TRANSIT_TO_FRONT
import android.window.DesktopExperienceFlags
import android.window.TransitionInfo
import android.window.TransitionInfo.Change
import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import com.android.internal.annotations.VisibleForTesting
import com.android.launcher3.icons.BaseIconFactory
import com.android.window.flags.Flags
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.ShellTaskOrganizer
@@ -204,7 +204,7 @@ class DesktopTilingWindowDecoration(
                desktopTilingDividerWindowManager = initTilingManagerForDisplay(displayId, config)
                isTilingManagerInitialised = true

                if (Flags.enableDisplayFocusInShellTransitions()) {
                if (DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) {
                    focusTransitionObserver.setLocalFocusTransitionListener(this, mainExecutor)
                } else {
                    shellTaskOrganizer.addFocusListener(this)
@@ -580,7 +580,7 @@ class DesktopTilingWindowDecoration(

    // Overriding ShellTaskOrganizer.FocusListener
    override fun onFocusTaskChanged(taskInfo: RunningTaskInfo?) {
        if (Flags.enableDisplayFocusInShellTransitions()) return
        if (DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) return
        if (taskInfo != null) {
            moveTiledPairToFront(taskInfo.taskId, taskInfo.isFocused)
        }
@@ -592,7 +592,7 @@ class DesktopTilingWindowDecoration(
        isFocusedOnDisplay: Boolean,
        isFocusedGlobally: Boolean,
    ) {
        if (!Flags.enableDisplayFocusInShellTransitions()) return
        if (!DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) return
        moveTiledPairToFront(taskId, isFocusedOnDisplay)
    }

@@ -720,7 +720,7 @@ class DesktopTilingWindowDecoration(
        if (!isFocusedOnDisplay) return false

        // If a task that isn't tiled is being focused, let the generic handler do the work.
        if (!Flags.enableDisplayFocusInShellTransitions() && isTilingFocusRemoved(taskId)) {
        if (!DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue && isTilingFocusRemoved(taskId)) {
            isTilingFocused = false
            return false
        }
@@ -731,7 +731,7 @@ class DesktopTilingWindowDecoration(
        val isLeftOnTop = taskId == leftTiledTask.taskInfo.taskId
        if (!isTilingRefocused(taskId)) return false
        val t = transactionSupplier.get()
        if (!Flags.enableDisplayFocusInShellTransitions()) isTilingFocused = true
        if (!DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) isTilingFocused = true
        if (taskId == leftTaskResizingHelper?.taskInfo?.taskId) {
            desktopTilingDividerWindowManager?.onRelativeLeashChanged(leftTiledTask.getLeash(), t)
        }
@@ -836,7 +836,7 @@ class DesktopTilingWindowDecoration(

    private fun tearDownTiling() {
        if (isTilingManagerInitialised) {
            if (Flags.enableDisplayFocusInShellTransitions()) {
            if (DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS.isTrue) {
                focusTransitionObserver.unsetLocalFocusTransitionListener(this)
            } else {
                shellTaskOrganizer.removeFocusListener(this)
Loading