From da54091640531ae927d25a56c44c1efc1f247a51 Mon Sep 17 00:00:00 2001 From: Marissa Wall Date: Mon, 25 Nov 2019 14:35:11 -0800 Subject: [PATCH] gralloc: move VtsHalCameraProviderV2_4TargetTest to GraphicBufferAllocator/Mapper libui's GraphicBufferAllocator/Mapper already wrap the different gralloc functions and hide the details from the caller. There is no reason VtsHalCameraProviderV2_4TargetTest needs to directly talk to gralloc. This patch updates VtsHalCameraProviderV2_4TargetTest to use libui. Bug: 145139476 Test: adb shell /system/bin/VtsHalCameraProviderV2_4TargetTest --hal_service_instance=android.hardware.camera.provider@2.4::ICameraProvider/internal/0 Change-Id: I2c2a913f6c5aea2ce7260b68293df404f40e0ddd --- camera/provider/2.4/vts/functional/Android.bp | 7 +- .../VtsHalCameraProviderV2_4TargetTest.cpp | 136 +++--------------- 2 files changed, 23 insertions(+), 120 deletions(-) diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp index 5fe7b197d0..080fa19d24 100644 --- a/camera/provider/2.4/vts/functional/Android.bp +++ b/camera/provider/2.4/vts/functional/Android.bp @@ -25,6 +25,7 @@ cc_test { "libcamera_metadata", "libcutils", "libfmq", + "libgralloctypes", "libgui", "libui", ], @@ -41,13 +42,7 @@ cc_test { "android.hardware.camera.metadata@3.4", "android.hardware.camera.provider@2.4", "android.hardware.camera.provider@2.5", - "android.hardware.graphics.allocator@2.0", - "android.hardware.graphics.allocator@3.0", - "android.hardware.graphics.allocator@4.0", "android.hardware.graphics.common@1.0", - "android.hardware.graphics.mapper@2.0", - "android.hardware.graphics.mapper@3.0", - "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "libgrallocusage", "libhidlmemory", diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index 6505440a26..9416a5430e 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -26,21 +26,21 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -52,14 +52,9 @@ #include #include #include +#include +#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -6311,102 +6306,15 @@ void CameraHidlTest::allocateGraphicBuffer(uint32_t width, uint32_t height, uint PixelFormat format, hidl_handle *buffer_handle /*out*/) { ASSERT_NE(buffer_handle, nullptr); - sp allocator = - android::hardware::graphics::allocator::V2_0::IAllocator::getService(); - sp allocatorV3 = - android::hardware::graphics::allocator::V3_0::IAllocator::getService(); - sp allocatorV4 = - android::hardware::graphics::allocator::V4_0::IAllocator::getService(); + buffer_handle_t buffer; + uint32_t stride; - sp mapperV4 = - android::hardware::graphics::mapper::V4_0::IMapper::getService(); - sp mapperV3 = - android::hardware::graphics::mapper::V3_0::IMapper::getService(); - sp mapper = - android::hardware::graphics::mapper::V2_0::IMapper::getService(); - if (mapperV4 != nullptr && allocatorV4 != nullptr) { - ::android::hardware::hidl_vec descriptor; - android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo descriptorInfo{}; - descriptorInfo.name = "VtsHalCameraProviderV2_4"; - descriptorInfo.width = width; - descriptorInfo.height = height; - descriptorInfo.layerCount = 1; - descriptorInfo.format = - static_cast(format); - descriptorInfo.usage = usage; + android::status_t err = android::GraphicBufferAllocator::get().allocate( + width, height, static_cast(format), 1u /*layerCount*/, usage, &buffer, &stride, + "VtsHalCameraProviderV2_4"); + ASSERT_EQ(err, android::NO_ERROR); - auto ret = mapperV4->createDescriptor( - descriptorInfo, [&descriptor](android::hardware::graphics::mapper::V4_0::Error err, - ::android::hardware::hidl_vec desc) { - ASSERT_EQ(err, android::hardware::graphics::mapper::V4_0::Error::NONE); - descriptor = desc; - }); - ASSERT_TRUE(ret.isOk()); - - ret = allocatorV4->allocate( - descriptor, 1u, - [&](android::hardware::graphics::mapper::V4_0::Error err, uint32_t /*stride*/, - const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& - buffers) { - ASSERT_EQ(android::hardware::graphics::mapper::V4_0::Error::NONE, err); - ASSERT_EQ(buffers.size(), 1u); - *buffer_handle = buffers[0]; - }); - ASSERT_TRUE(ret.isOk()); - } else if (mapperV3 != nullptr && allocatorV3 != nullptr) { - ::android::hardware::hidl_vec descriptor; - android::hardware::graphics::mapper::V3_0::IMapper::BufferDescriptorInfo descriptorInfo {}; - descriptorInfo.width = width; - descriptorInfo.height = height; - descriptorInfo.layerCount = 1; - descriptorInfo.format = - static_cast(format); - descriptorInfo.usage = usage; - - auto ret = mapperV3->createDescriptor( - descriptorInfo, [&descriptor](android::hardware::graphics::mapper::V3_0::Error err, - ::android::hardware::hidl_vec desc) { - ASSERT_EQ(err, android::hardware::graphics::mapper::V3_0::Error::NONE); - descriptor = desc; - }); - ASSERT_TRUE(ret.isOk()); - - ret = allocatorV3->allocate(descriptor, 1u, - [&](android::hardware::graphics::mapper::V3_0::Error err, uint32_t /*stride*/, - const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& buffers) { - ASSERT_EQ(android::hardware::graphics::mapper::V3_0::Error::NONE, err); - ASSERT_EQ(buffers.size(), 1u); - *buffer_handle = buffers[0]; - }); - ASSERT_TRUE(ret.isOk()); - } else { - ::android::hardware::hidl_vec descriptor; - ASSERT_NE(mapper.get(), nullptr); - ASSERT_NE(allocator.get(), nullptr); - android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo descriptorInfo {}; - descriptorInfo.width = width; - descriptorInfo.height = height; - descriptorInfo.layerCount = 1; - descriptorInfo.format = format; - descriptorInfo.usage = usage; - - auto ret = mapper->createDescriptor( - descriptorInfo, [&descriptor](android::hardware::graphics::mapper::V2_0::Error err, - ::android::hardware::hidl_vec desc) { - ASSERT_EQ(err, android::hardware::graphics::mapper::V2_0::Error::NONE); - descriptor = desc; - }); - ASSERT_TRUE(ret.isOk()); - - ret = allocator->allocate(descriptor, 1u, - [&](android::hardware::graphics::mapper::V2_0::Error err, uint32_t /*stride*/, - const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& buffers) { - ASSERT_EQ(android::hardware::graphics::mapper::V2_0::Error::NONE, err); - ASSERT_EQ(buffers.size(), 1u); - *buffer_handle = buffers[0]; - }); - ASSERT_TRUE(ret.isOk()); - } + buffer_handle->setTo(const_cast(buffer), true /*shouldOwn*/); } void CameraHidlTest::verifyRecommendedConfigs(const CameraMetadata& chars) {