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
This commit is contained in:
Yin-Chia Yeh 2019-04-05 14:15:29 -07:00
parent f2005a3e7a
commit 51ea7c984b
3 changed files with 23 additions and 6 deletions

View file

@ -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);

View file

@ -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());
}

View file

@ -391,6 +391,7 @@ cd4330c3196bda1d642a32abfe23a7d64ebfbda721940643af6867af3b3f0aa9 android.hardwar
f8a19622cb0cc890913b1ef3e32b675ffb26089a09e02fef4056ebad324d2b5d android.hardware.camera.device@3.4::types
291638a1b6d4e63283e9e722ab5049d9351717ffa2b66162124f84d1aa7c2835 android.hardware.camera.metadata@3.2::types
23780340c686ee86986aa5a9755c2d8566224fed177bbb22a5ebf06be574b60c android.hardware.camera.metadata@3.3::types
05d1ee760d81cdd2dc7a70ce0241af9fa830edae33b4be83d9bf5fffe05ddc6f android.hardware.camera.provider@2.4::ICameraProvider
da33234403ff5d60f3473711917b9948e6484a4260b5247acdafb111193a9de2 android.hardware.configstore@1.0::ISurfaceFlingerConfigs
21165b8e30c4b2d52980e4728f661420adc16e38bbe73476c06b2085be908f4c android.hardware.gnss@1.0::IGnssCallback
d702fb01dc2a0733aa820b7eb65435ee3334f75632ef880bafd2fb8803a20a58 android.hardware.gnss@1.0::IGnssMeasurementCallback