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

Commit 4b69da8c authored by Allen Hair's avatar Allen Hair Committed by Android (Google) Code Review
Browse files

Merge "Limit modal windows to only hide windows in the same task." into nyc-dev

parents e7cc1ace f20ac2c1
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.internal.R;
import com.android.internal.os.SomeArgs;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@@ -1019,9 +1020,17 @@ final class AccessibilityController {
                boolean focusedWindowAdded = false;

                final int visibleWindowCount = visibleWindows.size();
                int skipRemainingWindowsForTaskId = -1;
                HashSet<Integer> skipRemainingWindowsForTasks = new HashSet<>();
                for (int i = visibleWindowCount - 1; i >= 0; i--) {
                    final WindowState windowState = visibleWindows.valueAt(i);
                    final int flags = windowState.mAttrs.flags;
                    final Task task = windowState.getTask();

                    // If the window is part of a task that we're finished with - ignore.
                    if (task != null && skipRemainingWindowsForTasks.contains(task.mTaskId)) {
                        continue;
                    }

                    // If the window is not touchable - ignore.
                    if ((flags & WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE) != 0) {
@@ -1062,12 +1071,21 @@ final class AccessibilityController {
                        break;
                    }

                    // If a window is modal, no other below can be touched - done.
                    // If a window is modal it prevents other windows from being touched
                    if ((flags & (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                            | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)) == 0) {
                        if (task != null) {
                            // If the window is associated with a particular task, we can skip the
                            // rest of the windows for that task.
                            skipRemainingWindowsForTasks.add(task.mTaskId);
                            continue;
                        } else {
                            // If the window is not associated with a particular task, then it is
                            // globally modal. In this case we can skip all remaining windows.
                            break;
                        }
                    }
                }

                // Always report the focused window.
                if (!focusedWindowAdded) {