diff options
author | Yin-Chia Yeh <yinchiayeh@google.com> | 2019-04-05 14:15:29 -0700 |
---|---|---|
committer | Yin-Chia Yeh <yinchiayeh@google.com> | 2019-04-11 10:35:17 -0700 |
commit | 51ea7c984b7af8bf2dc147f2698dee6972b64615 (patch) | |
tree | af983d5588e6a515da13ef847c624f89b6809903 /camera/provider | |
parent | f2005a3e7a589222a794d0d5fb9893db07f409d5 (diff) | |
download | android_hardware_interfaces-51ea7c984b7af8bf2dc147f2698dee6972b64615.tar.gz android_hardware_interfaces-51ea7c984b7af8bf2dc147f2698dee6972b64615.tar.bz2 android_hardware_interfaces-51ea7c984b7af8bf2dc147f2698dee6972b64615.zip |
Camera: require torch API support for Android Q
Torch API was mandated on legacy libhardware camera module 2.4.
We kept the option of not supporting this API because the first
HIDL legacy wrapper needs to also support libhardware camera
module 1.0 + HAL1.0. Now that HAL 1.0 is no longer supported,
we can reenforce the torch API being supported by camera HAL as
this is critical to power usage of flashlight usecase.
Test: adb shell VtsHalCameraProviderV2_4TargetTest
--hal_service_instance=android.hardware.camera.provider@2.4::ICameraProvider/legacy/0
Bug: 113336515
Change-Id: I0dcf2e7a5cddadcd097caf6913625d8a607065f8
Diffstat (limited to 'camera/provider')
-rw-r--r-- | camera/provider/2.4/ICameraProvider.hal | 3 | ||||
-rw-r--r-- | camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp | 25 |
2 files changed, 22 insertions, 6 deletions
diff --git a/camera/provider/2.4/ICameraProvider.hal b/camera/provider/2.4/ICameraProvider.hal index 8773bc081..74c3ff169 100644 --- a/camera/provider/2.4/ICameraProvider.hal +++ b/camera/provider/2.4/ICameraProvider.hal @@ -140,7 +140,8 @@ interface ICameraProvider { * Torch API support cannot be queried. This may be due to * a failure to initialize the camera subsystem, for example. * @return support Whether the camera devices known to this provider - * supports setTorchMode API or not. + * supports setTorchMode API or not. Devices launched with SDK + * level 29 or higher must return true. * */ isSetTorchModeSupported() generates (Status status, bool support); diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index 5dfc783ef..797a19859 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -272,6 +272,16 @@ namespace { ALOGW("Unexpected HAL status code %d", s); return Status::OPERATION_NOT_SUPPORTED; } + + void getFirstApiLevel(/*out*/int32_t* outApiLevel) { + int32_t firstApiLevel = property_get_int32("ro.product.first_api_level", /*default*/-1); + if (firstApiLevel < 0) { + firstApiLevel = property_get_int32("ro.build.version.sdk", /*default*/-1); + } + ASSERT_GT(firstApiLevel, 0); // first_api_level must exist + *outApiLevel = firstApiLevel; + return; + } } // Test environment for camera @@ -1483,11 +1493,8 @@ hidl_vec<hidl_string> CameraHidlTest::getCameraDeviceNames(sp<ICameraProvider> p // Test devices with first_api_level >= P does not advertise device@1.0 TEST_F(CameraHidlTest, noHal1AfterP) { constexpr int32_t HAL1_PHASE_OUT_API_LEVEL = 28; - int32_t firstApiLevel = property_get_int32("ro.product.first_api_level", /*default*/-1); - if (firstApiLevel < 0) { - firstApiLevel = property_get_int32("ro.build.version.sdk", /*default*/-1); - } - ASSERT_GT(firstApiLevel, 0); // first_api_level must exist + int32_t firstApiLevel = 0; + getFirstApiLevel(&firstApiLevel); // all devices with first API level == 28 and <= 1GB of RAM must set low_ram // and thus be allowed to continue using HAL1 @@ -1508,11 +1515,19 @@ TEST_F(CameraHidlTest, noHal1AfterP) { } // Test if ICameraProvider::isTorchModeSupported returns Status::OK +// Also if first_api_level >= Q torch API must be supported. TEST_F(CameraHidlTest, isTorchModeSupported) { + constexpr int32_t API_LEVEL_Q = 29; + int32_t firstApiLevel = 0; + getFirstApiLevel(&firstApiLevel); + Return<void> ret; ret = mProvider->isSetTorchModeSupported([&](auto status, bool support) { ALOGI("isSetTorchModeSupported returns status:%d supported:%d", (int)status, support); ASSERT_EQ(Status::OK, status); + if (firstApiLevel >= API_LEVEL_Q) { + ASSERT_EQ(true, support); + } }); ASSERT_TRUE(ret.isOk()); } |