Camera: Vts test for manual flash control.

Test to verify configurations for manual flash strength level
control feature.

Test: Tested on an emulator with flag enabled/disabled.

Bug: 238348881

Change-Id: Iba492fe626c2fb74aa2107cec3969a04ea52eac0
This commit is contained in:
Rucha Katakwar
2023-10-13 15:47:58 -07:00
parent 66082e3cec
commit d08a015239
4 changed files with 82 additions and 0 deletions

View File

@@ -53,6 +53,7 @@ cc_test {
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"camera_platform_flags_c_lib",
],
// Statically link to libs not guaranteed to be present on the device.
@@ -67,6 +68,7 @@ cc_test {
"libhidlmemory",
"libgralloctypes",
"libaidlcommonsupport",
"libgtest",
],
require_root: true,

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <gtest/gtest.h>
#include <aidl/Vintf.h>
#include <aidl/android/hardware/camera/common/VendorTagSection.h>
@@ -29,6 +30,7 @@
#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>
#include <torch_provider_cb.h>
#include <com_android_internal_camera_flags.h>
#include <list>
using ::aidl::android::hardware::camera::common::CameraDeviceStatus;
@@ -50,6 +52,7 @@ const uint32_t kMaxStillWidth = 2048;
const uint32_t kMaxStillHeight = 1536;
const int64_t kEmptyFlushTimeoutMSec = 200;
namespace flags = com::android::internal::camera::flags;
const static std::vector<int64_t> kMandatoryUseCases = {
ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
@@ -159,6 +162,28 @@ TEST_P(CameraAidlTest, getResourceCost) {
}
}
// Validate the integrity of manual flash strength control metadata
TEST_P(CameraAidlTest, validateManualFlashStrengthControlKeys) {
if (flags::camera_manual_flash_strength_control()) {
std::vector<std::string> cameraDeviceNames = getCameraDeviceNames(mProvider);
for (const auto& name : cameraDeviceNames) {
ALOGI("validateManualFlashStrengthControlKeys: Testing camera device %s", name.c_str());
CameraMetadata meta;
std::shared_ptr<ICameraDevice> cameraDevice;
openEmptyDeviceSession(name, mProvider, &mSession /*out*/, &meta /*out*/,
&cameraDevice /*out*/);
ndk::ScopedAStatus ret = cameraDevice->getCameraCharacteristics(&meta);
ASSERT_TRUE(ret.isOk());
const camera_metadata_t* staticMeta =
reinterpret_cast<const camera_metadata_t*>(meta.metadata.data());
verifyManualFlashStrengthControlCharacteristics(staticMeta);
}
} else {
ALOGI("validateManualFlashStrengthControlKeys: Test skipped.\n");
GTEST_SKIP();
}
}
TEST_P(CameraAidlTest, systemCameraTest) {
std::vector<std::string> cameraDeviceNames = getCameraDeviceNames(mProvider);
std::map<std::string, std::vector<SystemCameraKind>> hiddenPhysicalIdToLogicalMap;

View File

@@ -1152,6 +1152,58 @@ void CameraAidlTest::verifyMonochromeCharacteristics(const CameraMetadata& chars
}
}
void CameraAidlTest::verifyManualFlashStrengthControlCharacteristics(
const camera_metadata_t* staticMeta) {
camera_metadata_ro_entry singleMaxEntry;
camera_metadata_ro_entry singleDefEntry;
camera_metadata_ro_entry torchMaxEntry;
camera_metadata_ro_entry torchDefEntry;
bool torch_supported = false;
int32_t singleMaxLevel = 0;
int32_t singleDefLevel = 0;
int32_t torchMaxLevel = 0;
int32_t torchDefLevel = 0;
// determine whether the device supports torch or not
torch_supported = isTorchSupported(staticMeta);
int singleMaxRetCode = find_camera_metadata_ro_entry(staticMeta,
ANDROID_FLASH_SINGLE_STRENGTH_MAX_LEVEL, &singleMaxEntry);
int singleDefRetCode = find_camera_metadata_ro_entry(staticMeta,
ANDROID_FLASH_SINGLE_STRENGTH_DEFAULT_LEVEL, &singleDefEntry);
int torchMaxRetCode = find_camera_metadata_ro_entry(staticMeta,
ANDROID_FLASH_TORCH_STRENGTH_MAX_LEVEL, &torchMaxEntry);
int torchDefRetCode = find_camera_metadata_ro_entry(staticMeta,
ANDROID_FLASH_TORCH_STRENGTH_DEFAULT_LEVEL, &torchDefEntry);
if (torch_supported) {
if(singleMaxRetCode == 0 && singleDefRetCode == 0 && torchMaxRetCode == 0 &&
torchDefRetCode == 0) {
singleMaxLevel = *singleMaxEntry.data.i32;
singleDefLevel = *singleDefEntry.data.i32;
torchMaxLevel = *torchMaxEntry.data.i32;
torchDefLevel = *torchDefEntry.data.i32;
ASSERT_TRUE((singleMaxEntry.count == singleDefEntry.count == torchMaxEntry.count
== torchDefEntry.count == 1));
} else {
ASSERT_TRUE((singleMaxEntry.count == singleDefEntry.count == torchMaxEntry.count
== torchDefEntry.count == 0));
}
// if the device supports this feature default levels should be greater than 0
if (singleMaxLevel > 1) {
ASSERT_GT(torchMaxLevel, 1);
ASSERT_GT(torchDefLevel, 0);
ASSERT_GT(singleDefLevel, 0);
ASSERT_TRUE(torchDefLevel <= torchMaxLevel); // default levels should be <= max levels
ASSERT_TRUE(singleDefLevel <= singleMaxLevel);
}
} else {
ASSERT_TRUE(singleMaxRetCode != 0);
ASSERT_TRUE(singleDefRetCode != 0);
ASSERT_TRUE(torchMaxRetCode != 0);
ASSERT_TRUE(torchDefRetCode != 0);
}
}
void CameraAidlTest::verifyRecommendedConfigs(const CameraMetadata& chars) {
size_t CONFIG_ENTRY_SIZE = 5;
size_t CONFIG_ENTRY_TYPE_OFFSET = 3;

View File

@@ -262,6 +262,9 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> {
static void verifyMonochromeCharacteristics(const CameraMetadata& chars);
static void verifyManualFlashStrengthControlCharacteristics(
const camera_metadata_t* staticMeta);
static void verifyMonochromeCameraResult(
const ::android::hardware::camera::common::V1_0::helper::CameraMetadata& metadata);