SurfaceFlinger: Drop input for blacked out layers
If the window will be blacked out on a display because
the display does not have the secure flag and the layer
has the secure flag set, then drop input.
Test: atest libgui_test
Fixes: 200842159
Change-Id: Idfe245b0f0091e0cafc15c83b25a9d0fd7364174
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 10391a2b..87afa22 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2154,7 +2154,7 @@
if (traceFlags & SurfaceTracing::TRACE_INPUT) {
WindowInfo info;
if (useDrawing) {
- info = fillInputInfo(ui::Transform());
+ info = fillInputInfo(ui::Transform(), /* displayIsSecure */ true);
} else {
info = state.inputInfo;
}
@@ -2356,7 +2356,7 @@
}
}
-WindowInfo Layer::fillInputInfo(const ui::Transform& displayTransform) {
+WindowInfo Layer::fillInputInfo(const ui::Transform& displayTransform, bool displayIsSecure) {
if (!hasInputInfo()) {
mDrawingState.inputInfo.name = getName();
mDrawingState.inputInfo.ownerUid = mOwnerUid;
@@ -2385,6 +2385,12 @@
fillTouchOcclusionMode(info);
handleDropInputMode(info);
+ // If the window will be blacked out on a display because the display does not have the secure
+ // flag and the layer has the secure flag set, then drop input.
+ if (!displayIsSecure && isSecure()) {
+ info.inputFeatures |= WindowInfo::Feature::DROP_INPUT;
+ }
+
auto cropLayer = mDrawingState.touchableRegionCrop.promote();
if (info.replaceTouchableRegionWithCrop) {
const Rect bounds(cropLayer ? cropLayer->mScreenBounds : mScreenBounds);