From 9bad0d7e726e6b264c528a3dd13d0c58fd92c0e1 Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Tue, 19 Dec 2017 12:34:34 -0700 Subject: Add plumbing for HDR metadata Allow a ANativeWindow client to send HDR metadata to SurfaceFlinger. The metadata can be queried with BufferLayerConsumer::getCurrentHdrMetadata. Written by Courtney. Updated by olv@. Bug: 63710530 Test: builds Change-Id: I23192d4750950664b57863a533bffd72397255b4 --- libs/gui/IGraphicBufferProducer.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libs/gui/IGraphicBufferProducer.cpp') diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 71e22cedf0..7e4902405e 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -951,7 +951,8 @@ constexpr size_t IGraphicBufferProducer::QueueBufferInput::minFlattenedSize() { size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const { return minFlattenedSize() + fence->getFlattenedSize() + - surfaceDamage.getFlattenedSize(); + surfaceDamage.getFlattenedSize() + + hdrMetadata.getFlattenedSize(); } size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const { @@ -978,7 +979,12 @@ status_t IGraphicBufferProducer::QueueBufferInput::flatten( if (result != NO_ERROR) { return result; } - return surfaceDamage.flatten(buffer, size); + result = surfaceDamage.flatten(buffer, size); + if (result != NO_ERROR) { + return result; + } + FlattenableUtils::advance(buffer, size, surfaceDamage.getFlattenedSize()); + return hdrMetadata.flatten(buffer, size); } status_t IGraphicBufferProducer::QueueBufferInput::unflatten( @@ -1002,7 +1008,12 @@ status_t IGraphicBufferProducer::QueueBufferInput::unflatten( if (result != NO_ERROR) { return result; } - return surfaceDamage.unflatten(buffer, size); + result = surfaceDamage.unflatten(buffer, size); + if (result != NO_ERROR) { + return result; + } + FlattenableUtils::advance(buffer, size, surfaceDamage.getFlattenedSize()); + return hdrMetadata.unflatten(buffer, size); } // ---------------------------------------------------------------------------- -- cgit v1.2.3-59-g8ed1b From c90a77f1e5b42d8fcf336d2b9bd2259280814df2 Mon Sep 17 00:00:00 2001 From: Jiwen 'Steve' Cai Date: Sun, 14 Jan 2018 15:42:29 -0800 Subject: Add BufferHub backend for android::view::Surface This CL allows BufferHubProducer to be used as alternative backend of parcelable Surface. When sent over binder, BufferHubProducer serializes itself differently from Binder-based IGBP objects. Instead of writing to a Parcel object as strong binder object, BufferHubProducer asks libbufferhubqueue to generate a BufferHubQueueParcelable object (which packs all the FDs representing the BufferHub channel). When received from a binder interface, BufferHubProducer object can be reconstructed from the BufferHubQueueParcelable object. The newly constructed object has all the FDs (i.e. UDS channels) directly connected to bufferhubd. Thus, on going buffer transport operations can happen directly between the receiving process and bufferhubd. This elimates one extra binder hop. Bug: 37517761 Bug: 70046255 Test: libgui_test, buffer_transport_benchmark, buffer_hub_queue_producer-test, dvr_api-test, SurfaceParcelable_test Change-Id: I78bd879f36d3196f3d74c76c79d27467740792f7 --- libs/gui/BufferHubProducer.cpp | 50 ++++++-- libs/gui/IGraphicBufferProducer.cpp | 70 +++++++++++ libs/gui/include/gui/BufferHubProducer.h | 24 +++- libs/gui/include/gui/IGraphicBufferProducer.h | 26 ++++ libs/gui/tests/Android.bp | 32 +++++ libs/gui/tests/SurfaceParcelable_test.cpp | 169 ++++++++++++++++++++++++++ libs/gui/view/Surface.cpp | 16 +-- 7 files changed, 360 insertions(+), 27 deletions(-) create mode 100644 libs/gui/tests/SurfaceParcelable_test.cpp (limited to 'libs/gui/IGraphicBufferProducer.cpp') diff --git a/libs/gui/BufferHubProducer.cpp b/libs/gui/BufferHubProducer.cpp index af1f83356d..c383f40355 100644 --- a/libs/gui/BufferHubProducer.cpp +++ b/libs/gui/BufferHubProducer.cpp @@ -35,8 +35,10 @@ namespace android { +using namespace dvr; + /* static */ -sp BufferHubProducer::Create(const std::shared_ptr& queue) { +sp BufferHubProducer::Create(const std::shared_ptr& queue) { if (queue->metadata_size() != sizeof(DvrNativeBufferMetadata)) { ALOGE("BufferHubProducer::Create producer's metadata size is different " "than the size of DvrNativeBufferMetadata"); @@ -49,14 +51,14 @@ sp BufferHubProducer::Create(const std::shared_ptr BufferHubProducer::Create(dvr::ProducerQueueParcelable parcelable) { +sp BufferHubProducer::Create(ProducerQueueParcelable parcelable) { if (!parcelable.IsValid()) { ALOGE("BufferHubProducer::Create: Invalid producer parcelable."); return nullptr; } sp producer = new BufferHubProducer; - producer->queue_ = dvr::ProducerQueue::Import(parcelable.TakeChannelHandle()); + producer->queue_ = ProducerQueue::Import(parcelable.TakeChannelHandle()); return producer; } @@ -102,9 +104,9 @@ status_t BufferHubProducer::setMaxDequeuedBufferCount(int max_dequeued_buffers) if (max_dequeued_buffers <= 0 || max_dequeued_buffers > - int(dvr::BufferHubQueue::kMaxQueueCapacity - kDefaultUndequeuedBuffers)) { + int(BufferHubQueue::kMaxQueueCapacity - kDefaultUndequeuedBuffers)) { ALOGE("setMaxDequeuedBufferCount: %d out of range (0, %zu]", max_dequeued_buffers, - dvr::BufferHubQueue::kMaxQueueCapacity); + BufferHubQueue::kMaxQueueCapacity); return BAD_VALUE; } @@ -153,7 +155,7 @@ status_t BufferHubProducer::dequeueBuffer(int* out_slot, sp* out_fence, u uint32_t height, PixelFormat format, uint64_t usage, uint64_t* /*outBufferAge*/, FrameEventHistoryDelta* /* out_timestamps */) { - ALOGV("dequeueBuffer: w=%u, h=%u, format=%d, usage=%" PRIu64, width, height, format, usage); + ALOGW("dequeueBuffer: w=%u, h=%u, format=%d, usage=%" PRIu64, width, height, format, usage); status_t ret; std::unique_lock lock(mutex_); @@ -174,9 +176,9 @@ status_t BufferHubProducer::dequeueBuffer(int* out_slot, sp* out_fence, u } size_t slot = 0; - std::shared_ptr buffer_producer; + std::shared_ptr buffer_producer; - for (size_t retry = 0; retry < dvr::BufferHubQueue::kMaxQueueCapacity; retry++) { + for (size_t retry = 0; retry < BufferHubQueue::kMaxQueueCapacity; retry++) { LocalHandle fence; auto buffer_status = queue_->Dequeue(dequeue_timeout_ms_, &slot, &fence); if (!buffer_status) return NO_MEMORY; @@ -225,7 +227,7 @@ status_t BufferHubProducer::dequeueBuffer(int* out_slot, sp* out_fence, u buffers_[slot].mBufferState.freeQueued(); buffers_[slot].mBufferState.dequeue(); - ALOGV("dequeueBuffer: slot=%zu", slot); + ALOGW("dequeueBuffer: slot=%zu", slot); // TODO(jwcai) Handle fence properly. |BufferHub| has full fence support, we // just need to exopose that through |BufferHubQueue| once we need fence. @@ -590,7 +592,7 @@ status_t BufferHubProducer::setDequeueTimeout(nsecs_t timeout) { ALOGV(__FUNCTION__); std::unique_lock lock(mutex_); - dequeue_timeout_ms_ = int(timeout / (1000 * 1000)); + dequeue_timeout_ms_ = static_cast(timeout / (1000 * 1000)); return NO_ERROR; } @@ -620,7 +622,7 @@ status_t BufferHubProducer::getConsumerUsage(uint64_t* out_usage) const { return NO_ERROR; } -status_t BufferHubProducer::TakeAsParcelable(dvr::ProducerQueueParcelable* out_parcelable) { +status_t BufferHubProducer::TakeAsParcelable(ProducerQueueParcelable* out_parcelable) { if (!out_parcelable || out_parcelable->IsValid()) return BAD_VALUE; if (connected_api_ != kNoConnectedApi) { @@ -684,7 +686,7 @@ status_t BufferHubProducer::RemoveBuffer(size_t slot) { } status_t BufferHubProducer::FreeAllBuffers() { - for (size_t slot = 0; slot < dvr::BufferHubQueue::kMaxQueueCapacity; slot++) { + for (size_t slot = 0; slot < BufferHubQueue::kMaxQueueCapacity; slot++) { // Reset in memory objects related the the buffer. buffers_[slot].mGraphicBuffer = nullptr; buffers_[slot].mBufferState.reset(); @@ -707,4 +709,28 @@ status_t BufferHubProducer::FreeAllBuffers() { return NO_ERROR; } +status_t BufferHubProducer::exportToParcel(Parcel* parcel) { + status_t res = TakeAsParcelable(&pending_producer_parcelable_); + if (res != NO_ERROR) return res; + + if (!pending_producer_parcelable_.IsValid()) { + ALOGE("BufferHubProducer::exportToParcel: Invalid parcelable object."); + return BAD_VALUE; + } + + res = parcel->writeUint32(USE_BUFFER_HUB); + if (res != NO_ERROR) { + ALOGE("BufferHubProducer::exportToParcel: Cannot write magic, res=%d.", res); + return res; + } + + return pending_producer_parcelable_.writeToParcel(parcel); +} + +IBinder* BufferHubProducer::onAsBinder() { + ALOGE("BufferHubProducer::onAsBinder: BufferHubProducer should never be used as an Binder " + "object."); + return nullptr; +} + } // namespace android diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 7e4902405e..777a3e5e9b 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -653,6 +654,75 @@ IMPLEMENT_HYBRID_META_INTERFACE(GraphicBufferProducer, HGraphicBufferProducer, // ---------------------------------------------------------------------- +status_t IGraphicBufferProducer::exportToParcel(Parcel* parcel) { + status_t res = OK; + res = parcel->writeUint32(USE_BUFFER_QUEUE); + if (res != NO_ERROR) { + ALOGE("exportToParcel: Cannot write magic, res=%d.", res); + return res; + } + + return parcel->writeStrongBinder(IInterface::asBinder(this)); +} + +/* static */ +status_t IGraphicBufferProducer::exportToParcel(const sp& producer, + Parcel* parcel) { + if (parcel == nullptr) { + ALOGE("exportToParcel: Invalid parcel object."); + return BAD_VALUE; + } + + if (producer == nullptr) { + status_t res = OK; + res = parcel->writeUint32(IGraphicBufferProducer::USE_BUFFER_QUEUE); + if (res != NO_ERROR) return res; + return parcel->writeStrongBinder(nullptr); + } else { + return producer->exportToParcel(parcel); + } +} + +/* static */ +sp IGraphicBufferProducer::createFromParcel(const Parcel* parcel) { + uint32_t outMagic = 0; + status_t res = NO_ERROR; + + res = parcel->readUint32(&outMagic); + if (res != NO_ERROR) { + ALOGE("createFromParcel: Failed to read magic, error=%d.", res); + return nullptr; + } + + switch (outMagic) { + case USE_BUFFER_QUEUE: { + sp binder; + res = parcel->readNullableStrongBinder(&binder); + if (res != NO_ERROR) { + ALOGE("createFromParcel: Can't read strong binder."); + return nullptr; + } + return interface_cast(binder); + } + case USE_BUFFER_HUB: { + ALOGE("createFromParcel: BufferHub not implemented."); + dvr::ProducerQueueParcelable producerParcelable; + res = producerParcelable.readFromParcel(parcel); + if (res != NO_ERROR) { + ALOGE("createFromParcel: Failed to read from parcel, error=%d", res); + return nullptr; + } + return BufferHubProducer::Create(std::move(producerParcelable)); + } + default: { + ALOGE("createFromParcel: Unexpected mgaic: 0x%x.", outMagic); + return nullptr; + } + } +} + +// ---------------------------------------------------------------------------- + status_t BnGraphicBufferProducer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/gui/include/gui/BufferHubProducer.h b/libs/gui/include/gui/BufferHubProducer.h index 2ee011b0d3..e596dc9679 100644 --- a/libs/gui/include/gui/BufferHubProducer.h +++ b/libs/gui/include/gui/BufferHubProducer.h @@ -19,12 +19,25 @@ #include #include + +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Weverything" +#endif + +// The following headers are included without checking every warning. +// TODO(b/72172820): Remove the workaround once we have enforced -Weverything +// in these headers and their dependencies. #include #include +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + namespace android { -class BufferHubProducer : public BnGraphicBufferProducer { +class BufferHubProducer : public IGraphicBufferProducer { public: static constexpr int kNoConnectedApi = -1; @@ -135,6 +148,12 @@ public: // invalid parcelable. status_t TakeAsParcelable(dvr::ProducerQueueParcelable* out_parcelable); + IBinder* onAsBinder() override; + +protected: + // See |IGraphicBufferProducer::exportToParcel| + status_t exportToParcel(Parcel* parcel) override; + private: using LocalHandle = pdx::LocalHandle; @@ -203,6 +222,9 @@ private: // A uniqueId used by IGraphicBufferProducer interface. const uint64_t unique_id_{genUniqueId()}; + + // A pending parcelable object which keeps the bufferhub channel alive. + dvr::ProducerQueueParcelable pending_producer_parcelable_; }; } // namespace android diff --git a/libs/gui/include/gui/IGraphicBufferProducer.h b/libs/gui/include/gui/IGraphicBufferProducer.h index 722833eed6..887654e05b 100644 --- a/libs/gui/include/gui/IGraphicBufferProducer.h +++ b/libs/gui/include/gui/IGraphicBufferProducer.h @@ -73,6 +73,14 @@ public: RELEASE_ALL_BUFFERS = 0x2, }; + enum { + // A parcelable magic indicates using Binder BufferQueue as transport + // backend. + USE_BUFFER_QUEUE = 0x62717565, // 'bque' + // A parcelable magic indicates using BufferHub as transport backend. + USE_BUFFER_HUB = 0x62687562, // 'bhub' + }; + // requestBuffer requests a new buffer for the given index. The server (i.e. // the IGraphicBufferProducer implementation) assigns the newly created // buffer to the given slot index, and the client is expected to mirror the @@ -604,6 +612,24 @@ public: // returned by querying the now deprecated // NATIVE_WINDOW_CONSUMER_USAGE_BITS attribute. virtual status_t getConsumerUsage(uint64_t* outUsage) const = 0; + + // Static method exports any IGraphicBufferProducer object to a parcel. It + // handles null producer as well. + static status_t exportToParcel(const sp& producer, + Parcel* parcel); + + // Factory method that creates a new IBGP instance from the parcel. + static sp createFromParcel(const Parcel* parcel); + +protected: + // Exports the current producer as a binder parcelable object. Note that the + // producer must be disconnected to be exportable. After successful export, + // the producer queue can no longer be connected again. Returns NO_ERROR + // when the export is successful and writes an implementation defined + // parcelable object into the parcel. For traditional Android BufferQueue, + // it writes a strong binder object; for BufferHub, it writes a + // ProducerQueueParcelable object. + virtual status_t exportToParcel(Parcel* parcel); }; // ---------------------------------------------------------------------------- diff --git a/libs/gui/tests/Android.bp b/libs/gui/tests/Android.bp index 908959ce1a..01e90e0eb8 100644 --- a/libs/gui/tests/Android.bp +++ b/libs/gui/tests/Android.bp @@ -49,3 +49,35 @@ cc_test { "libnativewindow" ], } + +// Build a separate binary for each source file to $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +cc_test { + name: "libgui_separate_binary_test", + test_suites: ["device-tests"], + + clang: true, + cflags: [ + "-Wall", + "-Werror", + ], + + test_per_src: true, + srcs: [ + "SurfaceParcelable_test.cpp", + ], + + shared_libs: [ + "liblog", + "libbinder", + "libcutils", + "libgui", + "libui", + "libutils", + "libbufferhubqueue", // TODO(b/70046255): Remove these once BufferHub is integrated into libgui. + "libpdx_default_transport", + ], + + header_libs: [ + "libdvr_headers", + ], +} diff --git a/libs/gui/tests/SurfaceParcelable_test.cpp b/libs/gui/tests/SurfaceParcelable_test.cpp new file mode 100644 index 0000000000..99a8a7a591 --- /dev/null +++ b/libs/gui/tests/SurfaceParcelable_test.cpp @@ -0,0 +1,169 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "SurfaceParcelable_test" + +#include + +#include +#include +#include +#include +#include +#include + +namespace android { + +static const String16 kTestServiceName = String16("SurfaceParcelableTestService"); +static const String16 kSurfaceName = String16("TEST_SURFACE"); +static const uint32_t kBufferWidth = 100; +static const uint32_t kBufferHeight = 1; +static const uint32_t kBufferFormat = HAL_PIXEL_FORMAT_BLOB; + +enum SurfaceParcelableTestServiceCode { + CREATE_BUFFER_QUEUE_SURFACE = IBinder::FIRST_CALL_TRANSACTION, + CREATE_BUFFER_HUB_SURFACE, +}; + +class SurfaceParcelableTestService : public BBinder { +public: + SurfaceParcelableTestService() { + // BufferQueue + BufferQueue::createBufferQueue(&mBufferQueueProducer, &mBufferQueueConsumer); + + // BufferHub + dvr::ProducerQueueConfigBuilder configBuilder; + mProducerQueue = dvr::ProducerQueue::Create(configBuilder.SetDefaultWidth(kBufferWidth) + .SetDefaultHeight(kBufferHeight) + .SetDefaultFormat(kBufferFormat) + .SetMetadata() + .Build(), + dvr::UsagePolicy{}); + mBufferHubProducer = BufferHubProducer::Create(mProducerQueue); + } + + ~SurfaceParcelableTestService() = default; + + virtual status_t onTransact(uint32_t code, const Parcel& /*data*/, Parcel* reply, + uint32_t /*flags*/ = 0) { + switch (code) { + case CREATE_BUFFER_QUEUE_SURFACE: { + view::Surface surfaceShim; + surfaceShim.name = kSurfaceName; + surfaceShim.graphicBufferProducer = mBufferQueueProducer; + return surfaceShim.writeToParcel(reply); + } + case CREATE_BUFFER_HUB_SURFACE: { + view::Surface surfaceShim; + surfaceShim.name = kSurfaceName; + surfaceShim.graphicBufferProducer = mBufferHubProducer; + return surfaceShim.writeToParcel(reply); + } + default: + return UNKNOWN_TRANSACTION; + }; + } + +protected: + sp mBufferQueueProducer; + sp mBufferQueueConsumer; + + std::shared_ptr mProducerQueue; + sp mBufferHubProducer; +}; + +static int runBinderServer() { + ProcessState::self()->startThreadPool(); + + sp sm = defaultServiceManager(); + sp service = new SurfaceParcelableTestService; + sm->addService(kTestServiceName, service, false); + + ALOGI("Binder server running..."); + + while (true) { + int stat, retval; + retval = wait(&stat); + if (retval == -1 && errno == ECHILD) { + break; + } + } + + ALOGI("Binder server exiting..."); + return 0; +} + +class SurfaceParcelableTest : public ::testing::TestWithParam { +protected: + virtual void SetUp() { + mService = defaultServiceManager()->getService(kTestServiceName); + if (mService == nullptr) { + ALOGE("Failed to connect to the test service."); + return; + } + + ALOGI("Binder service is ready for client."); + } + + status_t GetSurface(view::Surface* surfaceShim) { + ALOGI("...Test: %d", GetParam()); + + uint32_t opCode = GetParam(); + Parcel data; + Parcel reply; + status_t error = mService->transact(opCode, data, &reply); + if (error != NO_ERROR) { + ALOGE("Failed to get surface over binder, error=%d.", error); + return error; + } + + error = surfaceShim->readFromParcel(&reply); + if (error != NO_ERROR) { + ALOGE("Failed to get surface from parcel, error=%d.", error); + return error; + } + + return NO_ERROR; + } + +private: + sp mService; +}; + +TEST_P(SurfaceParcelableTest, SendOverBinder) { + view::Surface surfaceShim; + EXPECT_EQ(GetSurface(&surfaceShim), NO_ERROR); + EXPECT_EQ(surfaceShim.name, kSurfaceName); + EXPECT_FALSE(surfaceShim.graphicBufferProducer == nullptr); +} + +INSTANTIATE_TEST_CASE_P(SurfaceBackends, SurfaceParcelableTest, + ::testing::Values(CREATE_BUFFER_QUEUE_SURFACE, CREATE_BUFFER_HUB_SURFACE)); + +} // namespace android + +int main(int argc, char** argv) { + pid_t pid = fork(); + if (pid == 0) { + android::ProcessState::self()->startThreadPool(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); + + } else { + ALOGI("Test process pid: %d.", pid); + return android::runBinderServer(); + } +} diff --git a/libs/gui/view/Surface.cpp b/libs/gui/view/Surface.cpp index 5ed3d3bebb..d64dfd55be 100644 --- a/libs/gui/view/Surface.cpp +++ b/libs/gui/view/Surface.cpp @@ -45,10 +45,7 @@ status_t Surface::writeToParcel(Parcel* parcel, bool nameAlreadyWritten) const { if (res != OK) return res; } - res = parcel->writeStrongBinder( - IGraphicBufferProducer::asBinder(graphicBufferProducer)); - - return res; + return IGraphicBufferProducer::exportToParcel(graphicBufferProducer, parcel); } status_t Surface::readFromParcel(const Parcel* parcel) { @@ -70,16 +67,7 @@ status_t Surface::readFromParcel(const Parcel* parcel, bool nameAlreadyRead) { } } - sp binder; - - res = parcel->readNullableStrongBinder(&binder); - if (res != OK) { - ALOGE("%s: Can't read strong binder", __FUNCTION__); - return res; - } - - graphicBufferProducer = interface_cast(binder); - + graphicBufferProducer = IGraphicBufferProducer::createFromParcel(parcel); return OK; } -- cgit v1.2.3-59-g8ed1b From e3f35e348f6dea5288913736f26fa1233aa428fd Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Mon, 9 Apr 2018 12:16:30 +0900 Subject: Mark some libs as double_loadable Following libs are explicitly marked as double_loadable since they are one of the (indirect) dependencies of LLNDK libraries and at the same time they themselves are marked as VNDK. Such lib can be double loaded inside a vendor process. * libgui and libbinder: due to indirect dependency from libmediandk via libmediaomx. libmediandk is LLNDK) * libui: due to dependency from libnativewindow, which is LLNDK. Also, dependencies from libui and libgui to libpdx_default_transport and libbufferhubque are cut when building libui and libgui for vendors. This is primarily to exclude libpdx* and libbufferhubqueue from VNDK and secondly not to mark transitive dependencies of the libs (such as libcrypto) as double_loadable. Note: even without this change, the library is already capable of being double loaded due to the dependency chain towards it. This change is to make it explicit so that double loading of a library is carefully tracked and signed-off by the owner of the lib. Bug: 77155589 Test: m -j Merged-In: Id4768162aeb72b71d63d7e4498980f276ef58e6b Change-Id: I30c10400d3c4630539001b972ec897faabb4be20 (cherry picked from commit a75d3d6d9f2aef4b1855e6a58332859f3531143d) --- libs/gui/Android.bp | 16 ++++++++++++++++ libs/gui/BufferQueue.cpp | 5 +++++ libs/gui/IGraphicBufferProducer.cpp | 6 ++++++ libs/gui/include/gui/BufferQueue.h | 2 ++ libs/ui/Android.bp | 2 +- libs/vr/libbufferhub/Android.bp | 9 --------- libs/vr/libbufferhubqueue/Android.bp | 4 ---- libs/vr/libdvr/Android.bp | 5 +---- libs/vr/libpdx/Android.bp | 4 ---- libs/vr/libpdx_default_transport/Android.bp | 8 -------- libs/vr/libpdx_uds/Android.bp | 4 ---- 11 files changed, 31 insertions(+), 34 deletions(-) (limited to 'libs/gui/IGraphicBufferProducer.cpp') diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp index 6528b49994..b29c1d5157 100644 --- a/libs/gui/Android.bp +++ b/libs/gui/Android.bp @@ -140,10 +140,26 @@ cc_library_shared { "android.hardware.configstore-utils", ], + // bufferhub is not used when building libgui for vendors + target: { + vendor: { + cflags: ["-DNO_BUFFERHUB"], + exclude_srcs: [ + "BufferHubConsumer.cpp", + "BufferHubProducer.cpp", + ], + exclude_shared_libs: [ + "libbufferhubqueue", + "libpdx_default_transport", + ], + }, + }, + header_libs: [ "libdvr_headers", "libnativebase_headers", "libgui_headers", + "libpdx_headers", ], export_shared_lib_headers: [ diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 2917f45164..a8da1347cb 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -18,8 +18,11 @@ #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 +#ifndef NO_BUFFERHUB #include #include +#endif + #include #include #include @@ -103,6 +106,7 @@ void BufferQueue::createBufferQueue(sp* outProducer, *outConsumer = consumer; } +#ifndef NO_BUFFERHUB void BufferQueue::createBufferHubQueue(sp* outProducer, sp* outConsumer) { LOG_ALWAYS_FATAL_IF(outProducer == NULL, "BufferQueue: outProducer must not be NULL"); @@ -128,5 +132,6 @@ void BufferQueue::createBufferHubQueue(sp* outProducer, *outProducer = producer; *outConsumer = consumer; } +#endif }; // namespace android diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 777a3e5e9b..0749fde1ad 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -27,7 +27,9 @@ #include #include +#ifndef NO_BUFFERHUB #include +#endif #include #include #include @@ -706,6 +708,7 @@ sp IGraphicBufferProducer::createFromParcel(const Parcel } case USE_BUFFER_HUB: { ALOGE("createFromParcel: BufferHub not implemented."); +#ifndef NO_BUFFERHUB dvr::ProducerQueueParcelable producerParcelable; res = producerParcelable.readFromParcel(parcel); if (res != NO_ERROR) { @@ -713,6 +716,9 @@ sp IGraphicBufferProducer::createFromParcel(const Parcel return nullptr; } return BufferHubProducer::Create(std::move(producerParcelable)); +#else + return nullptr; +#endif } default: { ALOGE("createFromParcel: Unexpected mgaic: 0x%x.", outMagic); diff --git a/libs/gui/include/gui/BufferQueue.h b/libs/gui/include/gui/BufferQueue.h index f175573366..da952744f3 100644 --- a/libs/gui/include/gui/BufferQueue.h +++ b/libs/gui/include/gui/BufferQueue.h @@ -79,9 +79,11 @@ public: sp* outConsumer, bool consumerIsSurfaceFlinger = false); +#ifndef NO_BUFFERHUB // Creates an IGraphicBufferProducer and IGraphicBufferConsumer pair backed by BufferHub. static void createBufferHubQueue(sp* outProducer, sp* outConsumer); +#endif BufferQueue() = delete; // Create through createBufferQueue }; diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp index ae5fcbe949..d25ad1a46d 100644 --- a/libs/ui/Android.bp +++ b/libs/ui/Android.bp @@ -85,7 +85,6 @@ cc_library_shared { "libhidlbase", "libhidltransport", "libhwbinder", - "libpdx_default_transport", "libsync", "libutils", "libutilscallstack", @@ -107,6 +106,7 @@ cc_library_shared { "libnativebase_headers", "libhardware_headers", "libui_headers", + "libpdx_headers", ], export_static_lib_headers: [ diff --git a/libs/vr/libbufferhub/Android.bp b/libs/vr/libbufferhub/Android.bp index b38ecc7190..7b5ad44f67 100644 --- a/libs/vr/libbufferhub/Android.bp +++ b/libs/vr/libbufferhub/Android.bp @@ -56,15 +56,6 @@ cc_library { export_header_lib_headers: [ "libnativebase_headers", ], - vendor_available: false, - vndk: { - enabled: true, - }, - target: { - vendor: { - exclude_srcs: ["detached_buffer.cpp"], - }, - }, } cc_test { diff --git a/libs/vr/libbufferhubqueue/Android.bp b/libs/vr/libbufferhubqueue/Android.bp index eeec9ec49c..9f72c05f0c 100644 --- a/libs/vr/libbufferhubqueue/Android.bp +++ b/libs/vr/libbufferhubqueue/Android.bp @@ -59,10 +59,6 @@ cc_library_shared { static_libs: staticLibraries, shared_libs: sharedLibraries, header_libs: headerLibraries, - vendor_available: false, - vndk: { - enabled: true, - }, } subdirs = ["benchmarks", "tests"] diff --git a/libs/vr/libdvr/Android.bp b/libs/vr/libdvr/Android.bp index d0e34eef43..16906f57cd 100644 --- a/libs/vr/libdvr/Android.bp +++ b/libs/vr/libdvr/Android.bp @@ -16,10 +16,7 @@ cc_library_headers { name: "libdvr_headers", export_include_dirs: ["include"], - vendor_available: false, - vndk: { - enabled: true, - }, + vendor_available: true, } cflags = [ diff --git a/libs/vr/libpdx/Android.bp b/libs/vr/libpdx/Android.bp index 5516d21fb7..1a9d7274a1 100644 --- a/libs/vr/libpdx/Android.bp +++ b/libs/vr/libpdx/Android.bp @@ -28,10 +28,6 @@ cc_library_static { "libutils", "liblog", ], - vendor_available: false, - vndk: { - enabled: true, - }, } cc_test { diff --git a/libs/vr/libpdx_default_transport/Android.bp b/libs/vr/libpdx_default_transport/Android.bp index 475eb50f29..74b8c8bd21 100644 --- a/libs/vr/libpdx_default_transport/Android.bp +++ b/libs/vr/libpdx_default_transport/Android.bp @@ -12,10 +12,6 @@ cc_defaults { name: "pdx_default_transport_lib_defaults", export_include_dirs: ["private"], whole_static_libs: ["libpdx"], - vendor_available: false, - vndk: { - enabled: true, - }, } cc_defaults { @@ -37,10 +33,6 @@ cc_library_shared { "pdx_default_transport_lib_defaults", "pdx_use_transport_uds", ], - vendor_available: false, - vndk: { - enabled: true, - }, shared_libs: [ "libbase", "libbinder", diff --git a/libs/vr/libpdx_uds/Android.bp b/libs/vr/libpdx_uds/Android.bp index 79cfdf6324..d64095061e 100644 --- a/libs/vr/libpdx_uds/Android.bp +++ b/libs/vr/libpdx_uds/Android.bp @@ -30,10 +30,6 @@ cc_library_static { whole_static_libs: [ "libselinux", ], - vendor_available: false, - vndk: { - enabled: true, - }, } cc_test { -- cgit v1.2.3-59-g8ed1b