Limit modal windows to only hide windows in the same task.
Bug: 26560078
Change-Id: Ic3bd8d06ed0d8d44a8e7f0faaba31a762a9bfef3
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index e6b649e7..2c15818 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -60,6 +60,7 @@
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 @@
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,10 +1071,19 @@
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) {
- break;
+ 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;
+ }
}
}