diff options
| author | 2018-04-24 12:30:47 -0700 | |
|---|---|---|
| committer | 2018-04-24 13:01:20 -0700 | |
| commit | 94c7d3d948beff287eed53e6d841e29e05cad8b3 (patch) | |
| tree | dfbb9f592e1dfacf1b5a1d92e557d720f7b0d1c9 | |
| parent | d3898410e25f484e30e4ffc5a0fa33018189b19d (diff) | |
SurfaceFlinger: Only update client parent if set.
We use the idea of client with parents to allow applications
to access SurfaceFlinger as long as they have an original "root"
Surface granted to them from the WindowManager. Sometimes the WindowManager
may reparent these child surfaces to a new surface, and so we need to update
which Surface is providing this grant. However, if a client never had a root
surface and is instead relying on ACCESS_SURFACE_FLINGER, e.g. the WindowManager
we need to not reparent or we may end up making the client invalid when
the Surface dies when we never intended to.
Bug: 78301580
Bug: 62536731
Test: Manual repro of b/78301580
Change-Id: Ib18cfe86e1cec3da7808fcd01e2b7ce02bebff6d
| -rw-r--r-- | services/surfaceflinger/Client.cpp | 9 | ||||
| -rw-r--r-- | services/surfaceflinger/Client.h | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/services/surfaceflinger/Client.cpp b/services/surfaceflinger/Client.cpp index c90024b863..077469b5e1 100644 --- a/services/surfaceflinger/Client.cpp +++ b/services/surfaceflinger/Client.cpp @@ -65,9 +65,14 @@ Client::~Client() } } -void Client::setParentLayer(const sp<Layer>& parentLayer) { +void Client::updateParent(const sp<Layer>& parentLayer) { Mutex::Autolock _l(mLock); - mParentLayer = parentLayer; + + // If we didn't ever have a parent, then we must instead be + // relying on permissions and we never need a parent. + if (mParentLayer != nullptr) { + mParentLayer = parentLayer; + } } sp<Layer> Client::getParentLayer(bool* outParentDied) const { diff --git a/services/surfaceflinger/Client.h b/services/surfaceflinger/Client.h index c7df9f780f..49437ed7fd 100644 --- a/services/surfaceflinger/Client.h +++ b/services/surfaceflinger/Client.h @@ -51,7 +51,7 @@ public: sp<Layer> getLayerUser(const sp<IBinder>& handle) const; - void setParentLayer(const sp<Layer>& parentLayer); + void updateParent(const sp<Layer>& parentLayer); private: // ISurfaceComposerClient interface diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 66ad2f60a6..bbc974de2f 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -1589,7 +1589,7 @@ bool Layer::reparentChildren(const sp<IBinder>& newParentHandle) { sp<Client> client(child->mClientRef.promote()); if (client != nullptr) { - client->setParentLayer(newParent); + client->updateParent(newParent); } } mCurrentChildren.clear(); @@ -1625,7 +1625,7 @@ bool Layer::reparent(const sp<IBinder>& newParentHandle) { sp<Client> newParentClient(newParent->mClientRef.promote()); if (client != newParentClient) { - client->setParentLayer(newParent); + client->updateParent(newParent); } return true; |