SurfaceComposerClient: Ensure createSurface returns error codes.
If SurfaceComposerClient::mStatus is not equal to NO_ERROR (for example
because we have attempted to construct a rooted-connection to a destroyed
surface, and initialization has failed) then it is possible for createSurface
to return NO_ERROR while failing to assign a value to outSurface. This
violates the expectations of the JNI layer which expects that NO_ERROR will
result in a valid surface.
Bug: 76231383
Test: Surface_test.cpp (libgui_test)
Change-Id: Ie68aafad01674c43e13af09bc144cc673b84ac1b
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 38f0eb7..1f3ee61 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -629,7 +629,7 @@
uint32_t ownerUid)
{
sp<SurfaceControl> sur;
- status_t err = NO_ERROR;
+ status_t err = mStatus;
if (mStatus == NO_ERROR) {
sp<IBinder> handle;