Prevents scroll capture from targetting secure windows

Bug: 194256552
Test: atest DisplayContentTests
Change-Id: I436ff109ae26ff22f5d4367a82f0d391588d0a0f
Merged-In: I436ff109ae26ff22f5d4367a82f0d391588d0a0f
This commit is contained in:
Mark Renouf
2021-07-23 11:33:42 -04:00
parent a380ffbff1
commit 8328fde0ec
2 changed files with 30 additions and 1 deletions

View File

@@ -61,6 +61,7 @@ import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
@@ -5829,7 +5830,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
return false; /* continue */
}
}
if (nextWindow.isSecureLocked()) {
return false; /* continue */
}
return true; /* stop, match found */
}
});

View File

@@ -42,6 +42,7 @@ import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_B
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
@@ -1745,6 +1746,31 @@ public class DisplayContentTests extends WindowTestsBase {
assertEquals(activityWindow, result);
}
@Test
public void testFindScrollCaptureTargetWindow_secure() {
DisplayContent display = createNewDisplay();
Task rootTask = createTask(display);
Task task = createTaskInRootTask(rootTask, 0 /* userId */);
WindowState secureWindow = createWindow(null, TYPE_APPLICATION, "Secure Window");
secureWindow.mAttrs.flags |= FLAG_SECURE;
WindowState result = display.findScrollCaptureTargetWindow(null,
ActivityTaskManager.INVALID_TASK_ID);
assertNull(result);
}
@Test
public void testFindScrollCaptureTargetWindow_secureTaskId() {
DisplayContent display = createNewDisplay();
Task rootTask = createTask(display);
Task task = createTaskInRootTask(rootTask, 0 /* userId */);
WindowState secureWindow = createWindow(null, TYPE_APPLICATION, "Secure Window");
secureWindow.mAttrs.flags |= FLAG_SECURE;
WindowState result = display.findScrollCaptureTargetWindow(null, task.mTaskId);
assertNull(result);
}
@Test
public void testFindScrollCaptureTargetWindow_taskId() {
DisplayContent display = createNewDisplay();