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

Commit db6ba5e8 authored by Chong Zhang's avatar Chong Zhang Committed by Android (Google) Code Review
Browse files

Merge "Remove libbinder usage from media.swcodec apex"

parents 8917ac6f 62493096
Loading
Loading
Loading
Loading
+16 −11
Original line number Original line Diff line number Diff line
@@ -55,7 +55,11 @@ cc_library_shared {
        "DisplayEventReceiver.cpp",
        "DisplayEventReceiver.cpp",
        "GLConsumer.cpp",
        "GLConsumer.cpp",
        "GuiConfig.cpp",
        "GuiConfig.cpp",
        "IConsumerListener.cpp",
        "IDisplayEventConnection.cpp",
        "IDisplayEventConnection.cpp",
        "IGraphicBufferConsumer.cpp",
        "IGraphicBufferProducer.cpp",
        "IProducerListener.cpp",
        "IRegionSamplingListener.cpp",
        "IRegionSamplingListener.cpp",
        "ISurfaceComposer.cpp",
        "ISurfaceComposer.cpp",
        "ISurfaceComposerClient.cpp",
        "ISurfaceComposerClient.cpp",
@@ -63,22 +67,32 @@ cc_library_shared {
        "LayerDebugInfo.cpp",
        "LayerDebugInfo.cpp",
        "LayerMetadata.cpp",
        "LayerMetadata.cpp",
        "LayerState.cpp",
        "LayerState.cpp",
        "OccupancyTracker.cpp",
        "StreamSplitter.cpp",
        "StreamSplitter.cpp",
        "Surface.cpp",
        "Surface.cpp",
        "SurfaceControl.cpp",
        "SurfaceControl.cpp",
        "SurfaceComposerClient.cpp",
        "SurfaceComposerClient.cpp",
        "SyncFeatures.cpp",
        "SyncFeatures.cpp",
        "view/Surface.cpp",
        "view/Surface.cpp",
        "bufferqueue/1.0/B2HProducerListener.cpp",
        "bufferqueue/1.0/H2BGraphicBufferProducer.cpp",
        "bufferqueue/2.0/B2HProducerListener.cpp",
        "bufferqueue/2.0/H2BGraphicBufferProducer.cpp",
    ],
    ],


    shared_libs: [
    shared_libs: [
        "android.frameworks.bufferhub@1.0",
        "android.frameworks.bufferhub@1.0",
        "libbinder",
        "libbufferhub",
        "libbufferhub",
        "libbufferhubqueue", // TODO(b/70046255): Remove this once BufferHub is integrated into libgui.
        "libbufferhubqueue", // TODO(b/70046255): Remove this once BufferHub is integrated into libgui.
        "libinput",
        "libinput",
        "libpdx_default_transport",
        "libpdx_default_transport",
    ],
    ],


    export_shared_lib_headers: [
        "libbinder",
    ],

    // bufferhub is not used when building libgui for vendors
    // bufferhub is not used when building libgui for vendors
    target: {
    target: {
        vendor: {
        vendor: {
@@ -118,6 +132,7 @@ cc_library_static {


    cflags: [
    cflags: [
        "-DNO_BUFFERHUB",
        "-DNO_BUFFERHUB",
        "-DNO_BINDER",
    ],
    ],


    defaults: ["libgui_bufferqueue-defaults"],
    defaults: ["libgui_bufferqueue-defaults"],
@@ -140,19 +155,11 @@ filegroup {
        "FrameTimestamps.cpp",
        "FrameTimestamps.cpp",
        "GLConsumerUtils.cpp",
        "GLConsumerUtils.cpp",
        "HdrMetadata.cpp",
        "HdrMetadata.cpp",
        "IConsumerListener.cpp",
        "QueueBufferInputOutput.cpp",
        "IGraphicBufferConsumer.cpp",
        "IGraphicBufferProducer.cpp",
        "IProducerListener.cpp",
        "OccupancyTracker.cpp",
        "bufferqueue/1.0/B2HProducerListener.cpp",
        "bufferqueue/1.0/Conversion.cpp",
        "bufferqueue/1.0/Conversion.cpp",
        "bufferqueue/1.0/H2BGraphicBufferProducer.cpp",
        "bufferqueue/1.0/H2BProducerListener.cpp",
        "bufferqueue/1.0/H2BProducerListener.cpp",
        "bufferqueue/1.0/WProducerListener.cpp",
        "bufferqueue/1.0/WProducerListener.cpp",
        "bufferqueue/2.0/B2HGraphicBufferProducer.cpp",
        "bufferqueue/2.0/B2HGraphicBufferProducer.cpp",
        "bufferqueue/2.0/B2HProducerListener.cpp",
        "bufferqueue/2.0/H2BGraphicBufferProducer.cpp",
        "bufferqueue/2.0/H2BProducerListener.cpp",
        "bufferqueue/2.0/H2BProducerListener.cpp",
        "bufferqueue/2.0/types.cpp",
        "bufferqueue/2.0/types.cpp",
    ],
    ],
@@ -189,7 +196,6 @@ cc_defaults {
        "android.hardware.graphics.common@1.2",
        "android.hardware.graphics.common@1.2",
        "android.hidl.token@1.0-utils",
        "android.hidl.token@1.0-utils",
        "libbase",
        "libbase",
        "libbinder",
        "libcutils",
        "libcutils",
        "libEGL",
        "libEGL",
        "libGLESv2",
        "libGLESv2",
@@ -212,7 +218,6 @@ cc_defaults {
    ],
    ],


    export_shared_lib_headers: [
    export_shared_lib_headers: [
        "libbinder",
        "libEGL",
        "libEGL",
        "libnativewindow",
        "libnativewindow",
        "libui",
        "libui",
+10 −2
Original line number Original line Diff line number Diff line
@@ -66,6 +66,8 @@ namespace android {
          mCore->mUniqueId, mCore->mConnectedApi, mCore->mConnectedPid, (mCore->mUniqueId) >> 32, \
          mCore->mUniqueId, mCore->mConnectedApi, mCore->mConnectedPid, (mCore->mUniqueId) >> 32, \
          ##__VA_ARGS__)
          ##__VA_ARGS__)


ConsumerListener::~ConsumerListener() = default;

BufferQueueConsumer::BufferQueueConsumer(const sp<BufferQueueCore>& core) :
BufferQueueConsumer::BufferQueueConsumer(const sp<BufferQueueCore>& core) :
    mCore(core),
    mCore(core),
    mSlots(core->mSlots),
    mSlots(core->mSlots),
@@ -291,8 +293,9 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,


        ATRACE_INT(mCore->mConsumerName.string(),
        ATRACE_INT(mCore->mConsumerName.string(),
                static_cast<int32_t>(mCore->mQueue.size()));
                static_cast<int32_t>(mCore->mQueue.size()));
#ifndef NO_BINDER
        mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
        mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());

#endif
        VALIDATE_CONSISTENCY();
        VALIDATE_CONSISTENCY();
    }
    }


@@ -765,7 +768,12 @@ status_t BufferQueueConsumer::getSidebandStream(sp<NativeHandle>* outStream) con
status_t BufferQueueConsumer::getOccupancyHistory(bool forceFlush,
status_t BufferQueueConsumer::getOccupancyHistory(bool forceFlush,
        std::vector<OccupancyTracker::Segment>* outHistory) {
        std::vector<OccupancyTracker::Segment>* outHistory) {
    std::lock_guard<std::mutex> lock(mCore->mMutex);
    std::lock_guard<std::mutex> lock(mCore->mMutex);
#ifndef NO_BINDER
    *outHistory = mCore->mOccupancyTracker.getSegmentHistory(forceFlush);
    *outHistory = mCore->mOccupancyTracker.getSegmentHistory(forceFlush);
#else
    (void)forceFlush;
    outHistory->clear();
#endif
    return NO_ERROR;
    return NO_ERROR;
}
}


@@ -798,7 +806,7 @@ status_t BufferQueueConsumer::dumpState(const String8& prefix, String8* outResul


    bool denied = false;
    bool denied = false;
    const uid_t uid = BufferQueueThreadState::getCallingUid();
    const uid_t uid = BufferQueueThreadState::getCallingUid();
#ifndef __ANDROID_VNDK__
#if !defined(__ANDROID_VNDK__) && !defined(NO_BINDER)
    // permission check can't be done for vendors as vendors have no access to
    // permission check can't be done for vendors as vendors have no access to
    // the PermissionController. We need to do a runtime check as well, since
    // the PermissionController. We need to do a runtime check as well, since
    // the system variant of libgui can be loaded in a vendor process. For eg:
    // the system variant of libgui can be loaded in a vendor process. For eg:
+7 −1
Original line number Original line Diff line number Diff line
@@ -67,6 +67,7 @@ namespace android {
          ##__VA_ARGS__)
          ##__VA_ARGS__)


static constexpr uint32_t BQ_LAYER_COUNT = 1;
static constexpr uint32_t BQ_LAYER_COUNT = 1;
ProducerListener::~ProducerListener() = default;


BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core,
BufferQueueProducer::BufferQueueProducer(const sp<BufferQueueCore>& core,
        bool consumerIsSurfaceFlinger) :
        bool consumerIsSurfaceFlinger) :
@@ -1005,8 +1006,9 @@ status_t BufferQueueProducer::queueBuffer(int slot,


        ATRACE_INT(mCore->mConsumerName.string(),
        ATRACE_INT(mCore->mConsumerName.string(),
                static_cast<int32_t>(mCore->mQueue.size()));
                static_cast<int32_t>(mCore->mQueue.size()));
#ifndef NO_BINDER
        mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());
        mCore->mOccupancyTracker.registerOccupancyChange(mCore->mQueue.size());

#endif
        // Take a ticket for the callback functions
        // Take a ticket for the callback functions
        callbackTicket = mNextCallbackTicket++;
        callbackTicket = mNextCallbackTicket++;


@@ -1252,6 +1254,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
            if (listener != nullptr) {
            if (listener != nullptr) {
                // Set up a death notification so that we can disconnect
                // Set up a death notification so that we can disconnect
                // automatically if the remote producer dies
                // automatically if the remote producer dies
#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));
                            static_cast<IBinder::DeathRecipient*>(this));
@@ -1261,6 +1264,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
                    }
                    }
                    mCore->mLinkedToDeath = listener;
                    mCore->mLinkedToDeath = listener;
                }
                }
#endif
                mCore->mConnectedProducerListener = listener;
                mCore->mConnectedProducerListener = listener;
                mCore->mBufferReleasedCbEnabled = listener->needsReleaseNotify();
                mCore->mBufferReleasedCbEnabled = listener->needsReleaseNotify();
            }
            }
@@ -1329,6 +1333,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) {
                if (mCore->mConnectedApi == api) {
                if (mCore->mConnectedApi == api) {
                    mCore->freeAllBuffersLocked();
                    mCore->freeAllBuffersLocked();


#ifndef NO_BINDER
                    // Remove our death notification callback if we have one
                    // Remove our death notification callback if we have one
                    if (mCore->mLinkedToDeath != nullptr) {
                    if (mCore->mLinkedToDeath != nullptr) {
                        sp<IBinder> token =
                        sp<IBinder> token =
@@ -1338,6 +1343,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) {
                        token->unlinkToDeath(
                        token->unlinkToDeath(
                                static_cast<IBinder::DeathRecipient*>(this));
                                static_cast<IBinder::DeathRecipient*>(this));
                    }
                    }
#endif
                    mCore->mSharedBufferSlot =
                    mCore->mSharedBufferSlot =
                            BufferQueueCore::INVALID_BUFFER_SLOT;
                            BufferQueueCore::INVALID_BUFFER_SLOT;
                    mCore->mLinkedToDeath = nullptr;
                    mCore->mLinkedToDeath = nullptr;
+10 −0
Original line number Original line Diff line number Diff line
@@ -14,8 +14,10 @@
 * limitations under the License.
 * limitations under the License.
 */
 */


#ifndef NO_BINDER
#include <binder/IPCThreadState.h>
#include <binder/IPCThreadState.h>
#include <binderthreadstate/CallerUtils.h>
#include <binderthreadstate/CallerUtils.h>
#endif // NO_BINDER
#include <hwbinder/IPCThreadState.h>
#include <hwbinder/IPCThreadState.h>
#include <private/gui/BufferQueueThreadState.h>
#include <private/gui/BufferQueueThreadState.h>
#include <unistd.h>
#include <unistd.h>
@@ -23,17 +25,25 @@
namespace android {
namespace android {


uid_t BufferQueueThreadState::getCallingUid() {
uid_t BufferQueueThreadState::getCallingUid() {
#ifndef NO_BINDER
    if (getCurrentServingCall() == BinderCallType::HWBINDER) {
    if (getCurrentServingCall() == BinderCallType::HWBINDER) {
        return hardware::IPCThreadState::self()->getCallingUid();
        return hardware::IPCThreadState::self()->getCallingUid();
    }
    }
    return IPCThreadState::self()->getCallingUid();
    return IPCThreadState::self()->getCallingUid();
#else // NO_BINDER
    return hardware::IPCThreadState::self()->getCallingUid();
#endif // NO_BINDER
}
}


pid_t BufferQueueThreadState::getCallingPid() {
pid_t BufferQueueThreadState::getCallingPid() {
#ifndef NO_BINDER
    if (getCurrentServingCall() == BinderCallType::HWBINDER) {
    if (getCurrentServingCall() == BinderCallType::HWBINDER) {
        return hardware::IPCThreadState::self()->getCallingPid();
        return hardware::IPCThreadState::self()->getCallingPid();
    }
    }
    return IPCThreadState::self()->getCallingPid();
    return IPCThreadState::self()->getCallingPid();
#else // NO_BINDER
    return hardware::IPCThreadState::self()->getCallingPid();
#endif // NO_BINDER
}
}


} // namespace android
} // namespace android
+0 −1
Original line number Original line Diff line number Diff line
@@ -90,7 +90,6 @@ public:
// Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see
// Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see
// clang warning -Wweak-vtables)
// clang warning -Wweak-vtables)
BpConsumerListener::~BpConsumerListener() = default;
BpConsumerListener::~BpConsumerListener() = default;
ConsumerListener::~ConsumerListener() = default;


IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener");
IMPLEMENT_META_INTERFACE(ConsumerListener, "android.gui.IConsumerListener");


Loading