From 0d72ef929fbc1b6e04aaa39b3df535b01a2b4f9f Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Thu, 8 Mar 2018 15:41:11 -0800 Subject: [PATCH] Camera: external camera VTS fixes Test: VTS pass for external camera Bug: 72261912 Change-Id: I4f1da37081d0b8c1519ecc0ecc0cc6c3850ee2bb --- .../2.4/default/ExternalCameraProvider.cpp | 3 + .../VtsHalCameraProviderV2_4TargetTest.cpp | 61 ++++++++++++++++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/camera/provider/2.4/default/ExternalCameraProvider.cpp b/camera/provider/2.4/default/ExternalCameraProvider.cpp index faa4e3a0a9..285e96bc71 100644 --- a/camera/provider/2.4/default/ExternalCameraProvider.cpp +++ b/camera/provider/2.4/default/ExternalCameraProvider.cpp @@ -75,6 +75,9 @@ Return ExternalCameraProvider::setCallback( Mutex::Autolock _l(mLock); mCallbacks = callback; } + if (mCallbacks == nullptr) { + return Status::OK; + } // Send a callback for all devices to initialize { for (const auto& pair : mCameraStatusMap) { diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index abd875aeb1..5feec87a51 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -16,6 +16,7 @@ #define LOG_TAG "camera_hidl_hal_test" +#include #include #include #include @@ -65,6 +66,7 @@ using ::android::BufferQueue; using ::android::BufferItemConsumer; using ::android::Surface; using ::android::hardware::graphics::common::V1_0::BufferUsage; +using ::android::hardware::graphics::common::V1_0::Dataspace; using ::android::hardware::graphics::common::V1_0::PixelFormat; using ::android::hardware::camera::common::V1_0::Status; using ::android::hardware::camera::common::V1_0::CameraDeviceStatus; @@ -1084,7 +1086,7 @@ Return CameraHidlTest::DeviceCb::notify( } hidl_vec CameraHidlTest::getCameraDeviceNames(sp provider) { - hidl_vec cameraDeviceNames; + std::vector cameraDeviceNames; Return ret; ret = provider->getCameraIdList( [&](auto status, const auto& idList) { @@ -1093,12 +1095,50 @@ hidl_vec CameraHidlTest::getCameraDeviceNames(sp p ALOGI("Camera Id[%zu] is %s", i, idList[i].c_str()); } ASSERT_EQ(Status::OK, status); - cameraDeviceNames = idList; + for (const auto& id : idList) { + cameraDeviceNames.push_back(id); + } }); if (!ret.isOk()) { ADD_FAILURE(); } - return cameraDeviceNames; + + // External camera devices are reported through cameraDeviceStatusChange + struct ProviderCb : public ICameraProviderCallback { + virtual Return cameraDeviceStatusChange( + const hidl_string& devName, + CameraDeviceStatus newStatus) override { + ALOGI("camera device status callback name %s, status %d", + devName.c_str(), (int) newStatus); + if (newStatus == CameraDeviceStatus::PRESENT) { + externalCameraDeviceNames.push_back(devName); + + } + return Void(); + } + + virtual Return torchModeStatusChange( + const hidl_string&, TorchModeStatus) override { + return Void(); + } + + std::vector externalCameraDeviceNames; + }; + sp cb = new ProviderCb; + auto status = mProvider->setCallback(cb); + + for (const auto& devName : cb->externalCameraDeviceNames) { + if (cameraDeviceNames.end() == std::find( + cameraDeviceNames.begin(), cameraDeviceNames.end(), devName)) { + cameraDeviceNames.push_back(devName); + } + } + + hidl_vec retList(cameraDeviceNames.size()); + for (size_t i = 0; i < cameraDeviceNames.size(); i++) { + retList[i] = cameraDeviceNames[i]; + } + return retList; } // Test devices with first_api_level >= P does not advertise device@1.0 @@ -2010,7 +2050,8 @@ TEST_F(CameraHidlTest, getCameraCharacteristics) { ASSERT_TRUE( hardwareLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED || hardwareLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL || - hardwareLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3); + hardwareLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3 || + hardwareLevel == ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL); } else { ADD_FAILURE() << "Get camera hardware level failed!"; } @@ -2440,13 +2481,14 @@ TEST_F(CameraHidlTest, configureStreamsAvailableOutputs) { int32_t streamId = 0; for (auto& it : outputStreams) { V3_2::Stream stream3_2; + bool isJpeg = static_cast(it.format) == PixelFormat::BLOB; stream3_2 = {streamId, StreamType::OUTPUT, static_cast(it.width), static_cast(it.height), static_cast(it.format), GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, - 0, + (isJpeg) ? static_cast(Dataspace::V0_JFIF) : 0, StreamRotation::ROTATION_0}; ::android::hardware::hidl_vec streams3_2 = {stream3_2}; ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4; @@ -2897,7 +2939,7 @@ TEST_F(CameraHidlTest, configureStreamsPreviewStillOutputs) { static_cast(blobIter.height), static_cast(blobIter.format), GRALLOC1_CONSUMER_USAGE_CPU_READ, - 0, + static_cast(Dataspace::V0_JFIF), StreamRotation::ROTATION_0}; ::android::hardware::hidl_vec streams = {previewStream, blobStream}; @@ -3162,7 +3204,7 @@ TEST_F(CameraHidlTest, configureStreamsVideoStillOutputs) { static_cast(blobIter.height), static_cast(blobIter.format), GRALLOC1_CONSUMER_USAGE_CPU_READ, - 0, + static_cast(Dataspace::V0_JFIF), StreamRotation::ROTATION_0}; ::android::hardware::hidl_vec streams = {videoStream, blobStream}; ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4; @@ -3603,8 +3645,9 @@ TEST_F(CameraHidlTest, processCaptureRequestBurstISO) { camera_metadata_entry_t hwLevel = staticMeta.find(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL); ASSERT_TRUE(0 < hwLevel.count); - if (ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED == hwLevel.data.u8[0]) { - //Limited devices can skip this test + if (ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED == hwLevel.data.u8[0] || + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL == hwLevel.data.u8[0]) { + //Limited/External devices can skip this test ret = session->close(); ASSERT_TRUE(ret.isOk()); continue;