Make a layer secure if its parent is secure.
Dialogs and context menus can be captured in screenshots even if their
parent layer/window is marked secure. Therefore we should let the secure
flag be inherited from their parents as well.
Bug: 169851503
Test: Screen capture can't capture dialogs in a window marked secure.
Test: atest libsurfaceflinger_unittest
Test: atest SurfaceFlinger_test:ScreenCaptureTest
Change-Id: I0f32a03aeb733682df787105b051c691d1da7bc6
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index a79cbe4..d9faec4 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -778,7 +778,12 @@
bool Layer::isSecure() const {
const State& s(mDrawingState);
- return (s.flags & layer_state_t::eLayerSecure);
+ if (s.flags & layer_state_t::eLayerSecure) {
+ return true;
+ }
+
+ const auto p = mDrawingParent.promote();
+ return (p != nullptr) ? p->isSecure() : false;
}
// ----------------------------------------------------------------------------