Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b382ed2 authored by Robert Carr's avatar Robert Carr
Browse files

Propagate error codes from createSurface

Without an error code it's impossible to distinguish OOM
from missing parent, causing the WM to start killing applications
in the case of a missing parent.

Bug: 73664284
Test: Manual.
Change-Id: Ida6a30b41d1e856dfa9dceb80a432a30353d2764
parent 9a34c1a9
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -611,8 +611,26 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
        SurfaceControl* parent,
        uint32_t windowType,
        uint32_t ownerUid)
{
    sp<SurfaceControl> s;
    createSurfaceChecked(name, w, h, format, &s, flags, parent, windowType, ownerUid);
    return s;
}

status_t SurfaceComposerClient::createSurfaceChecked(
        const String8& name,
        uint32_t w,
        uint32_t h,
        PixelFormat format,
        sp<SurfaceControl>* outSurface,
        uint32_t flags,
        SurfaceControl* parent,
        uint32_t windowType,
        uint32_t ownerUid)
{
    sp<SurfaceControl> sur;
    status_t err = NO_ERROR;

    if (mStatus == NO_ERROR) {
        sp<IBinder> handle;
        sp<IBinder> parentHandle;
@@ -621,14 +639,14 @@ sp<SurfaceControl> SurfaceComposerClient::createSurface(
        if (parent != nullptr) {
            parentHandle = parent->getHandle();
        }
        status_t err = mClient->createSurface(name, w, h, format, flags, parentHandle,
        err = mClient->createSurface(name, w, h, format, flags, parentHandle,
                windowType, ownerUid, &handle, &gbp);
        ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err));
        if (err == NO_ERROR) {
            sur = new SurfaceControl(this, handle, gbp, true /* owned */);
            *outSurface = new SurfaceControl(this, handle, gbp, true /* owned */);
        }
    }
    return sur;
    return err;
}

status_t SurfaceComposerClient::destroySurface(const sp<IBinder>& sid) {
+12 −0
Original line number Diff line number Diff line
@@ -114,6 +114,18 @@ public:
            uint32_t ownerUid = 0 // UID of the task
    );

    status_t createSurfaceChecked(
            const String8& name,// name of the surface
            uint32_t w,         // width in pixel
            uint32_t h,         // height in pixel
            PixelFormat format, // pixel-format desired
            sp<SurfaceControl>* outSurface,
            uint32_t flags = 0, // usage flags
            SurfaceControl* parent = nullptr, // parent
            uint32_t windowType = 0, // from WindowManager.java (STATUS_BAR, INPUT_METHOD, etc.)
            uint32_t ownerUid = 0 // UID of the task
    );

    //! Create a virtual display
    static sp<IBinder> createDisplay(const String8& displayName, bool secure);