Merge "Camera: require torch API support for Android Q" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-04-11 22:04:52 +00:00
committed by Android (Google) Code Review
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
@@ -1484,11 +1494,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
@@ -1509,11 +1516,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