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

Commit 81793808 authored by Anton Ivanov's avatar Anton Ivanov
Browse files

Harden construction sites of android::StrongPointer.

Bug: 393217449
Test: presubmit
Flag: EXEMPT_refactor
Change-Id: Icf703aed608531e9b302b299481af00a52074731
parent f6dc8535
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -197,12 +197,12 @@ BLASTBufferQueue::BLASTBufferQueue(const std::string& name, bool updateDestinati
        mUpdateDestinationFrame(updateDestinationFrame) {
        mUpdateDestinationFrame(updateDestinationFrame) {
    createBufferQueue(&mProducer, &mConsumer);
    createBufferQueue(&mProducer, &mConsumer);
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ)
    mBufferItemConsumer = new BLASTBufferItemConsumer(mProducer, mConsumer,
    mBufferItemConsumer = sp<BLASTBufferItemConsumer>::make(mProducer, mConsumer,
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                            1, false, this);
                                                            1, false, this);
#else
#else
    mBufferItemConsumer = new BLASTBufferItemConsumer(mConsumer,
    mBufferItemConsumer = sp<BLASTBufferItemConsumer>::make(mConsumer,
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                            GraphicBuffer::USAGE_HW_COMPOSER |
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                                    GraphicBuffer::USAGE_HW_TEXTURE,
                                                            1, false, this);
                                                            1, false, this);
@@ -641,7 +641,8 @@ status_t BLASTBufferQueue::acquireNextBufferLocked(
                           bufferItem.mScalingMode, crop);
                           bufferItem.mScalingMode, crop);


    auto releaseBufferCallback = makeReleaseBufferCallbackThunk();
    auto releaseBufferCallback = makeReleaseBufferCallbackThunk();
    sp<Fence> fence = bufferItem.mFence ? new Fence(bufferItem.mFence->dup()) : Fence::NO_FENCE;
    sp<Fence> fence =
            bufferItem.mFence ? sp<Fence>::make(bufferItem.mFence->dup()) : Fence::NO_FENCE;


    nsecs_t dequeueTime = -1;
    nsecs_t dequeueTime = -1;
    {
    {
@@ -1018,7 +1019,8 @@ sp<Surface> BLASTBufferQueue::getSurface(bool includeSurfaceControlHandle) {
    if (includeSurfaceControlHandle && mSurfaceControl) {
    if (includeSurfaceControlHandle && mSurfaceControl) {
        scHandle = mSurfaceControl->getHandle();
        scHandle = mSurfaceControl->getHandle();
    }
    }
    return new BBQSurface(mProducer, true, scHandle, this);
    return sp<BBQSurface>::make(mProducer, true, scHandle,
                                sp<BLASTBufferQueue>::fromExisting(this));
}
}


void BLASTBufferQueue::mergeWithNextTransaction(SurfaceComposerClient::Transaction* t,
void BLASTBufferQueue::mergeWithNextTransaction(SurfaceComposerClient::Transaction* t,
@@ -1181,7 +1183,7 @@ public:
            return BufferQueueProducer::connect(listener, api, producerControlledByApp, output);
            return BufferQueueProducer::connect(listener, api, producerControlledByApp, output);
        }
        }


        return BufferQueueProducer::connect(new AsyncProducerListener(listener), api,
        return BufferQueueProducer::connect(sp<AsyncProducerListener>::make(listener), api,
                                            producerControlledByApp, output);
                                            producerControlledByApp, output);
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -215,14 +215,14 @@ status_t BufferItem::unflatten(
    FlattenableUtils::read(buffer, size, flags);
    FlattenableUtils::read(buffer, size, flags);


    if (flags & 1) {
    if (flags & 1) {
        mGraphicBuffer = new GraphicBuffer();
        mGraphicBuffer = sp<GraphicBuffer>::make();
        status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
        status_t err = mGraphicBuffer->unflatten(buffer, size, fds, count);
        if (err) return err;
        if (err) return err;
        size -= FlattenableUtils::align<4>(buffer);
        size -= FlattenableUtils::align<4>(buffer);
    }
    }


    if (flags & 2) {
    if (flags & 2) {
        mFence = new Fence();
        mFence = sp<Fence>::make();
        status_t err = mFence->unflatten(buffer, size, fds, count);
        status_t err = mFence->unflatten(buffer, size, fds, count);
        if (err) return err;
        if (err) return err;
        size -= FlattenableUtils::align<4>(buffer);
        size -= FlattenableUtils::align<4>(buffer);
+4 −3
Original line number Original line Diff line number Diff line
@@ -125,15 +125,16 @@ void BufferQueue::createBufferQueue(sp<IGraphicBufferProducer>* outProducer,
    LOG_ALWAYS_FATAL_IF(outConsumer == nullptr,
    LOG_ALWAYS_FATAL_IF(outConsumer == nullptr,
            "BufferQueue: outConsumer must not be NULL");
            "BufferQueue: outConsumer must not be NULL");


    sp<BufferQueueCore> core(new BufferQueueCore());
    sp<BufferQueueCore> core = sp<BufferQueueCore>::make();
    LOG_ALWAYS_FATAL_IF(core == nullptr,
    LOG_ALWAYS_FATAL_IF(core == nullptr,
            "BufferQueue: failed to create BufferQueueCore");
            "BufferQueue: failed to create BufferQueueCore");


    sp<IGraphicBufferProducer> producer(new BufferQueueProducer(core, consumerIsSurfaceFlinger));
    sp<IGraphicBufferProducer> producer =
            sp<BufferQueueProducer>::make(core, consumerIsSurfaceFlinger);
    LOG_ALWAYS_FATAL_IF(producer == nullptr,
    LOG_ALWAYS_FATAL_IF(producer == nullptr,
            "BufferQueue: failed to create BufferQueueProducer");
            "BufferQueue: failed to create BufferQueueProducer");


    sp<IGraphicBufferConsumer> consumer(new BufferQueueConsumer(core));
    sp<IGraphicBufferConsumer> consumer = sp<BufferQueueConsumer>::make(core);
    LOG_ALWAYS_FATAL_IF(consumer == nullptr,
    LOG_ALWAYS_FATAL_IF(consumer == nullptr,
            "BufferQueue: failed to create BufferQueueConsumer");
            "BufferQueue: failed to create BufferQueueConsumer");


+9 −10
Original line number Original line Diff line number Diff line
@@ -693,11 +693,11 @@ status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* ou
                .requestorName = {mConsumerName.c_str(), mConsumerName.size()},
                .requestorName = {mConsumerName.c_str(), mConsumerName.size()},
                .extras = std::move(tempOptions),
                .extras = std::move(tempOptions),
        };
        };
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest);
        sp<GraphicBuffer> graphicBuffer = sp<GraphicBuffer>::make(allocRequest);
#else
#else
        sp<GraphicBuffer> graphicBuffer =
        sp<GraphicBuffer> graphicBuffer =
                new GraphicBuffer(width, height, format, BQ_LAYER_COUNT, usage,
                sp<GraphicBuffer>::make(width, height, format, BQ_LAYER_COUNT, usage,
                                  {mConsumerName.c_str(), mConsumerName.size()});
                                        std::string{mConsumerName.c_str(), mConsumerName.size()});
#endif
#endif


        status_t error = graphicBuffer->initCheck();
        status_t error = graphicBuffer->initCheck();
@@ -1464,7 +1464,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
#ifndef NO_BINDER
#ifndef NO_BINDER
                if (IInterface::asBinder(listener)->remoteBinder() != nullptr) {
                if (IInterface::asBinder(listener)->remoteBinder() != nullptr) {
                    status = IInterface::asBinder(listener)->linkToDeath(
                    status = IInterface::asBinder(listener)->linkToDeath(
                            static_cast<IBinder::DeathRecipient*>(this));
                            sp<IBinder::DeathRecipient>::fromExisting(this));
                    if (status != NO_ERROR) {
                    if (status != NO_ERROR) {
                        BQ_LOGE("connect: linkToDeath failed: %s (%d)",
                        BQ_LOGE("connect: linkToDeath failed: %s (%d)",
                                strerror(-status), status);
                                strerror(-status), status);
@@ -1553,8 +1553,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) {
                                IInterface::asBinder(mCore->mLinkedToDeath);
                                IInterface::asBinder(mCore->mLinkedToDeath);
                        // This can fail if we're here because of the death
                        // This can fail if we're here because of the death
                        // notification, but we just ignore it
                        // notification, but we just ignore it
                        token->unlinkToDeath(
                        token->unlinkToDeath(sp<IBinder::DeathRecipient>::fromExisting(this));
                                static_cast<IBinder::DeathRecipient*>(this));
                    }
                    }
#endif
#endif
                    mCore->mSharedBufferSlot =
                    mCore->mSharedBufferSlot =
@@ -1685,10 +1684,10 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,
#endif
#endif


#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(allocRequest);
        sp<GraphicBuffer> graphicBuffer = sp<GraphicBuffer>::make(allocRequest);
#else
#else
        sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(
        sp<GraphicBuffer> graphicBuffer =
                allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
                sp<GraphicBuffer>::make(allocWidth, allocHeight, allocFormat, BQ_LAYER_COUNT,
                                        allocUsage, allocName);
                                        allocUsage, allocName);
#endif
#endif


+2 −2
Original line number Original line Diff line number Diff line
@@ -108,7 +108,7 @@ status_t BufferReleaseChannel::Message::flatten(void*& buffer, size_t& size, int


status_t BufferReleaseChannel::Message::unflatten(void const*& buffer, size_t& size,
status_t BufferReleaseChannel::Message::unflatten(void const*& buffer, size_t& size,
                                                  int const*& fds, size_t& count) {
                                                  int const*& fds, size_t& count) {
    releaseFence = new Fence();
    releaseFence = sp<Fence>::make();
    if (status_t err = releaseFence->unflatten(buffer, size, fds, count); err != OK) {
    if (status_t err = releaseFence->unflatten(buffer, size, fds, count); err != OK) {
        return err;
        return err;
    }
    }
Loading