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

Commit b432879e authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge "SurfaceFlinger: Validate layers before casting." into qt-dev

parents 7536d41c c0df312c
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ public:
    
    explicit SurfaceControl(const sp<SurfaceControl>& other);

    SurfaceControl(const sp<SurfaceComposerClient>& client, const sp<IBinder>& handle,
                   const sp<IGraphicBufferProducer>& gbp, bool owned);

private:
    // can't be copied
    SurfaceControl& operator = (SurfaceControl& rhs);
@@ -92,12 +95,6 @@ private:
    friend class SurfaceComposerClient;
    friend class Surface;

    SurfaceControl(
            const sp<SurfaceComposerClient>& client,
            const sp<IBinder>& handle,
            const sp<IGraphicBufferProducer>& gbp,
            bool owned);

    ~SurfaceControl();

    sp<Surface> generateSurfaceLocked() const;
+3 −13
Original line number Diff line number Diff line
@@ -76,18 +76,9 @@ status_t Client::createSurface(const String8& name, uint32_t w, uint32_t h, Pixe
                               uint32_t flags, const sp<IBinder>& parentHandle,
                               LayerMetadata metadata, sp<IBinder>* handle,
                               sp<IGraphicBufferProducer>* gbp) {
    sp<Layer> parent = nullptr;
    if (parentHandle != nullptr) {
        auto layerHandle = reinterpret_cast<Layer::Handle*>(parentHandle.get());
        parent = layerHandle->owner.promote();
        if (parent == nullptr) {
            return NAME_NOT_FOUND;
        }
    }

    // We rely on createLayer to check permissions.
    return mFlinger->createLayer(name, this, w, h, format, flags, std::move(metadata), handle, gbp,
                                 &parent);
                                 parentHandle);
}

status_t Client::createWithSurfaceParent(const String8& name, uint32_t w, uint32_t h,
@@ -104,9 +95,8 @@ status_t Client::createWithSurfaceParent(const String8& name, uint32_t w, uint32
        return BAD_VALUE;
    }

    sp<IBinder> parentHandle = layer->getHandle();

    return createSurface(name, w, h, format, flags, parentHandle, std::move(metadata), handle, gbp);
    return mFlinger->createLayer(name, this, w, h, format, flags, std::move(metadata), handle, gbp,
                                 nullptr, layer);
}

status_t Client::clearLayerFrameStats(const sp<IBinder>& handle) const {
+5 −1
Original line number Diff line number Diff line
@@ -130,7 +130,6 @@ Layer::~Layer() {
    }

    mFrameTracker.logAndResetStats(mName);

    mFlinger->onLayerDestroyed();
}

@@ -205,6 +204,11 @@ bool Layer::getPremultipledAlpha() const {

sp<IBinder> Layer::getHandle() {
    Mutex::Autolock _l(mLock);
    if (mGetHandleCalled) {
        ALOGE("Get handle called twice" );
        return nullptr;
    }
    mGetHandleCalled = true;
    return new Handle(mFlinger, this);
}

+4 −0
Original line number Diff line number Diff line
@@ -799,6 +799,8 @@ public:
        wp<Layer> owner;
    };

    // Creates a new handle each time, so we only expect
    // this to be called once.
    sp<IBinder> getHandle();
    const String8& getName() const;
    virtual void notifyAvailableFrames() {}
@@ -932,6 +934,8 @@ private:
    FloatRect mScreenBounds;

    void setZOrderRelativeOf(const wp<Layer>& relativeOf);

    bool mGetHandleCalled = false;
};

} // namespace android
+2 −2
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ bool RefreshRateOverlay::createLayer() {
    const status_t ret =
            mFlinger.createLayer(String8("RefreshRateOverlay"), mClient, 0, 0,
                                 PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eFXSurfaceColor,
                                 LayerMetadata(), &mIBinder, &mGbp, &mLayer);
                                 LayerMetadata(), &mIBinder, &mGbp, nullptr);
    if (ret) {
        ALOGE("failed to color layer");
        ALOGE("failed to create color layer");
        return false;
    }

Loading