From 231160866738f6ed2175701f300fed1a8e8e02b0 Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Thu, 18 Jun 2015 14:58:39 -0700 Subject: libgui/SF: Propagate SECURE Layer flag changes This allows changes to the SECURE flag to propagate down to Layers in SurfaceFlinger so that WindowManager can change it on the fly in response to device policy updates. Bug: 20934462 Change-Id: I558f6d22c6273be373f1f480365e42536af18a33 --- include/private/gui/LayerState.h | 4 ++-- libs/gui/SurfaceComposerClient.cpp | 9 ++++----- services/surfaceflinger/Layer.cpp | 10 ++++++++-- services/surfaceflinger/Layer.h | 3 +-- services/surfaceflinger/SurfaceFlinger.cpp | 4 +--- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h index 2fa6ff9..cbe8733 100644 --- a/include/private/gui/LayerState.h +++ b/include/private/gui/LayerState.h @@ -39,6 +39,7 @@ struct layer_state_t { enum { eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java eLayerOpaque = 0x02, // SURFACE_OPAQUE + eLayerSecure = 0x80, // SECURE }; enum { @@ -48,10 +49,9 @@ struct layer_state_t { eAlphaChanged = 0x00000008, eMatrixChanged = 0x00000010, eTransparentRegionChanged = 0x00000020, - eVisibilityChanged = 0x00000040, + eFlagsChanged = 0x00000040, eLayerStackChanged = 0x00000080, eCropChanged = 0x00000100, - eOpacityChanged = 0x00000200, }; layer_state_t() diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 707a321..6ad47d8 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -310,11 +310,10 @@ status_t Composer::setFlags(const sp& client, layer_state_t* s = getLayerStateLocked(client, id); if (!s) return BAD_INDEX; - if (mask & layer_state_t::eLayerOpaque) { - s->what |= layer_state_t::eOpacityChanged; - } - if (mask & layer_state_t::eLayerHidden) { - s->what |= layer_state_t::eVisibilityChanged; + if (mask & layer_state_t::eLayerOpaque || + mask & layer_state_t::eLayerHidden || + mask & layer_state_t::eLayerSecure) { + s->what |= layer_state_t::eFlagsChanged; } s->flags &= ~mask; s->flags |= (flags & mask); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index e2a0167..39b80ec 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -76,7 +76,6 @@ Layer::Layer(SurfaceFlinger* flinger, const sp& client, mFiltering(false), mNeedsFiltering(false), mMesh(Mesh::TRIANGLE_FAN, 4, 2, 2), - mSecure(false), mProtectedByApp(false), mHasSurface(false), mClientRef(client), @@ -96,6 +95,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp& client, layerFlags |= layer_state_t::eLayerHidden; if (flags & ISurfaceComposerClient::eOpaque) layerFlags |= layer_state_t::eLayerOpaque; + if (flags & ISurfaceComposerClient::eSecure) + layerFlags |= layer_state_t::eLayerSecure; if (flags & ISurfaceComposerClient::eNonPremultiplied) mPremultipliedAlpha = false; @@ -256,7 +257,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mFormat = format; mPotentialCursor = (flags & ISurfaceComposerClient::eCursorWindow) ? true : false; - mSecure = (flags & ISurfaceComposerClient::eSecure) ? true : false; mProtectedByApp = (flags & ISurfaceComposerClient::eProtectedByApp) ? true : false; mCurrentOpacity = getOpacityForFormat(format); @@ -858,6 +858,12 @@ bool Layer::isOpaque(const Layer::State& s) const return ((s.flags & layer_state_t::eLayerOpaque) != 0) || mCurrentOpacity; } +bool Layer::isSecure() const +{ + const Layer::State& s(mDrawingState); + return (s.flags & layer_state_t::eLayerSecure); +} + bool Layer::isProtected() const { const sp& activeBuffer(mActiveBuffer); diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 4e222b7..c1e5e9f 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -174,7 +174,7 @@ public: * isSecure - true if this surface is secure, that is if it prevents * screenshots or VNC servers. */ - virtual bool isSecure() const { return mSecure; } + virtual bool isSecure() const; /* * isProtected - true if the layer may contain protected content in the @@ -402,7 +402,6 @@ private: mutable Texture mTexture; // page-flip thread (currently main thread) - bool mSecure; // no screenshots bool mProtectedByApp; // application requires protected path to external sink // protected by mLock diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index a332cda..de0f921 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2235,9 +2235,7 @@ uint32_t SurfaceFlinger::setClientStateLocked( if (layer->setTransparentRegionHint(s.transparentRegion)) flags |= eTraversalNeeded; } - if ((what & layer_state_t::eVisibilityChanged) || - (what & layer_state_t::eOpacityChanged)) { - // TODO: should we just use an eFlagsChanged for this? + if (what & layer_state_t::eFlagsChanged) { if (layer->setFlags(s.flags, s.mask)) flags |= eTraversalNeeded; } -- cgit v1.1