diff --git a/Android.bp b/Android.bp
index 302e250a792b8f73005fd1806a507acd407d116d..7a2bb9b73ac57becf0c8c422b2414035eb8369a0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -52,8 +52,8 @@ aidl_interface {
"aidl/android/media/VolumeShaperOperationFlag.aidl",
"aidl/android/media/VolumeShaperState.aidl",
],
- imports: [
- "android.media.audio.common.types-V2",
+ defaults: [
+ "latest_android_media_audio_common_types_import_interface",
],
backend: {
cpp: {
@@ -113,8 +113,8 @@ aidl_interface {
srcs: [
"aidl/android/media/audio/IHalAdapterVendorExtension.aidl",
],
- imports: [
- "android.hardware.audio.core-V1",
+ defaults: [
+ "latest_android_hardware_audio_core_import_interface",
],
backend: {
// The C++ backend is disabled transitively due to use of FMQ by the audio core HAL.
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index 62cf8271f8fb50beb66d040cb83385af7864a227..1cf63b08b8cb031b6cc9d9ffe1c8c424b1e604f9 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -9,7 +9,8 @@ clang_format = true
[Builtin Hooks Options]
# Only turn on clang-format check for the following subfolders.
clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
- media/libmediatranscoding/
- services/mediatranscoding/
media/libaudioclient/tests/
media/libaudiohal/tests/
+ media/libmediatranscoding/
+ services/camera/virtualcamera/
+ services/mediatranscoding/
diff --git a/camera/Android.bp b/camera/Android.bp
index a3fd7f9082bd72b3d4b311713a663aa9eced0701..22f1633dc589e5fd2b0fcb82808640dce501e9f5 100644
--- a/camera/Android.bp
+++ b/camera/Android.bp
@@ -43,6 +43,23 @@ license {
],
}
+aconfig_declarations {
+ name: "camera_platform_flags",
+ package: "com.android.internal.camera.flags",
+ srcs: ["camera_platform.aconfig"],
+}
+
+cc_aconfig_library {
+ name: "camera_platform_flags_c_lib",
+ aconfig_declarations: "camera_platform_flags",
+ host_supported: true,
+}
+
+java_aconfig_library {
+ name: "camera_platform_flags_java_lib",
+ aconfig_declarations: "camera_platform_flags",
+}
+
cc_library_headers {
name: "camera_headers",
export_include_dirs: ["include"],
@@ -85,6 +102,7 @@ cc_library {
],
shared_libs: [
+ "camera_platform_flags_c_lib",
"libbase",
"libcutils",
"libutils",
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index 224468274b507b57c6f204b9bd471b0b049fd3d7..6b040abe2626b8d7c13e4cc1e181ad54283b9911 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -19,7 +19,6 @@
#define LOG_TAG "Camera"
#include
#include
-#include
#include
#include
#include
@@ -70,7 +69,7 @@ Camera::~Camera()
// deadlock if we call any method of ICamera here.
}
-sp Camera::connect(int cameraId, const String16& clientPackageName,
+sp Camera::connect(int cameraId, const std::string& clientPackageName,
int clientUid, int clientPid, int targetSdkVersion, bool overrideToPortrait,
bool forceSlowJpegMode)
{
@@ -246,7 +245,7 @@ String8 Camera::getParameters() const
ALOGV("getParameters");
String8 params;
sp <::android::hardware::ICamera> c = mCamera;
- if (c != 0) params = mCamera->getParameters();
+ if (c != 0) params = c->getParameters();
return params;
}
@@ -270,7 +269,7 @@ void Camera::setPreviewCallbackFlags(int flag)
ALOGV("setPreviewCallbackFlags");
sp <::android::hardware::ICamera> c = mCamera;
if (c == 0) return;
- mCamera->setPreviewCallbackFlag(flag);
+ c->setPreviewCallbackFlag(flag);
}
status_t Camera::setPreviewCallbackTarget(
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 9ae4607d3fc629e6dc3b599cf5804429c4f7c6e8..6759f3bc68a38866a45aa4898aae50d10603b138 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -31,6 +31,7 @@
#include
#include
+#include
// needed to instantiate
#include
@@ -58,7 +59,7 @@ status_t CameraInfo::readFromParcel(const android::Parcel* parcel) {
}
status_t CameraStatus::writeToParcel(android::Parcel* parcel) const {
- auto res = parcel->writeString16(String16(cameraId));
+ auto res = parcel->writeString16(toString16(cameraId));
if (res != OK) return res;
res = parcel->writeInt32(status);
@@ -66,12 +67,12 @@ status_t CameraStatus::writeToParcel(android::Parcel* parcel) const {
std::vector unavailablePhysicalIds16;
for (auto& id8 : unavailablePhysicalIds) {
- unavailablePhysicalIds16.push_back(String16(id8));
+ unavailablePhysicalIds16.push_back(toString16(id8));
}
res = parcel->writeString16Vector(unavailablePhysicalIds16);
if (res != OK) return res;
- res = parcel->writeString16(String16(clientPackage));
+ res = parcel->writeString16(toString16(clientPackage));
return res;
}
@@ -79,7 +80,7 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) {
String16 tempCameraId;
auto res = parcel->readString16(&tempCameraId);
if (res != OK) return res;
- cameraId = String8(tempCameraId);
+ cameraId = toString8(tempCameraId);
res = parcel->readInt32(&status);
if (res != OK) return res;
@@ -88,13 +89,13 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) {
res = parcel->readString16Vector(&unavailablePhysicalIds16);
if (res != OK) return res;
for (auto& id16 : unavailablePhysicalIds16) {
- unavailablePhysicalIds.push_back(String8(id16));
+ unavailablePhysicalIds.push_back(toStdString(id16));
}
String16 tempClientPackage;
res = parcel->readString16(&tempClientPackage);
if (res != OK) return res;
- clientPackage = String8(tempClientPackage);
+ clientPackage = toStdString(tempClientPackage);
return res;
}
@@ -103,7 +104,6 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) {
namespace {
sp<::android::hardware::ICameraService> gCameraService;
- const int kCameraServicePollDelay = 500000; // 0.5s
const char* kCameraServiceName = "media.camera";
Mutex gLock;
@@ -141,14 +141,10 @@ const sp<::android::hardware::ICameraService> CameraBase::getC
sp sm = defaultServiceManager();
sp binder;
- do {
- binder = sm->getService(String16(kCameraServiceName));
- if (binder != 0) {
- break;
- }
- ALOGW("CameraService not published, waiting...");
- usleep(kCameraServicePollDelay);
- } while(true);
+ binder = sm->waitForService(toString16(kCameraServiceName));
+ if (binder == nullptr) {
+ return nullptr;
+ }
if (gDeathNotifier == NULL) {
gDeathNotifier = new DeathNotifier();
}
@@ -161,7 +157,7 @@ const sp<::android::hardware::ICameraService> CameraBase::getC
template
sp CameraBase::connect(int cameraId,
- const String16& clientPackageName,
+ const std::string& clientPackageName,
int clientUid, int clientPid, int targetSdkVersion,
bool overrideToPortrait, bool forceSlowJpegMode)
{
@@ -184,7 +180,7 @@ sp CameraBase::connect(int cameraId,
c->mStatus = NO_ERROR;
} else {
ALOGW("An error occurred while connecting to camera %d: %s", cameraId,
- (cs == nullptr) ? "Service not available" : ret.toString8().string());
+ (cs == nullptr) ? "Service not available" : ret.toString8().c_str());
c.clear();
}
return c;
@@ -269,7 +265,7 @@ int CameraBase::getNumberOfCameras() {
&count);
if (!res.isOk()) {
ALOGE("Error reading number of cameras: %s",
- res.toString8().string());
+ res.toString8().c_str());
count = 0;
}
return count;
diff --git a/camera/CameraMetadata.cpp b/camera/CameraMetadata.cpp
index a4ae71be2c6bb7fe008e5e08beb970d2602f4633..2e808d1272ac4d857dbb7a16dfbebcb2bdf8d2af 100644
--- a/camera/CameraMetadata.cpp
+++ b/camera/CameraMetadata.cpp
@@ -289,7 +289,7 @@ status_t CameraMetadata::update(uint32_t tag,
return res;
}
// string.size() doesn't count the null termination character.
- return updateImpl(tag, (const void*)string.string(), string.size() + 1);
+ return updateImpl(tag, (const void*)string.c_str(), string.size() + 1);
}
status_t CameraMetadata::update(const camera_metadata_ro_entry &entry) {
@@ -809,7 +809,7 @@ status_t CameraMetadata::getTagFromName(const char *name,
for (size_t i = 0; i < totalSectionCount; ++i) {
const char *str = (i < ANDROID_SECTION_COUNT) ? camera_metadata_section_names[i] :
- (*vendorSections)[i - ANDROID_SECTION_COUNT].string();
+ (*vendorSections)[i - ANDROID_SECTION_COUNT].c_str();
ALOGV("%s: Trying to match against section '%s'", __FUNCTION__, str);
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index e95c91cb9848a26bfc4e6211ade278d98ce82811..272b113f230e506efe2b6c0b52079bbea3f348b9 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -205,7 +205,7 @@ String8 CameraParameters::flatten() const
void CameraParameters::unflatten(const String8 ¶ms)
{
- const char *a = params.string();
+ const char *a = params.c_str();
const char *b;
mMap.clear();
@@ -271,7 +271,7 @@ const char *CameraParameters::get(const char *key) const
String8 v = mMap.valueFor(String8(key));
if (v.length() == 0)
return 0;
- return v.string();
+ return v.c_str();
}
int CameraParameters::getInt(const char *key) const
@@ -463,7 +463,7 @@ void CameraParameters::dump() const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
- ALOGD("%s: %s\n", k.string(), v.string());
+ ALOGD("%s: %s\n", k.c_str(), v.c_str());
}
}
@@ -478,10 +478,10 @@ status_t CameraParameters::dump(int fd, const Vector& /*args*/) const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
- snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
+ snprintf(buffer, 255, "\t%s: %s\n", k.c_str(), v.c_str());
result.append(buffer);
}
- write(fd, result.string(), result.size());
+ write(fd, result.c_str(), result.size());
return NO_ERROR;
}
diff --git a/camera/CameraParameters2.cpp b/camera/CameraParameters2.cpp
index a1cf3553f4d9eff78b8c70b3f83f562db27b3da1..1ccad08a276c29d6aa1b16143994d60acd2bcc14 100644
--- a/camera/CameraParameters2.cpp
+++ b/camera/CameraParameters2.cpp
@@ -52,14 +52,14 @@ String8 CameraParameters2::flatten() const
flattened += ";";
}
- ALOGV("%s: Flattened params = %s", __FUNCTION__, flattened.string());
+ ALOGV("%s: Flattened params = %s", __FUNCTION__, flattened.c_str());
return flattened;
}
void CameraParameters2::unflatten(const String8 ¶ms)
{
- const char *a = params.string();
+ const char *a = params.c_str();
const char *b;
mMap.clear();
@@ -128,7 +128,7 @@ const char *CameraParameters2::get(const char *key) const
if (idx < 0) {
return NULL;
} else {
- return mMap.valueAt(idx).string();
+ return mMap.valueAt(idx).c_str();
}
}
@@ -305,7 +305,7 @@ void CameraParameters2::getPreviewFpsRange(int *min_fps, int *max_fps) const
void CameraParameters2::setPreviewFpsRange(int min_fps, int max_fps)
{
String8 str = String8::format("%d,%d", min_fps, max_fps);
- set(CameraParameters::KEY_PREVIEW_FPS_RANGE, str.string());
+ set(CameraParameters::KEY_PREVIEW_FPS_RANGE, str.c_str());
}
void CameraParameters2::setPreviewFormat(const char *format)
@@ -357,7 +357,7 @@ void CameraParameters2::dump() const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
- ALOGD("%s: %s\n", k.string(), v.string());
+ ALOGD("%s: %s\n", k.c_str(), v.c_str());
}
}
@@ -373,10 +373,10 @@ status_t CameraParameters2::dump(int fd, const Vector& args) const
String8 k, v;
k = mMap.keyAt(i);
v = mMap.valueAt(i);
- snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
+ snprintf(buffer, 255, "\t%s: %s\n", k.c_str(), v.c_str());
result.append(buffer);
}
- write(fd, result.string(), result.size());
+ write(fd, result.c_str(), result.size());
return NO_ERROR;
}
diff --git a/camera/CameraSessionStats.cpp b/camera/CameraSessionStats.cpp
index 9e9793ddc2a7a8b8a97f7091d97aa75ee95f8db3..057ec993bdfccd84a026e669963b68f9136f977c 100644
--- a/camera/CameraSessionStats.cpp
+++ b/camera/CameraSessionStats.cpp
@@ -16,10 +16,12 @@
// #define LOG_NDEBUG 0
#define LOG_TAG "CameraSessionStats"
+
#include
#include
#include
+#include
#include
@@ -282,8 +284,8 @@ CameraSessionStats::CameraSessionStats() :
mSessionIndex(0),
mCameraExtensionSessionStats() {}
-CameraSessionStats::CameraSessionStats(const String16& cameraId,
- int facing, int newCameraState, const String16& clientName,
+CameraSessionStats::CameraSessionStats(const std::string& cameraId,
+ int facing, int newCameraState, const std::string& clientName,
int apiLevel, bool isNdk, int32_t latencyMs, int64_t logId) :
mCameraId(cameraId),
mFacing(facing),
@@ -413,6 +415,18 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
return err;
}
+ bool usedUltraWide = false;
+ if ((err = parcel->readBool(&usedUltraWide)) != OK) {
+ ALOGE("%s: Failed to read ultrawide usage from parcel", __FUNCTION__);
+ return err;
+ }
+
+ bool usedZoomOverride = false;
+ if ((err = parcel->readBool(&usedZoomOverride)) != OK) {
+ ALOGE("%s: Failed to read zoom override usage from parcel", __FUNCTION__);
+ return err;
+ }
+
int32_t sessionIdx;
if ((err = parcel->readInt32(&sessionIdx)) != OK) {
ALOGE("%s: Failed to read session index from parcel", __FUNCTION__);
@@ -425,10 +439,10 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
return err;
}
- mCameraId = id;
+ mCameraId = toStdString(id);
mFacing = facing;
mNewCameraState = newCameraState;
- mClientName = clientName;
+ mClientName = toStdString(clientName);
mApiLevel = apiLevel;
mIsNdk = isNdk;
mLatencyMs = latencyMs;
@@ -440,8 +454,10 @@ status_t CameraSessionStats::readFromParcel(const android::Parcel* parcel) {
mResultErrorCount = resultErrorCount;
mDeviceError = deviceError;
mStreamStats = std::move(streamStats);
- mUserTag = userTag;
+ mUserTag = toStdString(userTag);
mVideoStabilizationMode = videoStabilizationMode;
+ mUsedUltraWide = usedUltraWide;
+ mUsedZoomOverride = usedZoomOverride;
mSessionIndex = sessionIdx;
mCameraExtensionSessionStats = extStats;
@@ -456,7 +472,7 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
status_t err = OK;
- if ((err = parcel->writeString16(mCameraId)) != OK) {
+ if ((err = parcel->writeString16(toString16(mCameraId))) != OK) {
ALOGE("%s: Failed to write camera id!", __FUNCTION__);
return err;
}
@@ -471,7 +487,7 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
return err;
}
- if ((err = parcel->writeString16(mClientName)) != OK) {
+ if ((err = parcel->writeString16(toString16(mClientName))) != OK) {
ALOGE("%s: Failed to write client name!", __FUNCTION__);
return err;
}
@@ -531,7 +547,7 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
return err;
}
- if ((err = parcel->writeString16(mUserTag)) != OK) {
+ if ((err = parcel->writeString16(toString16(mUserTag))) != OK) {
ALOGE("%s: Failed to write user tag!", __FUNCTION__);
return err;
}
@@ -541,6 +557,16 @@ status_t CameraSessionStats::writeToParcel(android::Parcel* parcel) const {
return err;
}
+ if ((err = parcel->writeBool(mUsedUltraWide)) != OK) {
+ ALOGE("%s: Failed to write ultrawide usage!", __FUNCTION__);
+ return err;
+ }
+
+ if ((err = parcel->writeBool(mUsedZoomOverride)) != OK) {
+ ALOGE("%s: Failed to write zoom override usage!", __FUNCTION__);
+ return err;
+ }
+
if ((err = parcel->writeInt32(mSessionIndex)) != OK) {
ALOGE("%s: Failed to write session index!", __FUNCTION__);
return err;
diff --git a/camera/CaptureResult.cpp b/camera/CaptureResult.cpp
index bb880d12291210ee6bb87c05d1435f55239a3531..9ff257872f0559ba734c5b55a0e99b1911db2139 100644
--- a/camera/CaptureResult.cpp
+++ b/camera/CaptureResult.cpp
@@ -18,6 +18,7 @@
#include
#include
+#include
#include
namespace android {
@@ -47,7 +48,7 @@ status_t CaptureResultExtras::readFromParcel(const android::Parcel *parcel) {
ALOGE("%s: Failed to read camera id: %d", __FUNCTION__, res);
return res;
}
- errorPhysicalCameraId = cameraId;
+ errorPhysicalCameraId = toStdString(cameraId);
}
parcel->readInt64(&lastCompletedRegularFrameNumber);
parcel->readInt64(&lastCompletedReprocessFrameNumber);
@@ -75,7 +76,7 @@ status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const {
if (errorPhysicalCameraId.size() > 0) {
parcel->writeBool(true);
status_t res = OK;
- if ((res = parcel->writeString16(errorPhysicalCameraId)) != OK) {
+ if ((res = parcel->writeString16(toString16(errorPhysicalCameraId))) != OK) {
ALOGE("%s: Failed to write physical camera ID to parcel: %d", __FUNCTION__, res);
return res;
}
@@ -96,13 +97,15 @@ status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const {
status_t PhysicalCaptureResultInfo::readFromParcel(const android::Parcel* parcel) {
status_t res;
- mPhysicalCameraId.setTo(u"");
+ mPhysicalCameraId = "";
mPhysicalCameraMetadata.clear();
- if ((res = parcel->readString16(&mPhysicalCameraId)) != OK) {
+ String16 physicalCameraId;
+ if ((res = parcel->readString16(&physicalCameraId)) != OK) {
ALOGE("%s: Failed to read camera id: %d", __FUNCTION__, res);
return res;
}
+ mPhysicalCameraId = toStdString(physicalCameraId);
if ((res = mPhysicalCameraMetadata.readFromParcel(parcel)) != OK) {
ALOGE("%s: Failed to read metadata from parcel: %d", __FUNCTION__, res);
@@ -113,7 +116,7 @@ status_t PhysicalCaptureResultInfo::readFromParcel(const android::Parcel* parcel
status_t PhysicalCaptureResultInfo::writeToParcel(android::Parcel* parcel) const {
status_t res;
- if ((res = parcel->writeString16(mPhysicalCameraId)) != OK) {
+ if ((res = parcel->writeString16(toString16(mPhysicalCameraId))) != OK) {
ALOGE("%s: Failed to write physical camera ID to parcel: %d",
__FUNCTION__, res);
return res;
@@ -187,7 +190,8 @@ status_t CaptureResult::readFromParcel(android::Parcel *parcel) {
return res;
}
- mPhysicalMetadatas.emplace(mPhysicalMetadatas.end(), cameraId, physicalMetadata);
+ mPhysicalMetadatas.emplace(mPhysicalMetadatas.end(), toStdString(cameraId),
+ physicalMetadata);
}
ALOGV("%s: Read physical metadata from parcel", __FUNCTION__);
@@ -228,7 +232,7 @@ status_t CaptureResult::writeToParcel(android::Parcel *parcel) const {
return BAD_VALUE;
}
for (const auto& physicalMetadata : mPhysicalMetadatas) {
- if ((res = parcel->writeString16(physicalMetadata.mPhysicalCameraId)) != OK) {
+ if ((res = parcel->writeString16(toString16(physicalMetadata.mPhysicalCameraId))) != OK) {
ALOGE("%s: Failed to write physical camera ID to parcel: %d",
__FUNCTION__, res);
return res;
diff --git a/camera/VendorTagDescriptor.cpp b/camera/VendorTagDescriptor.cpp
index 151b65386266c61e9a2d6ba972ed06ee16ab4b11..fb26f838b9ea509ac9a38da7eda51c07d0c4d156 100644
--- a/camera/VendorTagDescriptor.cpp
+++ b/camera/VendorTagDescriptor.cpp
@@ -152,7 +152,7 @@ status_t VendorTagDescriptor::readFromParcel(const android::Parcel* parcel) {
break;
}
String8 tagName = parcel->readString8();
- if (tagName.isEmpty()) {
+ if (tagName.empty()) {
ALOGE("%s: parcel tag name was NULL for tag %d.", __FUNCTION__, tag);
res = NOT_ENOUGH_DATA;
break;
@@ -190,7 +190,7 @@ status_t VendorTagDescriptor::readFromParcel(const android::Parcel* parcel) {
"Vector capacity must be positive");
for (size_t i = 0; i < sectionCount; ++i) {
String8 sectionName = parcel->readString8();
- if (sectionName.isEmpty()) {
+ if (sectionName.empty()) {
ALOGE("%s: parcel section name was NULL for section %zu.",
__FUNCTION__, i);
return NOT_ENOUGH_DATA;
@@ -237,7 +237,7 @@ const char* VendorTagDescriptor::getSectionName(uint32_t tag) const {
if (index < 0) {
return VENDOR_SECTION_NAME_ERR;
}
- return mSections[mTagToSectionMap.valueAt(index)].string();
+ return mSections[mTagToSectionMap.valueAt(index)].c_str();
}
const char* VendorTagDescriptor::getTagName(uint32_t tag) const {
@@ -245,7 +245,7 @@ const char* VendorTagDescriptor::getTagName(uint32_t tag) const {
if (index < 0) {
return VENDOR_TAG_NAME_ERR;
}
- return mTagToNameMap.valueAt(index).string();
+ return mTagToNameMap.valueAt(index).c_str();
}
int VendorTagDescriptor::getTagType(uint32_t tag) const {
@@ -299,13 +299,13 @@ const SortedVector* VendorTagDescriptor::getAllSectionNames() const {
status_t VendorTagDescriptor::lookupTag(const String8& name, const String8& section, /*out*/uint32_t* tag) const {
ssize_t index = mReverseMapping.indexOfKey(section);
if (index < 0) {
- ALOGE("%s: Section '%s' does not exist.", __FUNCTION__, section.string());
+ ALOGE("%s: Section '%s' does not exist.", __FUNCTION__, section.c_str());
return BAD_VALUE;
}
ssize_t nameIndex = mReverseMapping[index]->indexOfKey(name);
if (nameIndex < 0) {
- ALOGE("%s: Tag name '%s' does not exist.", __FUNCTION__, name.string());
+ ALOGE("%s: Tag name '%s' does not exist.", __FUNCTION__, name.c_str());
return BAD_VALUE;
}
@@ -344,7 +344,7 @@ void VendorTagDescriptor::dump(int fd, int verbosity, int indentation) const {
const char* typeName = (type >= 0 && type < NUM_TYPES) ?
camera_metadata_type_names[type] : "UNKNOWN";
dprintf(fd, "%*s0x%x (%s) with type %d (%s) defined in section %s\n", indentation + 2,
- "", tag, name.string(), type, typeName, sectionName.string());
+ "", tag, name.c_str(), type, typeName, sectionName.c_str());
}
}
diff --git a/camera/aidl/android/hardware/CameraIdRemapping.aidl b/camera/aidl/android/hardware/CameraIdRemapping.aidl
index e875c53526dfdc32fde55cc7922af6027d40bfd5..453f6968e429a2382207f56a385b0e9bf373707b 100644
--- a/camera/aidl/android/hardware/CameraIdRemapping.aidl
+++ b/camera/aidl/android/hardware/CameraIdRemapping.aidl
@@ -30,17 +30,17 @@ parcelable CameraIdRemapping {
*/
parcelable PackageIdRemapping {
/** Package Name (e.g. com.android.xyz). */
- String packageName;
+ @utf8InCpp String packageName;
/**
* Ordered list of Camera Ids to replace. Only Camera Ids present in this list will be
* affected.
*/
- List cameraIdsToReplace;
+ @utf8InCpp List cameraIdsToReplace;
/**
* Ordered list of updated Camera Ids, where updatedCameraIds[i] corresponds to
* the updated camera id for cameraIdsToReplace[i].
*/
- List updatedCameraIds;
+ @utf8InCpp List updatedCameraIds;
}
/**
diff --git a/camera/aidl/android/hardware/ICameraService.aidl b/camera/aidl/android/hardware/ICameraService.aidl
index 01b8ff89c1b8abd592771e063e56ac749b4c7377..0eeeb7f4b8343d993b36cc6d4b5dddc074916d2d 100644
--- a/camera/aidl/android/hardware/ICameraService.aidl
+++ b/camera/aidl/android/hardware/ICameraService.aidl
@@ -22,6 +22,7 @@ import android.hardware.camera2.ICameraDeviceUser;
import android.hardware.camera2.ICameraDeviceCallbacks;
import android.hardware.camera2.ICameraInjectionCallback;
import android.hardware.camera2.ICameraInjectionSession;
+import android.hardware.camera2.params.SessionConfiguration;
import android.hardware.camera2.params.VendorTagDescriptor;
import android.hardware.camera2.params.VendorTagDescriptorCache;
import android.hardware.camera2.utils.ConcurrentCameraIdCombination;
@@ -83,7 +84,7 @@ interface ICameraService
*/
ICamera connect(ICameraClient client,
int cameraId,
- String opPackageName,
+ @utf8InCpp String opPackageName,
int clientUid, int clientPid,
int targetSdkVersion,
boolean overrideToPortrait,
@@ -94,9 +95,9 @@ interface ICameraService
* Only supported for device HAL versions >= 3.2
*/
ICameraDeviceUser connectDevice(ICameraDeviceCallbacks callbacks,
- String cameraId,
- String opPackageName,
- @nullable String featureId,
+ @utf8InCpp String cameraId,
+ @utf8InCpp String opPackageName,
+ @nullable @utf8InCpp String featureId,
int clientUid, int oomScoreOffset,
int targetSdkVersion,
boolean overrideToPortrait);
@@ -147,6 +148,18 @@ interface ICameraService
*/
void remapCameraIds(in CameraIdRemapping cameraIdRemapping);
+ /**
+ * Inject Session Params into an existing camera session.
+ *
+ * @param cameraId the camera id session to inject session params into. Note that
+ * if there is no active session for the input cameraid, this operation
+ * will be a no-op. In addition, future camera sessions for cameraid will
+ * not be affected.
+ * @param sessionParams the session params to override for the existing session.
+ */
+ void injectSessionParams(@utf8InCpp String cameraId,
+ in CameraMetadataNative sessionParams);
+
/**
* Remove listener for changes to camera device and flashlight state.
*/
@@ -156,7 +169,7 @@ interface ICameraService
* Read the static camera metadata for a camera device.
* Only supported for device HAL versions >= 3.2
*/
- CameraMetadataNative getCameraCharacteristics(String cameraId, int targetSdkVersion,
+ CameraMetadataNative getCameraCharacteristics(@utf8InCpp String cameraId, int targetSdkVersion,
boolean overrideToPortrait);
/**
@@ -177,7 +190,7 @@ interface ICameraService
/**
* Read the legacy camera1 parameters into a String
*/
- String getLegacyParameters(int cameraId);
+ @utf8InCpp String getLegacyParameters(int cameraId);
/**
* apiVersion constants for supportsCameraApi
@@ -186,21 +199,21 @@ interface ICameraService
const int API_VERSION_2 = 2;
// Determines if a particular API version is supported directly for a cameraId.
- boolean supportsCameraApi(String cameraId, int apiVersion);
+ boolean supportsCameraApi(@utf8InCpp String cameraId, int apiVersion);
// Determines if a cameraId is a hidden physical camera of a logical multi-camera.
- boolean isHiddenPhysicalCamera(String cameraId);
+ boolean isHiddenPhysicalCamera(@utf8InCpp String cameraId);
// Inject the external camera to replace the internal camera session.
- ICameraInjectionSession injectCamera(String packageName, String internalCamId,
- String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
+ ICameraInjectionSession injectCamera(@utf8InCpp String packageName, @utf8InCpp String internalCamId,
+ @utf8InCpp String externalCamId, in ICameraInjectionCallback CameraInjectionCallback);
- void setTorchMode(String cameraId, boolean enabled, IBinder clientBinder);
+ void setTorchMode(@utf8InCpp String cameraId, boolean enabled, IBinder clientBinder);
// Change the brightness level of the flash unit associated with cameraId to strengthLevel.
// If the torch is in OFF state and strengthLevel > 0 then the torch will also be turned ON.
- void turnOnTorchWithStrengthLevel(String cameraId, int strengthLevel, IBinder clientBinder);
+ void turnOnTorchWithStrengthLevel(@utf8InCpp String cameraId, int strengthLevel, IBinder clientBinder);
// Get the brightness level of the flash unit associated with cameraId.
- int getTorchStrengthLevel(String cameraId);
+ int getTorchStrengthLevel(@utf8InCpp String cameraId);
/**
* Notify the camera service of a system event. Should only be called from system_server.
@@ -250,7 +263,7 @@ interface ICameraService
*
* @return the key that must be used to report updates to previously reported stats.
*/
- String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
+ @utf8InCpp String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
// Bitfield constants for notifyDeviceStateChange
// All bits >= 32 are for custom vendor states
@@ -261,4 +274,18 @@ interface ICameraService
const int DEVICE_STATE_FOLDED = 4;
const int DEVICE_STATE_LAST_FRAMEWORK_BIT = 0x80000000; // 1 << 31;
+ // Create a CaptureRequest metadata based on template id
+ CameraMetadataNative createDefaultRequest(@utf8InCpp String cameraId, int templateId);
+
+ /**
+ * Check whether a particular session configuration with optional session parameters
+ * has camera device support.
+ *
+ * @param cameraId The camera id to query session configuration on
+ * @param sessionConfiguration Specific session configuration to be verified.
+ * @return true - in case the stream combination is supported.
+ * false - in case there is no device support.
+ */
+ boolean isSessionConfigurationWithParametersSupported(@utf8InCpp String cameraId,
+ in SessionConfiguration sessionConfiguration);
}
diff --git a/camera/aidl/android/hardware/ICameraServiceListener.aidl b/camera/aidl/android/hardware/ICameraServiceListener.aidl
index 5f17f5be5919a64b3b22261173096f86b38c64a2..23a87d32fcf5e2d9fbe6c52962688aaefb37926b 100644
--- a/camera/aidl/android/hardware/ICameraServiceListener.aidl
+++ b/camera/aidl/android/hardware/ICameraServiceListener.aidl
@@ -51,13 +51,14 @@ interface ICameraServiceListener
// Use to initialize variables only
const int STATUS_UNKNOWN = -1;
- oneway void onStatusChanged(int status, String cameraId);
+ oneway void onStatusChanged(int status, @utf8InCpp String cameraId);
/**
* Notify registered client about status changes for a physical camera backing
* a logical camera.
*/
- oneway void onPhysicalCameraStatusChanged(int status, String cameraId, String physicalCameraId);
+ oneway void onPhysicalCameraStatusChanged(int status, @utf8InCpp String cameraId,
+ @utf8InCpp String physicalCameraId);
/**
* The torch mode status of a camera.
@@ -81,9 +82,9 @@ interface ICameraServiceListener
// Use to initialize variables only
const int TORCH_STATUS_UNKNOWN = -1;
- oneway void onTorchStatusChanged(int status, String cameraId);
+ oneway void onTorchStatusChanged(int status, @utf8InCpp String cameraId);
- oneway void onTorchStrengthLevelChanged(String cameraId, int newTorchStrength);
+ oneway void onTorchStrengthLevelChanged(@utf8InCpp String cameraId, int newTorchStrength);
/**
* Notify registered clients about camera access priority changes.
@@ -97,6 +98,6 @@ interface ICameraServiceListener
* Only clients with android.permission.CAMERA_OPEN_CLOSE_LISTENER permission
* will receive such callbacks.
*/
- oneway void onCameraOpened(String cameraId, String clientPackageId);
- oneway void onCameraClosed(String cameraId);
+ oneway void onCameraOpened(@utf8InCpp String cameraId, @utf8InCpp String clientPackageId);
+ oneway void onCameraClosed(@utf8InCpp String cameraId);
}
diff --git a/camera/aidl/android/hardware/ICameraServiceProxy.aidl b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
index 4faa6b49c079967f50be64ed4d2fce074c75e306..dcd69b042cf03a352056e6bc2ae6bf3212b040e0 100644
--- a/camera/aidl/android/hardware/ICameraServiceProxy.aidl
+++ b/camera/aidl/android/hardware/ICameraServiceProxy.aidl
@@ -44,14 +44,14 @@ interface ICameraServiceProxy
* {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_180},
* {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_270}).
*/
- int getRotateAndCropOverride(String packageName, int lensFacing, int userId);
+ int getRotateAndCropOverride(@utf8InCpp String packageName, int lensFacing, int userId);
/**
* Returns the necessary autoframing override for the top activity which
* will be one of ({@link android.hardware.camera2.CameraMetadata#AUTOFRAMING_FALSE},
* {@link android.hardware.camera2.CameraMetadata#AUTOFRAMING_TRUE}).
*/
- int getAutoframingOverride(String packageName);
+ int getAutoframingOverride(@utf8InCpp String packageName);
/**
* Checks if the camera has been disabled via device policy.
diff --git a/camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl b/camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl
index 8e1fcc06ee7f3003f56fd74e78cbfa891be08c96..843e0d455ebdac6b842407ad27525854b769184d 100644
--- a/camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl
+++ b/camera/aidl/android/hardware/camera2/ICameraDeviceUser.aidl
@@ -99,6 +99,15 @@ interface ICameraDeviceUser
*/
boolean isSessionConfigurationSupported(in SessionConfiguration sessionConfiguration);
+ /**
+ * Get the camera characteristics for a particular session configuration
+ *
+ * @param sessionConfiguration Specific session configuration for which the characteristics
+ * are fetched.
+ * @return - characteristics associated with the given session.
+ */
+ CameraMetadataNative getSessionCharacteristics(in SessionConfiguration sessionConfiguration);
+
void deleteStream(int streamId);
/**
diff --git a/camera/camera2/CaptureRequest.cpp b/camera/camera2/CaptureRequest.cpp
index 7a8a4bae411287d19bca7880bb3b94fe21b59f89..071f34ea3781b8f1b0e601a24c5a7b0925798cae 100644
--- a/camera/camera2/CaptureRequest.cpp
+++ b/camera/camera2/CaptureRequest.cpp
@@ -21,6 +21,7 @@
#include
#include
+#include
#include
#include
@@ -74,7 +75,7 @@ status_t CaptureRequest::readFromParcel(const android::Parcel* parcel) {
return err;
}
ALOGV("%s: Read metadata from parcel", __FUNCTION__);
- mPhysicalCameraSettings.push_back({std::string(String8(id).string()), settings});
+ mPhysicalCameraSettings.push_back({toStdString(id), settings});
}
int isReprocess = 0;
@@ -157,7 +158,7 @@ status_t CaptureRequest::readFromParcel(const android::Parcel* parcel) {
ALOGE("%s: Failed to read user tag!", __FUNCTION__);
return BAD_VALUE;
}
- mUserTag = String8(userTag).c_str();
+ mUserTag = toStdString(userTag);
}
return OK;
@@ -179,7 +180,7 @@ status_t CaptureRequest::writeToParcel(android::Parcel* parcel) const {
}
for (const auto &it : mPhysicalCameraSettings) {
- if ((err = parcel->writeString16(String16(it.id.c_str()))) != OK) {
+ if ((err = parcel->writeString16(toString16(it.id))) != OK) {
ALOGE("%s: Failed to camera id!", __FUNCTION__);
return err;
}
@@ -232,7 +233,7 @@ status_t CaptureRequest::writeToParcel(android::Parcel* parcel) const {
parcel->writeInt32(0);
} else {
parcel->writeInt32(1);
- parcel->writeString16(String16(mUserTag.c_str()));
+ parcel->writeString16(toString16(mUserTag));
}
return OK;
diff --git a/camera/camera2/ConcurrentCamera.cpp b/camera/camera2/ConcurrentCamera.cpp
index 01a695c9796ff32140223ee91a6d066a5fcae846..67aa8764a23d18eb1baeae104af180131660198d 100644
--- a/camera/camera2/ConcurrentCamera.cpp
+++ b/camera/camera2/ConcurrentCamera.cpp
@@ -20,6 +20,7 @@
#include
#include
+#include
#include
@@ -53,7 +54,7 @@ status_t ConcurrentCameraIdCombination::readFromParcel(const android::Parcel* pa
ALOGE("%s: Failed to read camera id!", __FUNCTION__);
return err;
}
- mConcurrentCameraIds.push_back(std::string(String8(id).string()));
+ mConcurrentCameraIds.push_back(toStdString(id));
}
return OK;
}
@@ -73,7 +74,7 @@ status_t ConcurrentCameraIdCombination::writeToParcel(android::Parcel* parcel) c
}
for (const auto &it : mConcurrentCameraIds) {
- if ((err = parcel->writeString16(String16(it.c_str()))) != OK) {
+ if ((err = parcel->writeString16(toString16(it))) != OK) {
ALOGE("%s: Failed to write the camera id string to parcel: %d", __FUNCTION__, err);
return err;
}
@@ -99,7 +100,7 @@ status_t CameraIdAndSessionConfiguration::readFromParcel(const android::Parcel*
ALOGE("%s: Failed to read sessionConfiguration!", __FUNCTION__);
return err;
}
- mCameraId = std::string(String8(id).string());
+ mCameraId = toStdString(id);
return OK;
}
@@ -111,7 +112,7 @@ status_t CameraIdAndSessionConfiguration::writeToParcel(android::Parcel* parcel)
}
status_t err = OK;
- if ((err = parcel->writeString16(String16(mCameraId.c_str()))) != OK) {
+ if ((err = parcel->writeString16(toString16(mCameraId))) != OK) {
ALOGE("%s: Failed to write camera id!", __FUNCTION__);
return err;
}
diff --git a/camera/camera2/OutputConfiguration.cpp b/camera/camera2/OutputConfiguration.cpp
index da4484a9cfb1d0beee07c0e62f96a19981e1cad5..73b153c914cd38ac892a7562c729129d66f59c3c 100644
--- a/camera/camera2/OutputConfiguration.cpp
+++ b/camera/camera2/OutputConfiguration.cpp
@@ -21,6 +21,7 @@
#include
#include
+#include
#include
#include
#include
@@ -65,7 +66,7 @@ bool OutputConfiguration::isShared() const {
return mIsShared;
}
-String16 OutputConfiguration::getPhysicalCameraId() const {
+std::string OutputConfiguration::getPhysicalCameraId() const {
return mPhysicalCameraId;
}
@@ -183,7 +184,9 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
return err;
}
- parcel->readString16(&mPhysicalCameraId);
+ String16 physicalCameraId;
+ parcel->readString16(&physicalCameraId);
+ mPhysicalCameraId = toStdString(physicalCameraId);
int isMultiResolution = 0;
if ((err = parcel->readInt32(&isMultiResolution)) != OK) {
@@ -246,7 +249,7 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
for (auto& surface : surfaceShims) {
ALOGV("%s: OutputConfiguration: %p, name %s", __FUNCTION__,
surface.graphicBufferProducer.get(),
- String8(surface.name).string());
+ toString8(surface.name).c_str());
mGbps.push_back(surface.graphicBufferProducer);
}
@@ -258,14 +261,14 @@ status_t OutputConfiguration::readFromParcel(const android::Parcel* parcel) {
" physicalCameraId = %s, isMultiResolution = %d, streamUseCase = %" PRId64
", timestampBase = %d, mirrorMode = %d, useReadoutTimestamp = %d",
__FUNCTION__, mRotation, mSurfaceSetID, mSurfaceType,
- String8(mPhysicalCameraId).string(), mIsMultiResolution, mStreamUseCase, timestampBase,
+ mPhysicalCameraId.c_str(), mIsMultiResolution, mStreamUseCase, timestampBase,
mMirrorMode, mUseReadoutTimestamp);
return err;
}
OutputConfiguration::OutputConfiguration(sp& gbp, int rotation,
- const String16& physicalId,
+ const std::string& physicalId,
int surfaceSetID, bool isShared) {
mGbps.push_back(gbp);
mRotation = rotation;
@@ -284,7 +287,7 @@ OutputConfiguration::OutputConfiguration(sp& gbp, int ro
OutputConfiguration::OutputConfiguration(
const std::vector>& gbps,
- int rotation, const String16& physicalCameraId, int surfaceSetID, int surfaceType,
+ int rotation, const std::string& physicalCameraId, int surfaceSetID, int surfaceType,
int width, int height, bool isShared)
: mGbps(gbps), mRotation(rotation), mSurfaceSetID(surfaceSetID), mSurfaceType(surfaceType),
mWidth(width), mHeight(height), mIsDeferred(false), mIsShared(isShared),
@@ -331,7 +334,8 @@ status_t OutputConfiguration::writeToParcel(android::Parcel* parcel) const {
err = parcel->writeParcelableVector(surfaceShims);
if (err != OK) return err;
- err = parcel->writeString16(mPhysicalCameraId);
+ String16 physicalCameraId = toString16(mPhysicalCameraId);
+ err = parcel->writeString16(physicalCameraId);
if (err != OK) return err;
err = parcel->writeInt32(mIsMultiResolution ? 1 : 0);
diff --git a/camera/camera2/SessionConfiguration.cpp b/camera/camera2/SessionConfiguration.cpp
index 7cf6087830b3fbcc8d7ed555e730708de399ff83..2f1f22dd6e547719a177d21806166a264f4639ef 100644
--- a/camera/camera2/SessionConfiguration.cpp
+++ b/camera/camera2/SessionConfiguration.cpp
@@ -22,10 +22,13 @@
#include
#include
+#include
#include
namespace android {
+namespace flags = com::android::internal::camera::flags;
+
status_t SessionConfiguration::readFromParcel(const android::Parcel* parcel) {
status_t err = OK;
int operatingMode = 0;
@@ -67,6 +70,22 @@ status_t SessionConfiguration::readFromParcel(const android::Parcel* parcel) {
return err;
}
+ bool hasSessionParameters = false;
+ CameraMetadata settings;
+ if (flags::feature_combination_query()) {
+ if ((err = parcel->readBool(&hasSessionParameters)) != OK) {
+ ALOGE("%s: Failed to read hasSessionParameters flag from parcel", __FUNCTION__);
+ return err;
+ }
+
+ if (hasSessionParameters) {
+ if ((err = settings.readFromParcel(parcel)) != OK) {
+ ALOGE("%s: Failed to read metadata flag from parcel", __FUNCTION__);
+ return err;
+ }
+ }
+ }
+
mOperatingMode = operatingMode;
mInputWidth = inputWidth;
mInputHeight = inputHeight;
@@ -75,7 +94,10 @@ status_t SessionConfiguration::readFromParcel(const android::Parcel* parcel) {
for (auto& stream : outputStreams) {
mOutputStreams.push_back(stream);
}
-
+ if (flags::feature_combination_query()) {
+ mHasSessionParameters = hasSessionParameters;
+ mSessionParameters = std::move(settings);
+ }
return err;
}
@@ -103,6 +125,16 @@ status_t SessionConfiguration::writeToParcel(android::Parcel* parcel) const {
err = parcel->writeParcelableVector(mOutputStreams);
if (err != OK) return err;
+ if (flags::feature_combination_query()) {
+ err = parcel->writeBool(mHasSessionParameters);
+ if (err != OK) return err;
+
+ if (mHasSessionParameters) {
+ err = mSessionParameters.writeToParcel(parcel);
+ if (err != OK) return err;
+ }
+ }
+
return OK;
}
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
new file mode 100644
index 0000000000000000000000000000000000000000..5d2a26346a6d649cbedb0914649d8a88fddb8709
--- /dev/null
+++ b/camera/camera_platform.aconfig
@@ -0,0 +1,78 @@
+package: "com.android.internal.camera.flags"
+
+flag {
+ namespace: "camera_platform"
+ name: "camera_hsum_permission"
+ description: "Camera access by headless system user"
+ bug: "273539631"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "concert_mode"
+ description: "Introduces a new concert mode camera extension type"
+ bug: "297083874"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "feature_combination_query"
+ description: "Query feature combination support and session specific characteristics"
+ bug: "309627704"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "log_ultrawide_usage"
+ description: "Enable measuring how much usage there is for ultrawide-angle cameras"
+ bug: "300515796"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "camera_manual_flash_strength_control"
+ description: "Flash brightness level control in manual flash mode"
+ bug: "238348881"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "lazy_aidl_wait_for_service"
+ description: "Use waitForService instead of getService with lazy AIDL HALs"
+ bug: "285546208"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "log_zoom_override_usage"
+ description: "Enable measuring how much usage there is for zoom settings overrde"
+ bug: "307409002"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "session_hal_buf_manager"
+ description: "Enable or disable HAL buffer manager as requested by the camera HAL"
+ bug: "311263114"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "inject_session_params"
+ description: "Enable session parameter injection via reconfiguration"
+ bug: "308984721"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "camera_ae_mode_low_light_boost"
+ description: "An AE mode that enables increased brightening in low light scenes"
+ bug: "312803148"
+}
+
+flag {
+ namespace: "camera_platform"
+ name: "multiresolution_imagereader_usage_config"
+ description: "Enable creating MultiResolutionImageReader with usage flag configuration"
+ bug: "301588215"
+}
diff --git a/camera/cameraserver/Android.bp b/camera/cameraserver/Android.bp
index 847256272a8ebb34e2890d05d27ed616b9405d2e..13b705cf9e69b8b924308048679b3af6e3a0d5ba 100644
--- a/camera/cameraserver/Android.bp
+++ b/camera/cameraserver/Android.bp
@@ -26,12 +26,15 @@ cc_binary {
srcs: ["main_cameraserver.cpp"],
+ defaults: [
+ "libcameraservice_deps",
+ ],
+
header_libs: [
"libmedia_headers",
],
shared_libs: [
- "libcameraservice",
"liblog",
"libutils",
"libui",
@@ -40,15 +43,13 @@ cc_binary {
"libbinder_ndk",
"libhidlbase",
"android.hardware.camera.common@1.0",
- "android.hardware.camera.provider@2.4",
- "android.hardware.camera.provider@2.5",
- "android.hardware.camera.provider@2.6",
- "android.hardware.camera.provider@2.7",
- "android.hardware.camera.provider-V2-ndk",
"android.hardware.camera.device@1.0",
"android.hardware.camera.device@3.2",
"android.hardware.camera.device@3.4",
],
+ static_libs: [
+ "libcameraservice",
+ ],
compile_multilib: "first",
cflags: [
"-Wall",
diff --git a/camera/cameraserver/manifest_android.frameworks.cameraservice.service.xml b/camera/cameraserver/manifest_android.frameworks.cameraservice.service.xml
index f7e455f9c4c4f2a079e51ee707109afd890fa724..5d859098eea76840721d8c40e49db928121cb0b8 100644
--- a/camera/cameraserver/manifest_android.frameworks.cameraservice.service.xml
+++ b/camera/cameraserver/manifest_android.frameworks.cameraservice.service.xml
@@ -11,7 +11,7 @@
android.frameworks.cameraservice.service
- 1
+ 2
ICameraService
default
diff --git a/camera/include/camera/Camera.h b/camera/include/camera/Camera.h
index 21b57afabf54d913397a1fa823ac63e5514808a5..6655f82b583a6800e29d9583769ceb9a61f6315d 100644
--- a/camera/include/camera/Camera.h
+++ b/camera/include/camera/Camera.h
@@ -56,9 +56,9 @@ struct CameraTraits
typedef CameraListener TCamListener;
typedef ::android::hardware::ICamera TCamUser;
typedef ::android::hardware::ICameraClient TCamCallbacks;
- typedef ::android::binder::Status(::android::hardware::ICameraService::*TCamConnectService)
+ typedef ::android::binder::Status (::android::hardware::ICameraService::*TCamConnectService)
(const sp<::android::hardware::ICameraClient>&,
- int, const String16&, int, int, int, bool, bool,
+ int, const std::string&, int, int, int, bool, bool,
/*out*/
sp<::android::hardware::ICamera>*);
static TCamConnectService fnConnectService;
@@ -80,7 +80,7 @@ public:
// construct a camera client from an existing remote
static sp create(const sp<::android::hardware::ICamera>& camera);
static sp connect(int cameraId,
- const String16& clientPackageName,
+ const std::string& clientPackageName,
int clientUid, int clientPid, int targetSdkVersion,
bool overrideToPortrait, bool forceSlowJpegMode);
diff --git a/camera/include/camera/CameraBase.h b/camera/include/camera/CameraBase.h
index b20dc1bcd366c08feb33b180601887ce78bdcb99..6af7f2aa0b5b1df145e76aa2f01213a8625da018 100644
--- a/camera/include/camera/CameraBase.h
+++ b/camera/include/camera/CameraBase.h
@@ -73,7 +73,7 @@ struct CameraStatus : public android::Parcelable {
/**
* The name of the camera device
*/
- String8 cameraId;
+ std::string cameraId;
/**
* Its current status, one of the ICameraService::STATUS_* fields
@@ -83,18 +83,18 @@ struct CameraStatus : public android::Parcelable {
/**
* Unavailable physical camera names for a multi-camera device
*/
- std::vector unavailablePhysicalIds;
+ std::vector unavailablePhysicalIds;
/**
* Client package name if camera is open, otherwise not applicable
*/
- String8 clientPackage;
+ std::string clientPackage;
virtual status_t writeToParcel(android::Parcel* parcel) const;
virtual status_t readFromParcel(const android::Parcel* parcel);
- CameraStatus(String8 id, int32_t s, const std::vector& unavailSubIds,
- const String8& clientPkg) : cameraId(id), status(s),
+ CameraStatus(std::string id, int32_t s, const std::vector& unavailSubIds,
+ const std::string& clientPkg) : cameraId(id), status(s),
unavailablePhysicalIds(unavailSubIds), clientPackage(clientPkg) {}
CameraStatus() : status(ICameraServiceListener::STATUS_PRESENT) {}
};
@@ -118,7 +118,7 @@ public:
typedef typename TCamTraits::TCamConnectService TCamConnectService;
static sp connect(int cameraId,
- const String16& clientPackageName,
+ const std::string& clientPackageName,
int clientUid, int clientPid, int targetSdkVersion,
bool overrideToPortrait, bool forceSlowJpegMode);
virtual void disconnect();
diff --git a/camera/include/camera/CameraSessionStats.h b/camera/include/camera/CameraSessionStats.h
index 071bc7368cd3a643ccf5867bec01435fd940a42a..06c154ddf15b41f840dbed7eeb11c5549263f882 100644
--- a/camera/include/camera/CameraSessionStats.h
+++ b/camera/include/camera/CameraSessionStats.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_HARDWARE_CAMERA_SERVICE_SESSION_STATS_H
#define ANDROID_HARDWARE_CAMERA_SERVICE_SESSION_STATS_H
+#include
+
#include
#include
@@ -121,10 +123,10 @@ public:
static const int CAMERA_API_LEVEL_1;
static const int CAMERA_API_LEVEL_2;
- String16 mCameraId;
+ std::string mCameraId;
int mFacing;
int mNewCameraState;
- String16 mClientName;
+ std::string mClientName;
int mApiLevel;
bool mIsNdk;
// latency in ms for camera open, close, or session creation.
@@ -157,16 +159,18 @@ public:
// Whether the device runs into an error state
bool mDeviceError;
std::vector mStreamStats;
- String16 mUserTag;
+ std::string mUserTag;
int mVideoStabilizationMode;
+ bool mUsedUltraWide;
+ bool mUsedZoomOverride;
int mSessionIndex;
CameraExtensionSessionStats mCameraExtensionSessionStats;
// Constructors
CameraSessionStats();
- CameraSessionStats(const String16& cameraId, int facing, int newCameraState,
- const String16& clientName, int apiLevel, bool isNdk, int32_t latencyMs,
+ CameraSessionStats(const std::string& cameraId, int facing, int newCameraState,
+ const std::string& clientName, int apiLevel, bool isNdk, int32_t latencyMs,
int64_t logId);
virtual status_t readFromParcel(const android::Parcel* parcel) override;
diff --git a/camera/include/camera/CaptureResult.h b/camera/include/camera/CaptureResult.h
index de534ab0bccb17877b15c208b62a32b810ceba03..e08c9ca3b80484e7f764cda39c45cc0e22a616d7 100644
--- a/camera/include/camera/CaptureResult.h
+++ b/camera/include/camera/CaptureResult.h
@@ -74,7 +74,7 @@ struct CaptureResultExtras : public android::Parcelable {
* a reference to physical camera device.
* Empty otherwise.
*/
- String16 errorPhysicalCameraId;
+ std::string errorPhysicalCameraId;
// The last completed frame numbers shouldn't be checked in onResultReceived() and notifyError()
// because the output buffers could be arriving after onResultReceived() and
@@ -150,13 +150,13 @@ struct PhysicalCaptureResultInfo : public android::Parcelable {
: mPhysicalCameraId(),
mPhysicalCameraMetadata() {
}
- PhysicalCaptureResultInfo(const String16& cameraId,
+ PhysicalCaptureResultInfo(const std::string& cameraId,
const CameraMetadata& cameraMetadata)
: mPhysicalCameraId(cameraId),
mPhysicalCameraMetadata(cameraMetadata) {
}
- String16 mPhysicalCameraId;
+ std::string mPhysicalCameraId;
CameraMetadata mPhysicalCameraMetadata;
virtual status_t readFromParcel(const android::Parcel* parcel) override;
diff --git a/camera/include/camera/StringUtils.h b/camera/include/camera/StringUtils.h
new file mode 100644
index 0000000000000000000000000000000000000000..80c419f32f44cb40261ec8bf6c08133dc0a1a77d
--- /dev/null
+++ b/camera/include/camera/StringUtils.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_STRINGUTILS_H
+#define ANDROID_SERVERS_CAMERA_STRINGUTILS_H
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+namespace android {
+ inline String8 toString8(const std::string &str) {
+ return String8(str.c_str());
+ }
+
+ inline String8 toString8(const String16 &str) {
+ return String8(str);
+ }
+
+ inline String8 toString8(const char *str) {
+ return String8(str);
+ }
+
+ inline String16 toString16(const std::string &str) {
+ return String16(str.c_str());
+ }
+
+ inline String16 toString16(const String8 &str) {
+ return String16(str);
+ }
+
+ inline String16 toString16(const char *str) {
+ return String16(str);
+ }
+
+ inline std::optional toString16(std::optional str) {
+ if (str.has_value()) {
+ return std::optional(toString16(str.value()));
+ }
+
+ return std::nullopt;
+ }
+
+ inline std::string toStdString(const String8 &str) {
+ return std::string(str.c_str());
+ }
+
+ inline std::string toStdString(const String16 &str) {
+ String8 str8(str);
+ return std::string(str8.c_str());
+ }
+
+ /**
+ * Convert a non-null-terminated UTF16 string to a UTF8 string (i.e. in jni functions)
+ * len is the number of characters.
+ */
+ inline std::string toStdString(const char16_t *str, size_t len) {
+ String16 str16(str, len);
+ String8 str8(str16);
+ return std::string(str8.c_str());
+ }
+} // namespace android
+
+#endif // ANDROID_SERVERS_CAMERA_STRINGUTILS_H
diff --git a/camera/include/camera/camera2/OutputConfiguration.h b/camera/include/camera/camera2/OutputConfiguration.h
index 16fddb5eb4cdcc4c90b70ce9468e86c571b6674c..3f74b4a6ff361a06929706c2604515e1c5ccae95 100644
--- a/camera/include/camera/camera2/OutputConfiguration.h
+++ b/camera/include/camera/camera2/OutputConfiguration.h
@@ -17,6 +17,8 @@
#ifndef ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H
#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H
+#include
+
#include
#include
@@ -63,7 +65,7 @@ public:
int32_t getColorSpace() const;
bool isDeferred() const;
bool isShared() const;
- String16 getPhysicalCameraId() const;
+ std::string getPhysicalCameraId() const;
bool isMultiResolution() const;
int64_t getStreamUseCase() const;
int getTimestampBase() const;
@@ -90,11 +92,11 @@ public:
OutputConfiguration(const android::Parcel& parcel);
OutputConfiguration(sp& gbp, int rotation,
- const String16& physicalCameraId,
+ const std::string& physicalCameraId,
int surfaceSetID = INVALID_SET_ID, bool isShared = false);
OutputConfiguration(const std::vector>& gbps,
- int rotation, const String16& physicalCameraId,
+ int rotation, const std::string& physicalCameraId,
int surfaceSetID = INVALID_SET_ID,
int surfaceType = OutputConfiguration::SURFACE_TYPE_UNKNOWN, int width = 0,
int height = 0, bool isShared = false);
@@ -192,7 +194,7 @@ private:
int mHeight;
bool mIsDeferred;
bool mIsShared;
- String16 mPhysicalCameraId;
+ std::string mPhysicalCameraId;
bool mIsMultiResolution;
std::vector mSensorPixelModesUsed;
int64_t mDynamicRangeProfile;
diff --git a/camera/include/camera/camera2/SessionConfiguration.h b/camera/include/camera/camera2/SessionConfiguration.h
index 29913f6f0b89a4a85a622cab0ff670b6ae0cb78e..120bf9efbc936960961cdb847fcb5bbf7ffe8957 100644
--- a/camera/include/camera/camera2/SessionConfiguration.h
+++ b/camera/include/camera/camera2/SessionConfiguration.h
@@ -18,6 +18,7 @@
#define ANDROID_HARDWARE_CAMERA2_SESSIONCONFIGURATION_H
#include
+#include
namespace android {
@@ -39,6 +40,8 @@ public:
int getInputFormat() const { return mInputFormat; }
int getOperatingMode() const { return mOperatingMode; }
bool inputIsMultiResolution() const { return mInputIsMultiResolution; }
+ bool hasSessionParameters() const { return mHasSessionParameters; }
+ const CameraMetadata& getSessionParameters() const { return mSessionParameters; }
virtual status_t writeToParcel(android::Parcel* parcel) const override;
virtual status_t readFromParcel(const android::Parcel* parcel) override;
@@ -111,6 +114,8 @@ private:
std::vector mOutputStreams;
int mInputWidth, mInputHeight, mInputFormat, mOperatingMode;
bool mInputIsMultiResolution = false;
+ bool mHasSessionParameters = false;
+ CameraMetadata mSessionParameters;
};
} // namespace params
} // namespace camera2
diff --git a/camera/ndk/Android.bp b/camera/ndk/Android.bp
index bfd02b3594bc4d29e5e48cdcd5283435fe2d4a15..d4dd5464f3014694bbf98724468c9e5b603e0480 100644
--- a/camera/ndk/Android.bp
+++ b/camera/ndk/Android.bp
@@ -111,6 +111,7 @@ cc_library_shared {
cc_library_shared {
name: "libcamera2ndk_vendor",
+ cpp_std: "gnu++17",
vendor: true,
srcs: [
"ndk_vendor/impl/ACameraDevice.cpp",
@@ -165,11 +166,6 @@ cc_library_shared {
include_dirs: [
"system/media/private/camera/include",
],
- product_variables: {
- pdk: {
- enabled: false,
- },
- },
}
cc_test {
@@ -182,6 +178,7 @@ cc_test {
shared_libs: [
"libcamera2ndk_vendor",
"libcamera_metadata",
+ "libhidlbase",
"libmediandk",
"libnativewindow",
"libutils",
@@ -191,6 +188,7 @@ cc_test {
],
static_libs: [
"android.hardware.camera.common@1.0-helper",
+ "android.hidl.token@1.0",
],
cflags: [
"-D__ANDROID_VNDK__",
diff --git a/camera/ndk/impl/ACameraDevice.cpp b/camera/ndk/impl/ACameraDevice.cpp
index 1dae0f91dca2fb76b45b635b72b607aa0d2600fa..97d65b0ab09b5aa0aa5bad072a77e2df4269654c 100644
--- a/camera/ndk/impl/ACameraDevice.cpp
+++ b/camera/ndk/impl/ACameraDevice.cpp
@@ -21,6 +21,7 @@
#include
#include
#include
+#include
#include "ACameraDevice.h"
#include "ACameraMetadata.h"
#include "ACaptureRequest.h"
@@ -162,7 +163,7 @@ CameraDevice::createCaptureRequest(
templateId);
return ACAMERA_ERROR_INVALID_PARAMETER;
} else if (!remoteRet.isOk()) {
- ALOGE("Create capture request failed: %s", remoteRet.toString8().string());
+ ALOGE("Create capture request failed: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
ACaptureRequest* outReq = new ACaptureRequest();
@@ -234,8 +235,7 @@ camera_status_t CameraDevice::isSessionConfigurationSupported(
return ret;
}
- String16 physicalId16(output.mPhysicalCameraId.c_str());
- OutputConfiguration outConfig(iGBP, output.mRotation, physicalId16,
+ OutputConfiguration outConfig(iGBP, output.mRotation, output.mPhysicalCameraId,
OutputConfiguration::INVALID_SET_ID, true);
for (auto& anw : output.mSharedWindows) {
@@ -299,8 +299,7 @@ camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOut
return ret;
}
- String16 physicalId16(output->mPhysicalCameraId.c_str());
- OutputConfiguration outConfig(iGBP, output->mRotation, physicalId16,
+ OutputConfiguration outConfig(iGBP, output->mRotation, output->mPhysicalCameraId,
OutputConfiguration::INVALID_SET_ID, true);
for (auto& anw : output->mSharedWindows) {
@@ -318,22 +317,22 @@ camera_status_t CameraDevice::updateOutputConfigurationLocked(ACaptureSessionOut
switch (remoteRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_INVALID_OPERATION:
ALOGE("Camera device %s invalid operation: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_OPERATION;
break;
case hardware::ICameraService::ERROR_ALREADY_EXISTS:
ALOGE("Camera device %s output surface already exists: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
case hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT:
ALOGE("Camera device %s invalid input argument: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
default:
ALOGE("Camera device %s failed to add shared output: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
}
@@ -369,24 +368,24 @@ camera_status_t CameraDevice::prepareLocked(ACameraWindowType *window) {
// ndk as well.
if (remoteRet.exceptionCode() != EX_SERVICE_SPECIFIC) {
ALOGE("Camera device %s failed to prepare output window %p: %s", getId(), window,
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
switch (remoteRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_INVALID_OPERATION:
ALOGE("Camera device %s invalid operation: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_OPERATION;
break;
case hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT:
ALOGE("Camera device %s invalid input argument: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_INVALID_PARAMETER;
break;
default:
ALOGE("Camera device %s failed to prepare output window %p: %s", getId(), window,
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
}
@@ -547,7 +546,7 @@ CameraDevice::stopRepeatingLocked() {
ALOGV("Repeating request is already stopped.");
return ACAMERA_OK;
} else if (!remoteRet.isOk()) {
- ALOGE("Stop repeating request fails in remote: %s", remoteRet.toString8().string());
+ ALOGE("Stop repeating request fails in remote: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
checkRepeatingSequenceCompleteLocked(repeatingSequenceId, lastFrameNumber);
@@ -599,7 +598,7 @@ CameraDevice::flushLocked(ACameraCaptureSession* session) {
int64_t lastFrameNumber;
binder::Status remoteRet = mRemote->flush(&lastFrameNumber);
if (!remoteRet.isOk()) {
- ALOGE("Abort captures fails in remote: %s", remoteRet.toString8().string());
+ ALOGE("Abort captures fails in remote: %s", remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
if (mRepeatingSequenceId != REQUEST_ID_NONE) {
@@ -623,7 +622,7 @@ CameraDevice::waitUntilIdleLocked() {
binder::Status remoteRet = mRemote->waitUntilIdle();
if (!remoteRet.isOk()) {
- ALOGE("Camera device %s waitUntilIdle failed: %s", getId(), remoteRet.toString8().string());
+ ALOGE("Camera device %s waitUntilIdle failed: %s", getId(), remoteRet.toString8().c_str());
// TODO: define a function to convert status_t -> camera_status_t
return ACAMERA_ERROR_UNKNOWN;
}
@@ -683,9 +682,8 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
if (ret != ACAMERA_OK) {
return ret;
}
- String16 physicalId16(outConfig.mPhysicalCameraId.c_str());
outputSet.insert(std::make_pair(
- anw, OutputConfiguration(iGBP, outConfig.mRotation, physicalId16,
+ anw, OutputConfiguration(iGBP, outConfig.mRotation, outConfig.mPhysicalCameraId,
OutputConfiguration::INVALID_SET_ID, outConfig.mIsShared)));
}
auto addSet = outputSet;
@@ -734,7 +732,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
binder::Status remoteRet = mRemote->beginConfigure();
if (!remoteRet.isOk()) {
- ALOGE("Camera device %s begin configure failed: %s", getId(), remoteRet.toString8().string());
+ ALOGE("Camera device %s begin configure failed: %s", getId(), remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
@@ -743,7 +741,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
remoteRet = mRemote->deleteStream(streamId);
if (!remoteRet.isOk()) {
ALOGE("Camera device %s failed to remove stream %d: %s", getId(), streamId,
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
mConfiguredOutputs.erase(streamId);
@@ -755,7 +753,7 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
remoteRet = mRemote->createStream(outputPair.second, &streamId);
if (!remoteRet.isOk()) {
ALOGE("Camera device %s failed to create stream: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
mConfiguredOutputs.insert(std::make_pair(streamId, outputPair));
@@ -770,10 +768,10 @@ CameraDevice::configureStreamsLocked(const ACaptureSessionOutputContainer* outpu
ns2ms(startTimeNs), &offlineStreamIds);
if (remoteRet.serviceSpecificErrorCode() == hardware::ICameraService::ERROR_ILLEGAL_ARGUMENT) {
ALOGE("Camera device %s cannnot support app output configuration: %s", getId(),
- remoteRet.toString8().string());
+ remoteRet.toString8().c_str());
return ACAMERA_ERROR_STREAM_CONFIGURE_FAIL;
} else if (!remoteRet.isOk()) {
- ALOGE("Camera device %s end configure failed: %s", getId(), remoteRet.toString8().string());
+ ALOGE("Camera device %s end configure failed: %s", getId(), remoteRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN;
}
@@ -919,8 +917,8 @@ CameraDevice::onCaptureErrorLocked(
msg->setObject(kSessionSpKey, session);
if (cbh.mIsLogicalCameraCallback) {
if (resultExtras.errorPhysicalCameraId.size() > 0) {
- String8 cameraId(resultExtras.errorPhysicalCameraId);
- msg->setString(kFailingPhysicalCameraId, cameraId.string(), cameraId.size());
+ String8 cameraId = toString8(resultExtras.errorPhysicalCameraId);
+ msg->setString(kFailingPhysicalCameraId, cameraId.c_str(), cameraId.size());
}
msg->setPointer(kCallbackFpKey, (void*) cbh.mOnLogicalCameraCaptureFailed);
} else {
@@ -1215,7 +1213,7 @@ void CameraDevice::CallbackHandler::onMessageReceived(
std::vector physicalCameraIds;
std::vector> physicalMetadataCopy;
for (size_t i = 0; i < physicalResultInfo.size(); i++) {
- String8 physicalId8(physicalResultInfo[i].mPhysicalCameraId);
+ String8 physicalId8 = toString8(physicalResultInfo[i].mPhysicalCameraId);
physicalCameraIds.push_back(physicalId8.c_str());
CameraMetadata clone = physicalResultInfo[i].mPhysicalCameraMetadata;
diff --git a/camera/ndk/impl/ACameraDevice.h b/camera/ndk/impl/ACameraDevice.h
index 382d6ce7f41b555694d162e9e380e19509e9adf2..4658d182cf8ed58f04f8f8e87505dd4d0c33260c 100644
--- a/camera/ndk/impl/ACameraDevice.h
+++ b/camera/ndk/impl/ACameraDevice.h
@@ -66,7 +66,7 @@ class CameraDevice final : public RefBase {
ACameraDevice* wrapper);
~CameraDevice();
- inline const char* getId() const { return mCameraId.string(); }
+ inline const char* getId() const { return mCameraId.c_str(); }
camera_status_t createCaptureRequest(
ACameraDevice_request_template templateId,
diff --git a/camera/ndk/impl/ACameraManager.cpp b/camera/ndk/impl/ACameraManager.cpp
index 837b5be252f7fc2e60348d1cc2d09ee7016b2029..5d3b65b56f61030e48797be3460cb81d01852ff8 100644
--- a/camera/ndk/impl/ACameraManager.cpp
+++ b/camera/ndk/impl/ACameraManager.cpp
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#include
using namespace android::acam;
@@ -84,7 +85,7 @@ sp CameraManagerGlobal::getCameraServiceLocked() {
sp sm = defaultServiceManager();
sp binder;
do {
- binder = sm->getService(String16(kCameraServiceName));
+ binder = sm->getService(toString16(kCameraServiceName));
if (binder != nullptr) {
break;
}
@@ -165,7 +166,7 @@ sp CameraManagerGlobal::getCameraServiceLocked() {
} else {
VendorTagDescriptorCache::clearGlobalVendorTagCache();
ALOGE("%s: Failed to setup vendor tag cache: %s",
- __FUNCTION__, res.toString8().string());
+ __FUNCTION__, res.toString8().c_str());
}
}
} else if (ret.serviceSpecificErrorCode() ==
@@ -175,7 +176,7 @@ sp CameraManagerGlobal::getCameraServiceLocked() {
VendorTagDescriptor::clearGlobalVendorTagDescriptor();
} else {
ALOGE("%s: Failed to get vendor tag descriptors: %s",
- __FUNCTION__, ret.toString8().string());
+ __FUNCTION__, ret.toString8().c_str());
}
}
ALOGE_IF(mCameraService == nullptr, "no CameraService!?");
@@ -188,12 +189,12 @@ void CameraManagerGlobal::DeathNotifier::binderDied(const wp&)
sp cm = mCameraManager.promote();
if (cm != nullptr) {
AutoMutex lock(cm->mLock);
- std::vector cameraIdList;
+ std::vector cameraIdList;
for (auto& pair : cm->mDeviceStatusMap) {
cameraIdList.push_back(pair.first);
}
- for (String8 cameraId : cameraIdList) {
+ for (const std::string& cameraId : cameraIdList) {
cm->onStatusChangedLocked(
CameraServiceListener::STATUS_NOT_PRESENT, cameraId);
}
@@ -259,7 +260,7 @@ void CameraManagerGlobal::registerAvailCallback(const T *callback) {
// Send initial callbacks if callback is newly registered
if (pair.second) {
for (auto& pair : mDeviceStatusMap) {
- const String8& cameraId = pair.first;
+ const std::string& cameraId = pair.first;
int32_t status = pair.second.getStatus();
// Don't send initial callbacks for camera ids which don't support
// camera2
@@ -273,12 +274,12 @@ void CameraManagerGlobal::registerAvailCallback(const T *callback) {
cb.mAvailable : cb.mUnavailable;
msg->setPointer(kCallbackFpKey, (void *) cbFunc);
msg->setPointer(kContextKey, cb.mContext);
- msg->setString(kCameraIdKey, AString(cameraId));
+ msg->setString(kCameraIdKey, AString(cameraId.c_str()));
mPendingCallbackCnt++;
msg->post();
// Physical camera unavailable callback
- std::set unavailablePhysicalCameras =
+ std::set unavailablePhysicalCameras =
pair.second.getUnavailablePhysicalIds();
for (const auto& physicalCameraId : unavailablePhysicalCameras) {
sp msg = new AMessage(kWhatSendSinglePhysicalCameraCallback, mHandler);
@@ -286,8 +287,8 @@ void CameraManagerGlobal::registerAvailCallback(const T *callback) {
cb.mPhysicalCamUnavailable;
msg->setPointer(kCallbackFpKey, (void *) cbFunc);
msg->setPointer(kContextKey, cb.mContext);
- msg->setString(kCameraIdKey, AString(cameraId));
- msg->setString(kPhysicalCameraIdKey, AString(physicalCameraId));
+ msg->setString(kCameraIdKey, AString(cameraId.c_str()));
+ msg->setString(kPhysicalCameraIdKey, AString(physicalCameraId.c_str()));
mPendingCallbackCnt++;
msg->post();
}
@@ -295,11 +296,11 @@ void CameraManagerGlobal::registerAvailCallback(const T *callback) {
}
}
-bool CameraManagerGlobal::supportsCamera2ApiLocked(const String8 &cameraId) {
+bool CameraManagerGlobal::supportsCamera2ApiLocked(const std::string &cameraId) {
bool camera2Support = false;
auto cs = getCameraServiceLocked();
binder::Status serviceRet =
- cs->supportsCameraApi(String16(cameraId),
+ cs->supportsCameraApi(cameraId,
hardware::ICameraService::API_VERSION_2, &camera2Support);
if (!serviceRet.isOk()) {
ALOGE("%s: supportsCameraApi2Locked() call failed for cameraId %s",
@@ -309,7 +310,7 @@ bool CameraManagerGlobal::supportsCamera2ApiLocked(const String8 &cameraId) {
return camera2Support;
}
-void CameraManagerGlobal::getCameraIdList(std::vector* cameraIds) {
+void CameraManagerGlobal::getCameraIdList(std::vector* cameraIds) {
// Ensure that we have initialized/refreshed the list of available devices
Mutex::Autolock _l(mLock);
// Needed to make sure we're connected to cameraservice
@@ -459,10 +460,10 @@ binder::Status CameraManagerGlobal::CameraServiceListener::onCameraAccessPriorit
}
binder::Status CameraManagerGlobal::CameraServiceListener::onStatusChanged(
- int32_t status, const String16& cameraId) {
+ int32_t status, const std::string& cameraId) {
sp cm = mCameraManager.promote();
if (cm != nullptr) {
- cm->onStatusChanged(status, String8(cameraId));
+ cm->onStatusChanged(status, cameraId);
} else {
ALOGE("Cannot deliver status change. Global camera manager died");
}
@@ -470,10 +471,10 @@ binder::Status CameraManagerGlobal::CameraServiceListener::onStatusChanged(
}
binder::Status CameraManagerGlobal::CameraServiceListener::onPhysicalCameraStatusChanged(
- int32_t status, const String16& cameraId, const String16& physicalCameraId) {
+ int32_t status, const std::string& cameraId, const std::string& physicalCameraId) {
sp cm = mCameraManager.promote();
if (cm != nullptr) {
- cm->onStatusChanged(status, String8(cameraId), String8(physicalCameraId));
+ cm->onStatusChanged(status, cameraId, physicalCameraId);
} else {
ALOGE("Cannot deliver physical camera status change. Global camera manager died");
}
@@ -495,13 +496,13 @@ void CameraManagerGlobal::onCameraAccessPrioritiesChanged() {
}
void CameraManagerGlobal::onStatusChanged(
- int32_t status, const String8& cameraId) {
+ int32_t status, const std::string& cameraId) {
Mutex::Autolock _l(mLock);
onStatusChangedLocked(status, cameraId);
}
void CameraManagerGlobal::onStatusChangedLocked(
- int32_t status, const String8& cameraId) {
+ int32_t status, const std::string& cameraId) {
if (!validStatus(status)) {
ALOGE("%s: Invalid status %d", __FUNCTION__, status);
return;
@@ -534,7 +535,7 @@ void CameraManagerGlobal::onStatusChangedLocked(
cb.mAvailable : cb.mUnavailable;
msg->setPointer(kCallbackFpKey, (void *) cbFp);
msg->setPointer(kContextKey, cb.mContext);
- msg->setString(kCameraIdKey, AString(cameraId));
+ msg->setString(kCameraIdKey, AString(cameraId.c_str()));
mPendingCallbackCnt++;
msg->post();
}
@@ -545,13 +546,13 @@ void CameraManagerGlobal::onStatusChangedLocked(
}
void CameraManagerGlobal::onStatusChanged(
- int32_t status, const String8& cameraId, const String8& physicalCameraId) {
+ int32_t status, const std::string& cameraId, const std::string& physicalCameraId) {
Mutex::Autolock _l(mLock);
onStatusChangedLocked(status, cameraId, physicalCameraId);
}
void CameraManagerGlobal::onStatusChangedLocked(
- int32_t status, const String8& cameraId, const String8& physicalCameraId) {
+ int32_t status, const std::string& cameraId, const std::string& physicalCameraId) {
if (!validStatus(status)) {
ALOGE("%s: Invalid status %d", __FUNCTION__, status);
return;
@@ -567,7 +568,7 @@ void CameraManagerGlobal::onStatusChangedLocked(
if (logicalCamStatus != hardware::ICameraServiceListener::STATUS_PRESENT &&
logicalCamStatus != hardware::ICameraServiceListener::STATUS_NOT_AVAILABLE) {
ALOGE("%s: Physical camera id %s status %d change for an invalid logical camera state %d",
- __FUNCTION__, physicalCameraId.string(), status, logicalCamStatus);
+ __FUNCTION__, physicalCameraId.c_str(), status, logicalCamStatus);
return;
}
@@ -588,8 +589,8 @@ void CameraManagerGlobal::onStatusChangedLocked(
cb.mPhysicalCamAvailable : cb.mPhysicalCamUnavailable;
msg->setPointer(kCallbackFpKey, (void *) cbFp);
msg->setPointer(kContextKey, cb.mContext);
- msg->setString(kCameraIdKey, AString(cameraId));
- msg->setString(kPhysicalCameraIdKey, AString(physicalCameraId));
+ msg->setString(kCameraIdKey, AString(cameraId.c_str()));
+ msg->setString(kPhysicalCameraIdKey, AString(physicalCameraId.c_str()));
mPendingCallbackCnt++;
msg->post();
}
@@ -607,20 +608,20 @@ void CameraManagerGlobal::StatusAndHAL3Support::updateStatus(int32_t newStatus)
}
bool CameraManagerGlobal::StatusAndHAL3Support::addUnavailablePhysicalId(
- const String8& physicalCameraId) {
+ const std::string& physicalCameraId) {
std::lock_guard lock(mLock);
auto result = unavailablePhysicalIds.insert(physicalCameraId);
return result.second;
}
bool CameraManagerGlobal::StatusAndHAL3Support::removeUnavailablePhysicalId(
- const String8& physicalCameraId) {
+ const std::string& physicalCameraId) {
std::lock_guard lock(mLock);
auto count = unavailablePhysicalIds.erase(physicalCameraId);
return count > 0;
}
-std::set CameraManagerGlobal::StatusAndHAL3Support::getUnavailablePhysicalIds() {
+std::set CameraManagerGlobal::StatusAndHAL3Support::getUnavailablePhysicalIds() {
std::lock_guard lock(mLock);
return unavailablePhysicalIds;
}
@@ -635,7 +636,7 @@ camera_status_t
ACameraManager::getCameraIdList(ACameraIdList** cameraIdList) {
Mutex::Autolock _l(mLock);
- std::vector idList;
+ std::vector idList;
CameraManagerGlobal::getInstance()->getCameraIdList(&idList);
int numCameras = idList.size();
@@ -652,7 +653,7 @@ ACameraManager::getCameraIdList(ACameraIdList** cameraIdList) {
return ACAMERA_ERROR_NOT_ENOUGH_MEMORY;
}
for (int i = 0; i < numCameras; i++) {
- const char* src = idList[i].string();
+ const char* src = idList[i].c_str();
size_t dstSize = strlen(src) + 1;
char* dst = new char[dstSize];
if (!dst) {
@@ -694,7 +695,7 @@ camera_status_t ACameraManager::getCameraCharacteristics(
CameraMetadata rawMetadata;
int targetSdkVersion = android_get_application_target_sdk_version();
- binder::Status serviceRet = cs->getCameraCharacteristics(String16(cameraIdStr),
+ binder::Status serviceRet = cs->getCameraCharacteristics(cameraIdStr,
targetSdkVersion, /*overrideToPortrait*/false, &rawMetadata);
if (!serviceRet.isOk()) {
switch(serviceRet.serviceSpecificErrorCode()) {
@@ -706,7 +707,7 @@ camera_status_t ACameraManager::getCameraCharacteristics(
return ACAMERA_ERROR_INVALID_PARAMETER;
default:
ALOGE("Get camera characteristics from camera service failed: %s",
- serviceRet.toString8().string());
+ serviceRet.toString8().c_str());
return ACAMERA_ERROR_UNKNOWN; // should not reach here
}
}
@@ -745,12 +746,12 @@ ACameraManager::openCamera(
// No way to get package name from native.
// Send a zero length package name and let camera service figure it out from UID
binder::Status serviceRet = cs->connectDevice(
- callbacks, String16(cameraId), String16(""), {},
+ callbacks, cameraId, "", {},
hardware::ICameraService::USE_CALLING_UID, /*oomScoreOffset*/0,
targetSdkVersion, /*overrideToPortrait*/false, /*out*/&deviceRemote);
if (!serviceRet.isOk()) {
- ALOGE("%s: connect camera device failed: %s", __FUNCTION__, serviceRet.toString8().string());
+ ALOGE("%s: connect camera device failed: %s", __FUNCTION__, serviceRet.toString8().c_str());
// Convert serviceRet to camera_status_t
switch(serviceRet.serviceSpecificErrorCode()) {
case hardware::ICameraService::ERROR_DISCONNECTED:
diff --git a/camera/ndk/impl/ACameraManager.h b/camera/ndk/impl/ACameraManager.h
index 0dd79da2213751c216ca60ccdb0d2e1a176e12c1..c135d0f00b51ec0c956c11d1fb0339aac8d864a9 100644
--- a/camera/ndk/impl/ACameraManager.h
+++ b/camera/ndk/impl/ACameraManager.h
@@ -62,7 +62,7 @@ class CameraManagerGlobal final : public RefBase {
/**
* Return camera IDs that support camera2
*/
- void getCameraIdList(std::vector *cameraIds);
+ void getCameraIdList(std::vector *cameraIds);
private:
sp mCameraService;
@@ -87,23 +87,23 @@ class CameraManagerGlobal final : public RefBase {
class CameraServiceListener final : public hardware::BnCameraServiceListener {
public:
explicit CameraServiceListener(CameraManagerGlobal* cm) : mCameraManager(cm) {}
- virtual binder::Status onStatusChanged(int32_t status, const String16& cameraId);
+ virtual binder::Status onStatusChanged(int32_t status, const std::string& cameraId);
virtual binder::Status onPhysicalCameraStatusChanged(int32_t status,
- const String16& cameraId, const String16& physicalCameraId);
+ const std::string& cameraId, const std::string& physicalCameraId);
// Torch API not implemented yet
- virtual binder::Status onTorchStatusChanged(int32_t, const String16&) {
+ virtual binder::Status onTorchStatusChanged(int32_t, const std::string&) {
return binder::Status::ok();
}
- virtual binder::Status onTorchStrengthLevelChanged(const String16&, int32_t) {
+ virtual binder::Status onTorchStrengthLevelChanged(const std::string&, int32_t) {
return binder::Status::ok();
}
virtual binder::Status onCameraAccessPrioritiesChanged();
- virtual binder::Status onCameraOpened(const String16&, const String16&) {
+ virtual binder::Status onCameraOpened(const std::string&, const std::string&) {
return binder::Status::ok();
}
- virtual binder::Status onCameraClosed(const String16&) {
+ virtual binder::Status onCameraClosed(const std::string&) {
return binder::Status::ok();
}
@@ -203,20 +203,20 @@ class CameraManagerGlobal final : public RefBase {
sp getCameraServiceLocked();
void onCameraAccessPrioritiesChanged();
- void onStatusChanged(int32_t status, const String8& cameraId);
- void onStatusChangedLocked(int32_t status, const String8& cameraId);
- void onStatusChanged(int32_t status, const String8& cameraId, const String8& physicalCameraId);
- void onStatusChangedLocked(int32_t status, const String8& cameraId,
- const String8& physicalCameraId);
+ void onStatusChanged(int32_t status, const std::string& cameraId);
+ void onStatusChangedLocked(int32_t status, const std::string& cameraId);
+ void onStatusChanged(int32_t status, const std::string& cameraId, const std::string& physicalCameraId);
+ void onStatusChangedLocked(int32_t status, const std::string& cameraId,
+ const std::string& physicalCameraId);
// Utils for status
static bool validStatus(int32_t status);
static bool isStatusAvailable(int32_t status);
- bool supportsCamera2ApiLocked(const String8 &cameraId);
+ bool supportsCamera2ApiLocked(const std::string &cameraId);
// The sort logic must match the logic in
// libcameraservice/common/CameraProviderManager.cpp::getAPI1CompatibleCameraDeviceIds
struct CameraIdComparator {
- bool operator()(const String8& a, const String8& b) const {
+ bool operator()(const std::string& a, const std::string& b) const {
uint32_t aUint = 0, bUint = 0;
bool aIsUint = base::ParseUint(a.c_str(), &aUint);
bool bIsUint = base::ParseUint(b.c_str(), &bUint);
@@ -238,22 +238,22 @@ class CameraManagerGlobal final : public RefBase {
private:
int32_t status = hardware::ICameraServiceListener::STATUS_NOT_PRESENT;
mutable std::mutex mLock;
- std::set unavailablePhysicalIds;
+ std::set unavailablePhysicalIds;
public:
const bool supportsHAL3 = false;
StatusAndHAL3Support(int32_t st, bool HAL3support):
status(st), supportsHAL3(HAL3support) { };
StatusAndHAL3Support() = default;
- bool addUnavailablePhysicalId(const String8& physicalCameraId);
- bool removeUnavailablePhysicalId(const String8& physicalCameraId);
+ bool addUnavailablePhysicalId(const std::string& physicalCameraId);
+ bool removeUnavailablePhysicalId(const std::string& physicalCameraId);
int32_t getStatus();
void updateStatus(int32_t newStatus);
- std::set getUnavailablePhysicalIds();
+ std::set getUnavailablePhysicalIds();
};
// Map camera_id -> status
- std::map mDeviceStatusMap;
+ std::map mDeviceStatusMap;
// For the singleton instance
static Mutex sLock;
diff --git a/camera/ndk/impl/ACameraMetadata.cpp b/camera/ndk/impl/ACameraMetadata.cpp
index 1fd4a864b649c908cdca16141b1b0716f07ca5cb..b6b8012762eb0cc586d33cfd8955c35355950804 100644
--- a/camera/ndk/impl/ACameraMetadata.cpp
+++ b/camera/ndk/impl/ACameraMetadata.cpp
@@ -142,7 +142,7 @@ ACameraMetadata::derivePhysicalCameraIds() {
if (ids[i] == '\0') {
if (start != i) {
mStaticPhysicalCameraIdValues.push_back(String8((const char *)ids+start));
- mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().string());
+ mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().c_str());
}
start = i+1;
}
@@ -540,6 +540,7 @@ ACameraMetadata::isCaptureRequestTag(const uint32_t tag) {
case ACAMERA_CONTROL_AUTOFRAMING:
case ACAMERA_EDGE_MODE:
case ACAMERA_FLASH_MODE:
+ case ACAMERA_FLASH_STRENGTH_LEVEL:
case ACAMERA_HOT_PIXEL_MODE:
case ACAMERA_JPEG_GPS_COORDINATES:
case ACAMERA_JPEG_GPS_PROCESSING_METHOD:
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index fe0ef679178974c448517cdb8fb0af06c5c2be3f..2c68cefd6a3e0eae881effc8ea2db756698cdbfa 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -2244,6 +2244,39 @@ typedef enum acamera_metadata_tag {
*/
ACAMERA_CONTROL_AUTOFRAMING_STATE = // byte (acamera_metadata_enum_android_control_autoframing_state_t)
ACAMERA_CONTROL_START + 54,
+ /**
+ * The operating luminance range of low light boost measured in lux (lx).
+ *
+ * Type: float[2]
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraManager_getCameraCharacteristics
+ *
+ *
+ */
+ ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE = // float[2]
+ ACAMERA_CONTROL_START + 55,
+ /**
+ * Current state of the low light boost AE mode.
+ *
+ * Type: byte (acamera_metadata_enum_android_control_low_light_boost_state_t)
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks
+ *
+ *
+ * When low light boost is enabled by setting the AE mode to
+ * 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY', it can dynamically apply a low light
+ * boost when the light level threshold is exceeded.
+ * This state indicates when low light boost is 'ACTIVE' and applied. Similarly, it can
+ * indicate when it is not being applied by returning 'INACTIVE'.
+ * This key will be absent from the CaptureResult if AE mode is not set to
+ * 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY.
+ */
+ ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE = // byte (acamera_metadata_enum_android_control_low_light_boost_state_t)
+ ACAMERA_CONTROL_START + 56,
ACAMERA_CONTROL_END,
/**
@@ -2364,6 +2397,125 @@ typedef enum acamera_metadata_tag {
*/
ACAMERA_FLASH_STATE = // byte (acamera_metadata_enum_android_flash_state_t)
ACAMERA_FLASH_START + 5,
+ /**
+ * Flash strength level to be used when manual flash control is active.
+ *
+ * Type: int32
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks
+ * - ACaptureRequest
+ *
+ *
+ * Flash strength level to use in capture mode i.e. when the applications control
+ * flash with either SINGLE or TORCH mode.
+ * Use android.flash.info.singleStrengthMaxLevel and
+ * android.flash.info.torchStrengthMaxLevel to check whether the device supports
+ * flash strength control or not.
+ * If the values of android.flash.info.singleStrengthMaxLevel and
+ * android.flash.info.torchStrengthMaxLevel are greater than 1,
+ * then the device supports manual flash strength control.
+ * If the ACAMERA_FLASH_MODE ==
TORCH the value must be >= 1
+ * and <= android.flash.info.torchStrengthMaxLevel.
+ * If the application doesn't set the key and
+ * android.flash.info.torchStrengthMaxLevel > 1,
+ * then the flash will be fired at the default level set by HAL in
+ * android.flash.info.torchStrengthDefaultLevel.
+ * If the ACAMERA_FLASH_MODE ==
SINGLE, then the value must be >= 1
+ * and <= android.flash.info.singleStrengthMaxLevel.
+ * If the application does not set this key and
+ * android.flash.info.singleStrengthMaxLevel > 1,
+ * then the flash will be fired at the default level set by HAL
+ * in android.flash.info.singleStrengthDefaultLevel.
+ * If ACAMERA_CONTROL_AE_MODE is set to any of ON_AUTO_FLASH, ON_ALWAYS_FLASH,
+ * ON_AUTO_FLASH_REDEYE, ON_EXTERNAL_FLASH values, then the strengthLevel will be ignored.
+ *
+ * @see ACAMERA_CONTROL_AE_MODE
+ * @see ACAMERA_FLASH_MODE
+ */
+ ACAMERA_FLASH_STRENGTH_LEVEL = // int32
+ ACAMERA_FLASH_START + 6,
+ /**
+ * Maximum flash brightness level for manual flash control in SINGLE mode.
+ *
+ * Type: int32
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraManager_getCameraCharacteristics
+ *
+ *
+ * Maximum flash brightness level in camera capture mode and
+ * ACAMERA_FLASH_MODE set to SINGLE.
+ * Value will be > 1 if the manual flash strength control feature is supported,
+ * otherwise the value will be equal to 1.
+ * Note that this level is just a number of supported levels (the granularity of control).
+ * There is no actual physical power units tied to this level.
+ *
+ * @see ACAMERA_FLASH_MODE
+ */
+ ACAMERA_FLASH_SINGLE_STRENGTH_MAX_LEVEL = // int32
+ ACAMERA_FLASH_START + 7,
+ /**
+ * Default flash brightness level for manual flash control in SINGLE mode.
+ *
+ * Type: int32
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraManager_getCameraCharacteristics
+ *
+ *
+ * If flash unit is available this will be greater than or equal to 1 and less
+ * or equal to android.flash.info.singleStrengthMaxLevel
.
+ * Note for devices that do not support the manual flash strength control
+ * feature, this level will always be equal to 1.
+ */
+ ACAMERA_FLASH_SINGLE_STRENGTH_DEFAULT_LEVEL = // int32
+ ACAMERA_FLASH_START + 8,
+ /**
+ * Maximum flash brightness level for manual flash control in TORCH mode
+ *
+ * Type: int32
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraManager_getCameraCharacteristics
+ *
+ *
+ * Maximum flash brightness level in camera capture mode and
+ * ACAMERA_FLASH_MODE set to TORCH.
+ * Value will be > 1 if the manual flash strength control feature is supported,
+ * otherwise the value will be equal to 1.
+ * Note that this level is just a number of supported levels(the granularity of control).
+ * There is no actual physical power units tied to this level.
+ * There is no relation between android.flash.info.torchStrengthMaxLevel and
+ * android.flash.info.singleStrengthMaxLevel i.e. the ratio of
+ * android.flash.info.torchStrengthMaxLevel:android.flash.info.singleStrengthMaxLevel
+ * is not guaranteed to be the ratio of actual brightness.
+ *
+ * @see ACAMERA_FLASH_MODE
+ */
+ ACAMERA_FLASH_TORCH_STRENGTH_MAX_LEVEL = // int32
+ ACAMERA_FLASH_START + 9,
+ /**
+ * Default flash brightness level for manual flash control in TORCH mode
+ *
+ * Type: int32
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraManager_getCameraCharacteristics
+ *
+ *
+ * If flash unit is available this will be greater than or equal to 1 and less
+ * or equal to android.flash.info.torchStrengthMaxLevel.
+ * Note for the devices that do not support the manual flash strength control feature,
+ * this level will always be equal to 1.
+ */
+ ACAMERA_FLASH_TORCH_STRENGTH_DEFAULT_LEVEL = // int32
+ ACAMERA_FLASH_START + 10,
ACAMERA_FLASH_END,
/**
@@ -4506,8 +4658,8 @@ typedef enum acamera_metadata_tag {
* The guaranteed stream combinations related to stream use case for a camera device with
* CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE
* capability is documented in the camera device
- * guideline. The application is strongly recommended to use one of the guaranteed stream
- * combinations.
+ * guideline.
+ * The application is strongly recommended to use one of the guaranteed stream combinations.
* If the application creates a session with a stream combination not in the guaranteed
* list, or with mixed DEFAULT and non-DEFAULT use cases within the same session,
* the camera device may ignore some stream use cases due to hardware constraints
@@ -4597,8 +4749,8 @@ typedef enum acamera_metadata_tag {
ACAMERA_SENSOR_EXPOSURE_TIME = // int64
ACAMERA_SENSOR_START,
/**
- *
Duration from start of frame exposure to
- * start of next frame exposure.
+ * Duration from start of frame readout to
+ * start of next frame readout.
*
* Type: int64
*
@@ -4668,6 +4820,10 @@ typedef enum acamera_metadata_tag {
* For more details about stalling, see {@link ACAMERA_SCALER_AVAILABLE_STALL_DURATIONS }.
* This control is only effective if ACAMERA_CONTROL_AE_MODE or ACAMERA_CONTROL_MODE is set to
* OFF; otherwise the auto-exposure algorithm will override this value.
+ * Note: Prior to Android 13, this field was described as measuring the duration from
+ * start of frame exposure to start of next frame exposure, which doesn't reflect the
+ * definition from sensor manufacturer. A mobile sensor defines the frame duration as
+ * intervals between sensor readouts.
*
* @see ACAMERA_CONTROL_AE_MODE
* @see ACAMERA_CONTROL_MODE
@@ -6371,6 +6527,40 @@ typedef enum acamera_metadata_tag {
*/
ACAMERA_STATISTICS_OIS_Y_SHIFTS = // float[n]
ACAMERA_STATISTICS_START + 20,
+ /**
+ * An array of timestamps of lens intrinsics samples, in nanoseconds.
+ *
+ * Type: int64[n]
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks
+ *
+ *
+ * The array contains the timestamps of lens intrinsics samples. The timestamps are in the
+ * same timebase as and comparable to ACAMERA_SENSOR_TIMESTAMP.
+ *
+ * @see ACAMERA_SENSOR_TIMESTAMP
+ */
+ ACAMERA_STATISTICS_LENS_INTRINSIC_TIMESTAMPS = // int64[n]
+ ACAMERA_STATISTICS_START + 21,
+ /**
+ * An array of intra-frame lens intrinsics.
+ *
+ * Type: float[5*n]
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks
+ *
+ *
+ * The data layout and contents of individual array entries matches with
+ * ACAMERA_LENS_INTRINSIC_CALIBRATION.
+ *
+ * @see ACAMERA_LENS_INTRINSIC_CALIBRATION
+ */
+ ACAMERA_STATISTICS_LENS_INTRINSIC_SAMPLES = // float[5*n]
+ ACAMERA_STATISTICS_START + 22,
ACAMERA_STATISTICS_END,
/**
@@ -7345,6 +7535,54 @@ typedef enum acamera_metadata_tag {
*/
ACAMERA_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID = // byte
ACAMERA_LOGICAL_MULTI_CAMERA_START + 2,
+ /**
+ * The current region of the active physical sensor that will be read out for this
+ * capture.
+ *
+ * Type: int32[4]
+ *
+ * This tag may appear in:
+ *
+ * - ACameraMetadata from ACameraCaptureSession_captureCallback_result callbacks
+ *
+ *
+ * This capture result matches with ACAMERA_SCALER_CROP_REGION on non-logical single
+ * camera sensor devices. In case of logical cameras that can switch between several
+ * physical devices in response to ACAMERA_CONTROL_ZOOM_RATIO, this capture result will
+ * not behave like ACAMERA_SCALER_CROP_REGION and ACAMERA_CONTROL_ZOOM_RATIO, where the
+ * combination of both reflects the effective zoom and crop of the logical camera output.
+ * Instead, this capture result value will describe the zoom and crop of the active physical
+ * device. Some examples of when the value of this capture result will change include
+ * switches between different physical lenses, switches between regular and maximum
+ * resolution pixel mode and going through the device digital or optical range.
+ * This capture result is similar to ACAMERA_SCALER_CROP_REGION with respect to distortion
+ * correction. When the distortion correction mode is OFF, the coordinate system follows
+ * ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, with (0, 0) being the top-left pixel
+ * of the pre-correction active array. When the distortion correction mode is not OFF,
+ * the coordinate system follows ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE, with (0, 0) being
+ * the top-left pixel of the active array.
+ * For camera devices with the
+ * CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_ULTRA_HIGH_RESOLUTION_SENSOR
+ * capability or devices where CameraCharacteristics#getAvailableCaptureRequestKeys
+ * lists ACAMERA_SENSOR_PIXEL_MODE
+ * , the current active physical device
+ * ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION /
+ * ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION must be used as the
+ * coordinate system for requests where ACAMERA_SENSOR_PIXEL_MODE is set to
+ * CameraMetadata#SENSOR_PIXEL_MODE_MAXIMUM_RESOLUTION.
+ * The data representation is int[4], which maps to (left, top, width, height).
+ *
+ * @see ACAMERA_CONTROL_ZOOM_RATIO
+ * @see ACAMERA_SCALER_CROP_REGION
+ * @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE
+ * @see ACAMERA_SENSOR_INFO_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ * @see ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE
+ * @see ACAMERA_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE_MAXIMUM_RESOLUTION
+ * @see ACAMERA_SENSOR_PIXEL_MODE
+ */
+ ACAMERA_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION =
+ // int32[4]
+ ACAMERA_LOGICAL_MULTI_CAMERA_START + 3,
ACAMERA_LOGICAL_MULTI_CAMERA_END,
/**
@@ -8009,6 +8247,44 @@ typedef enum acamera_metadata_enum_acamera_control_ae_mode {
*/
ACAMERA_CONTROL_AE_MODE_ON_EXTERNAL_FLASH = 5,
+ /**
+ * Like 'ON' but applies additional brightness boost in low light scenes.
+ * When the scene lighting conditions are within the range defined by
+ * ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE this mode will apply additional
+ * brightness boost.
+ * This mode will automatically adjust the intensity of low light boost applied
+ * according to the scene lighting conditions. A darker scene will receive more boost
+ * while a brighter scene will receive less boost.
+ * This mode can ignore the set target frame rate to allow more light to be captured
+ * which can result in choppier motion. The frame rate can extend to lower than the
+ * ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES but will not go below 10 FPS. This mode
+ * can also increase the sensor sensitivity gain which can result in increased luma
+ * and chroma noise. The sensor sensitivity gain can extend to higher values beyond
+ * ACAMERA_SENSOR_INFO_SENSITIVITY_RANGE. This mode may also apply additional
+ * processing to recover details in dark and bright areas of the image,and noise
+ * reduction at high sensitivity gain settings to manage the trade-off between light
+ * sensitivity and capture noise.
+ * This mode is restricted to two output surfaces. One output surface type can either
+ * be SurfaceView or TextureView. Another output surface type can either be MediaCodec
+ * or MediaRecorder. This mode cannot be used with a target FPS range higher than 30
+ * FPS.
+ * If the session configuration is not supported, the AE mode reported in the
+ * CaptureResult will be 'ON' instead of 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY'.
+ * The application can observe the CapturerResult field
+ * ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE to determine when low light boost is 'ACTIVE' or
+ * 'INACTIVE'.
+ * The low light boost is 'ACTIVE' once the scene lighting condition is less than the
+ * upper bound lux value defined by ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE.
+ * This mode will be 'INACTIVE' once the scene lighting condition is greater than the
+ * upper bound lux value defined by ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE.
+ *
+ * @see ACAMERA_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
+ * @see ACAMERA_CONTROL_LOW_LIGHT_BOOST_INFO_LUMINANCE_RANGE
+ * @see ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE
+ * @see ACAMERA_SENSOR_INFO_SENSITIVITY_RANGE
+ */
+ ACAMERA_CONTROL_AE_MODE_ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY = 6,
+
} acamera_metadata_enum_android_control_ae_mode_t;
// ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER
@@ -9010,6 +9286,20 @@ typedef enum acamera_metadata_enum_acamera_control_autoframing_state {
} acamera_metadata_enum_android_control_autoframing_state_t;
+// ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE
+typedef enum acamera_metadata_enum_acamera_control_low_light_boost_state {
+ /**
+ * The AE mode 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY' is enabled but not applied.
+ */
+ ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE_INACTIVE = 0,
+
+ /**
+ * The AE mode 'ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY' is enabled and applied.
+ */
+ ACAMERA_CONTROL_LOW_LIGHT_BOOST_STATE_ACTIVE = 1,
+
+} acamera_metadata_enum_android_control_low_light_boost_state_t;
+
// ACAMERA_EDGE_MODE
@@ -9885,8 +10175,8 @@ typedef enum acamera_metadata_enum_acamera_request_available_capabilities {
*
* CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES
* lists all of the supported stream use cases.
- * Refer to
- * CameraDevice#stream-use-case-capability-additional-guaranteed-configurations
+ *
Refer to the
+ * guideline
* for the mandatory stream combinations involving stream use cases, which can also be
* queried via MandatoryStreamCombination.
*/
@@ -10747,9 +11037,9 @@ typedef enum acamera_metadata_enum_acamera_info_supported_hardware_level {
/**
* This camera device does not have enough capabilities to qualify as a FULL
device or
* better.
- * Only the stream configurations listed in the LEGACY
and LIMITED
tables in the
- * {@link ACameraDevice_createCaptureSession }
- * documentation are guaranteed to be supported.
+ * Only the stream configurations listed in the LEGACY
and LIMITED
+ * tables
+ * in the documentation are guaranteed to be supported.
* All LIMITED
devices support the BACKWARDS_COMPATIBLE
capability, indicating basic
* support for color image capture. The only exception is that the device may
* alternatively support only the DEPTH_OUTPUT
capability, if it can only output depth
@@ -10774,9 +11064,9 @@ typedef enum acamera_metadata_enum_acamera_info_supported_hardware_level {
/**
*
This camera device is capable of supporting advanced imaging applications.
- * The stream configurations listed in the FULL
, LEGACY
and LIMITED
tables in the
- * {@link ACameraDevice_createCaptureSession }
- * documentation are guaranteed to be supported.
+ * The stream configurations listed in the FULL
, LEGACY
and LIMITED
+ * tables
+ * in the documentation are guaranteed to be supported.
* A FULL
device will support below capabilities:
*
* BURST_CAPTURE
capability (ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
@@ -10803,9 +11093,9 @@ typedef enum acamera_metadata_enum_acamera_info_supported_hardware_level {
/**
* This camera device is running in backward compatibility mode.
- * Only the stream configurations listed in the LEGACY
table in the
- * {@link ACameraDevice_createCaptureSession }
- * documentation are supported.
+ * Only the stream configurations listed in the LEGACY
+ * table
+ * in the documentation are supported.
* A LEGACY
device does not support per-frame control, manual sensor control, manual
* post-processing, arbitrary cropping regions, and has relaxed performance constraints.
* No additional capabilities beyond BACKWARD_COMPATIBLE
will ever be listed by a
@@ -10827,9 +11117,9 @@ typedef enum acamera_metadata_enum_acamera_info_supported_hardware_level {
*
This camera device is capable of YUV reprocessing and RAW data capture, in addition to
* FULL-level capabilities.
* The stream configurations listed in the LEVEL_3
, RAW
, FULL
, LEGACY
and
- * LIMITED
tables in the
- * {@link ACameraDevice_createCaptureSession }
- * documentation are guaranteed to be supported.
+ * LIMITED
+ * tables
+ * in the documentation are guaranteed to be supported.
* The following additional capabilities are guaranteed to be supported:
*
* YUV_REPROCESSING
capability (ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
diff --git a/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp b/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
index 7f6ea9d2dba7419046a3c82b0029da8f9e30c455..74c6cad216c9534712059e647a0598b41a3e99ef 100644
--- a/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
+++ b/camera/ndk/ndk_vendor/tests/AImageReaderVendorTest.cpp
@@ -31,10 +31,13 @@
#include
#include
+#include
+#include
#include
#include
#include
#include
+#include
#include
#include
#include
@@ -50,6 +53,8 @@ static constexpr int kTestImageHeight = 480;
static constexpr int kTestImageFormat = AIMAGE_FORMAT_YUV_420_888;
using android::hardware::camera::common::V1_0::helper::VendorTagDescriptorCache;
+using android::hidl::manager::V1_0::IServiceManager;
+using android::hidl::token::V1_0::ITokenManager;
using ConfiguredWindows = std::set;
class CameraHelper {
@@ -981,11 +986,19 @@ class AImageReaderVendorTest : public ::testing::Test {
TEST_F(AImageReaderVendorTest, CreateWindowNativeHandle) {
+ auto transport = android::hardware::defaultServiceManager()->getTransport(ITokenManager::descriptor, "default");
+ if (transport.isOk() && transport == IServiceManager::Transport::EMPTY) {
+ GTEST_SKIP() << "This device no longer supports AImageReader_getWindowNativeHandle";
+ }
testBasicTakePictures(/*prepareSurfaces*/ false);
testBasicTakePictures(/*prepareSurfaces*/ true);
}
TEST_F(AImageReaderVendorTest, LogicalCameraPhysicalStream) {
+ auto transport = android::hardware::defaultServiceManager()->getTransport(ITokenManager::descriptor, "default");
+ if (transport.isOk() && transport == IServiceManager::Transport::EMPTY) {
+ GTEST_SKIP() << "This device no longer supports AImageReader_getWindowNativeHandle";
+ }
for (auto & v2 : {true, false}) {
testLogicalCameraPhysicalStream(false/*usePhysicalSettings*/, v2);
testLogicalCameraPhysicalStream(true/*usePhysicalSettings*/, v2);
diff --git a/camera/tests/CameraBinderTests.cpp b/camera/tests/CameraBinderTests.cpp
index 1af5637f8747aad74094181aab29e3664a378f5a..bb963abb5f67949c02496f7f52e139ea178ea943 100644
--- a/camera/tests/CameraBinderTests.cpp
+++ b/camera/tests/CameraBinderTests.cpp
@@ -43,6 +43,7 @@
#include
#include
#include
+#include
#include
#include
@@ -68,15 +69,15 @@ using ::android::hardware::camera2::ICameraDeviceUser;
// Stub listener implementation
class TestCameraServiceListener : public hardware::BnCameraServiceListener {
- std::map mCameraTorchStatuses;
- std::map mCameraStatuses;
+ std::map mCameraTorchStatuses;
+ std::map mCameraStatuses;
mutable Mutex mLock;
mutable Condition mCondition;
mutable Condition mTorchCondition;
public:
virtual ~TestCameraServiceListener() {};
- virtual binder::Status onStatusChanged(int32_t status, const String16& cameraId) {
+ virtual binder::Status onStatusChanged(int32_t status, const std::string& cameraId) override {
Mutex::Autolock l(mLock);
mCameraStatuses[cameraId] = status;
mCondition.broadcast();
@@ -84,36 +85,37 @@ public:
};
virtual binder::Status onPhysicalCameraStatusChanged(int32_t /*status*/,
- const String16& /*cameraId*/, const String16& /*physicalCameraId*/) {
+ const std::string& /*cameraId*/, const std::string& /*physicalCameraId*/) override {
// No op
return binder::Status::ok();
};
- virtual binder::Status onTorchStatusChanged(int32_t status, const String16& cameraId) {
+ virtual binder::Status onTorchStatusChanged(int32_t status,
+ const std::string& cameraId) override {
Mutex::Autolock l(mLock);
mCameraTorchStatuses[cameraId] = status;
mTorchCondition.broadcast();
return binder::Status::ok();
};
- virtual binder::Status onTorchStrengthLevelChanged(const String16& /*cameraId*/,
- int32_t /*torchStrength*/) {
+ virtual binder::Status onTorchStrengthLevelChanged(const std::string& /*cameraId*/,
+ int32_t /*torchStrength*/) override {
// No op
return binder::Status::ok();
}
- virtual binder::Status onCameraAccessPrioritiesChanged() {
+ virtual binder::Status onCameraAccessPrioritiesChanged() override {
// No op
return binder::Status::ok();
}
- virtual binder::Status onCameraOpened(const String16& /*cameraId*/,
- const String16& /*clientPackageName*/) {
+ virtual binder::Status onCameraOpened(const std::string& /*cameraId*/,
+ const std::string& /*clientPackageName*/) {
// No op
return binder::Status::ok();
}
- virtual binder::Status onCameraClosed(const String16& /*cameraId*/) {
+ virtual binder::Status onCameraClosed(const std::string& /*cameraId*/) override {
// No op
return binder::Status::ok();
}
@@ -136,7 +138,7 @@ public:
bool waitForTorchState(int32_t status, int32_t cameraId) const {
Mutex::Autolock l(mLock);
- const auto& iter = mCameraTorchStatuses.find(String16(String8::format("%d", cameraId)));
+ const auto& iter = mCameraTorchStatuses.find(std::to_string(cameraId));
if (iter != mCameraTorchStatuses.end() && iter->second == status) {
return true;
}
@@ -147,7 +149,7 @@ public:
return false;
}
const auto& iter =
- mCameraTorchStatuses.find(String16(String8::format("%d", cameraId)));
+ mCameraTorchStatuses.find(std::to_string(cameraId));
foundStatus = (iter != mCameraTorchStatuses.end() && iter->second == status);
}
return true;
@@ -155,14 +157,14 @@ public:
int32_t getTorchStatus(int32_t cameraId) const {
Mutex::Autolock l(mLock);
- const auto& iter = mCameraTorchStatuses.find(String16(String8::format("%d", cameraId)));
+ const auto& iter = mCameraTorchStatuses.find(std::to_string(cameraId));
if (iter == mCameraTorchStatuses.end()) {
return hardware::ICameraServiceListener::TORCH_STATUS_UNKNOWN;
}
return iter->second;
};
- int32_t getStatus(const String16& cameraId) const {
+ int32_t getStatus(const std::string& cameraId) const {
Mutex::Autolock l(mLock);
const auto& iter = mCameraStatuses.find(cameraId);
if (iter == mCameraStatuses.end()) {
@@ -352,11 +354,11 @@ TEST(CameraServiceBinderTest, CheckBinderCameraService) {
EXPECT_EQ(numCameras, static_cast(statuses.size()));
for (const auto &it : statuses) {
- listener->onStatusChanged(it.status, String16(it.cameraId));
+ listener->onStatusChanged(it.status, it.cameraId);
}
for (int32_t i = 0; i < numCameras; i++) {
- String16 cameraId = String16(String8::format("%d", i));
+ std::string cameraId = std::to_string(i);
bool isSupported = false;
res = service->supportsCameraApi(cameraId,
hardware::ICameraService::API_VERSION_2, &isSupported);
@@ -384,7 +386,7 @@ TEST(CameraServiceBinderTest, CheckBinderCameraService) {
// Check connect binder calls
sp callbacks(new TestCameraDeviceCallbacks());
sp device;
- res = service->connectDevice(callbacks, cameraId, String16("meeeeeeeee!"),
+ res = service->connectDevice(callbacks, cameraId, "meeeeeeeee!",
{}, hardware::ICameraService::USE_CALLING_UID, /*oomScoreOffset*/ 0,
/*targetSdkVersion*/__ANDROID_API_FUTURE__,
/*overrideToPortrait*/false, /*out*/&device);
@@ -423,12 +425,12 @@ protected:
sp serviceListener;
std::pair, sp>
- openNewDevice(const String16& deviceId) {
+ openNewDevice(const std::string& deviceId) {
sp callbacks(new TestCameraDeviceCallbacks());
sp device;
{
SCOPED_TRACE("openNewDevice");
- binder::Status res = service->connectDevice(callbacks, deviceId, String16("meeeeeeeee!"),
+ binder::Status res = service->connectDevice(callbacks, deviceId, "meeeeeeeee!",
{}, hardware::ICameraService::USE_CALLING_UID, /*oomScoreOffset*/ 0,
/*targetSdkVersion*/__ANDROID_API_FUTURE__,
/*overrideToPortrait*/false, /*out*/&device);
@@ -464,7 +466,7 @@ protected:
std::vector statuses;
service->addListener(serviceListener, &statuses);
for (const auto &it : statuses) {
- serviceListener->onStatusChanged(it.status, String16(it.cameraId));
+ serviceListener->onStatusChanged(it.status, it.cameraId);
}
service->getNumberOfCameras(hardware::ICameraService::CAMERA_TYPE_BACKWARD_COMPATIBLE,
&numCameras);
@@ -484,9 +486,8 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
ASSERT_NOT_NULL(service);
EXPECT_TRUE(serviceListener->waitForNumCameras(numCameras));
for (int32_t i = 0; i < numCameras; i++) {
- String8 cameraId8 = String8::format("%d", i);
+ std::string cameraId = std::to_string(i);
// Make sure we're available, or skip device tests otherwise
- String16 cameraId(cameraId8);
int32_t s = serviceListener->getStatus(cameraId);
EXPECT_EQ(hardware::ICameraServiceListener::STATUS_PRESENT, s);
if (s != hardware::ICameraServiceListener::STATUS_PRESENT) {
@@ -513,7 +514,7 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
sp surface(new Surface(gbProducer, /*controlledByApp*/false));
- String16 noPhysicalId;
+ std::string noPhysicalId;
OutputConfiguration output(gbProducer, /*rotation*/0, noPhysicalId);
// Can we configure?
@@ -550,7 +551,7 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
EXPECT_TRUE(res.isOk()) << res;
hardware::camera2::CaptureRequest request;
- request.mPhysicalCameraSettings.push_back({cameraId8.string(), requestTemplate});
+ request.mPhysicalCameraSettings.push_back({cameraId, requestTemplate});
request.mSurfaceList.add(surface);
request.mIsReprocess = false;
int64_t lastFrameNumber = 0;
@@ -577,7 +578,7 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
/*out*/&requestTemplate);
EXPECT_TRUE(res.isOk()) << res;
hardware::camera2::CaptureRequest request2;
- request2.mPhysicalCameraSettings.push_back({cameraId8.string(), requestTemplate});
+ request2.mPhysicalCameraSettings.push_back({cameraId, requestTemplate});
request2.mSurfaceList.add(surface);
request2.mIsReprocess = false;
callbacks->clearStatus();
@@ -610,10 +611,10 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
EXPECT_TRUE(res.isOk()) << res;
android::hardware::camera2::CaptureRequest request3;
android::hardware::camera2::CaptureRequest request4;
- request3.mPhysicalCameraSettings.push_back({cameraId8.string(), requestTemplate});
+ request3.mPhysicalCameraSettings.push_back({cameraId, requestTemplate});
request3.mSurfaceList.add(surface);
request3.mIsReprocess = false;
- request4.mPhysicalCameraSettings.push_back({cameraId8.string(), requestTemplate2});
+ request4.mPhysicalCameraSettings.push_back({cameraId, requestTemplate2});
request4.mSurfaceList.add(surface);
request4.mIsReprocess = false;
std::vector requestList;
diff --git a/camera/tests/CameraCharacteristicsPermission.cpp b/camera/tests/CameraCharacteristicsPermission.cpp
index f2fa48c493ce6c5715c470b207974a1d158217e3..1de7cb4a226caba1c8ae756be958d4d54ec0e5db 100644
--- a/camera/tests/CameraCharacteristicsPermission.cpp
+++ b/camera/tests/CameraCharacteristicsPermission.cpp
@@ -62,7 +62,7 @@ void CameraCharacteristicsPermission::TearDown() {
TEST_F(CameraCharacteristicsPermission, TestCameraPermission) {
for (int32_t cameraId = 0; cameraId < numCameras; cameraId++) {
- String16 cameraIdStr = String16(String8::format("%d", cameraId));
+ std::string cameraIdStr = std::to_string(cameraId);
bool isSupported = false;
auto rc = mCameraService->supportsCameraApi(cameraIdStr,
hardware::ICameraService::API_VERSION_2, &isSupported);
diff --git a/camera/tests/CameraZSLTests.cpp b/camera/tests/CameraZSLTests.cpp
index 64237096e3aaeecebed52e9db7ecf6b47109bdd6..3ae76595554241b9d5c03db02af2fb2879e63ae0 100644
--- a/camera/tests/CameraZSLTests.cpp
+++ b/camera/tests/CameraZSLTests.cpp
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
using namespace android;
@@ -169,7 +170,7 @@ TEST_F(CameraZSLTests, TestAllPictureSizes) {
sp surfaceControl;
sp cameraDevice;
- String16 cameraIdStr = String16(String8::format("%d", cameraId));
+ std::string cameraIdStr = std::to_string(cameraId);
bool isSupported = false;
rc = mCameraService->supportsCameraApi(cameraIdStr,
hardware::ICameraService::API_VERSION_1, &isSupported);
@@ -208,7 +209,7 @@ TEST_F(CameraZSLTests, TestAllPictureSizes) {
}
rc = mCameraService->connect(this, cameraId,
- String16("ZSLTest"), hardware::ICameraService::USE_CALLING_UID,
+ "ZSLTest", hardware::ICameraService::USE_CALLING_UID,
hardware::ICameraService::USE_CALLING_PID,
/*targetSdkVersion*/__ANDROID_API_FUTURE__,
/*overrideToPortrait*/false, /*forceSlowJpegMode*/false, &cameraDevice);
diff --git a/camera/tests/fuzzer/Android.bp b/camera/tests/fuzzer/Android.bp
index bae870651dd6f90ee94b5f095c910effc6313a6b..b74b7a10dc24e1b03c8841ea2923218a359722e4 100644
--- a/camera/tests/fuzzer/Android.bp
+++ b/camera/tests/fuzzer/Android.bp
@@ -26,8 +26,10 @@ cc_defaults {
name: "camera_defaults",
static_libs: [
"libcamera_client",
+ "libbinder_random_parcel",
],
shared_libs: [
+ "camera_platform_flags_c_lib",
"libbase",
"libcutils",
"libutils",
@@ -37,11 +39,22 @@ cc_defaults {
"libcamera_metadata",
"libnativewindow",
],
+ header_libs: [
+ "libbinder_headers",
+ ],
fuzz_config: {
cc: [
- "android-media-fuzzing-reports@google.com",
+ "android-camera-fwk-eng@google.com",
+ ],
+ componentid: 41727,
+ hotlists: [
+ "4593311",
],
- componentid: 155276,
+ description: "The fuzzer targets the APIs of libcamera_client",
+ vector: "local_no_privileges_required",
+ service_privilege: "privileged",
+ users: "multi_user",
+ fuzzed_code_usage: "shipped",
},
}
@@ -148,3 +161,23 @@ cc_fuzz {
"camera_defaults",
],
}
+
+cc_fuzz {
+ name: "camera_utils_fuzzer",
+ srcs: [
+ "camera_utils_fuzzer.cpp",
+ ],
+ defaults: [
+ "camera_defaults",
+ ],
+}
+
+cc_fuzz {
+ name: "camera_metadata_fuzzer",
+ srcs: [
+ "camera_metadata_fuzzer.cpp",
+ ],
+ defaults: [
+ "camera_defaults",
+ ],
+}
diff --git a/camera/tests/fuzzer/README.md b/camera/tests/fuzzer/README.md
index c07ac04928446a26d9bd833277589518efebca4c..96557f8494536fa3d8ec851b4618ee7792286c6c 100644
--- a/camera/tests/fuzzer/README.md
+++ b/camera/tests/fuzzer/README.md
@@ -52,6 +52,8 @@ Build the fuzzer
$ mm -j$(nproc) camera_Parameters_fuzzer
$ mm -j$(nproc) camera_SessionStats_fuzzer
$ mm -j$(nproc) camera_captureResult_fuzzer
+ $ mm -j$(nproc) camera_utils_fuzzer
+ $ mm -j$(nproc) camera_metadata_fuzzer
```
#### Steps to run
To run on device
@@ -67,6 +69,8 @@ To run on device
$ adb shell /data/fuzz/${TARGET_ARCH}/camera_Parameters_fuzzer/camera_Parameters_fuzzer
$ adb shell /data/fuzz/${TARGET_ARCH}/camera_SessionStats_fuzzer/camera_SessionStats_fuzzer
$ adb shell /data/fuzz/${TARGET_ARCH}/camera_captureResult_fuzzer/camera_captureResult_fuzzer
+ $ adb shell /data/fuzz/${TARGET_ARCH}/camera_utils_fuzzer/camera_utils_fuzzer
+ $ adb shell /data/fuzz/${TARGET_ARCH}/camera_metadata_fuzzer/camera_metadata_fuzzer
```
## References:
diff --git a/camera/tests/fuzzer/camera2common.h b/camera/tests/fuzzer/camera2common.h
index 14a1b1b4427681b628fc751ca2d142ab478e7c85..c82e74d3b85328dc31b132fa984fc18a7596645c 100644
--- a/camera/tests/fuzzer/camera2common.h
+++ b/camera/tests/fuzzer/camera2common.h
@@ -16,10 +16,93 @@
#ifndef CAMERA2COMMON_H
#define CAMERA2COMMON_H
+#include
+#include
+#include
#include
+#include
+#include
+#include
+#include
+#include
using namespace android;
+const std::string kFetchCameraService = "media.camera";
+
+constexpr int8_t kMinIterations = 0;
+constexpr int8_t kMaxIterations = 20;
+constexpr int8_t kMinExtraFDs = 0;
+constexpr int8_t kMinExtraBinder = 0;
+constexpr int32_t kMaxFDs = 1000;
+constexpr int32_t kMinBytes = 0;
+constexpr int32_t kMaxBytes = 20;
+constexpr int32_t kMinCapacity = 1;
+constexpr int32_t kMaxCapacity = 1000;
+
+const int32_t kValidFacing[] = {android::hardware::CameraSessionStats::CAMERA_FACING_BACK,
+ android::hardware::CameraSessionStats::CAMERA_FACING_FRONT};
+const int32_t kValidOrientation[] = {0, 90, 180, 270};
+
+void randomizeParcel(Parcel* parcel, FuzzedDataProvider& provider) {
+ sp sm = defaultServiceManager();
+ sp binder = sm->getService(String16(kFetchCameraService.c_str()));
+ RandomParcelOptions options{
+ .extraBinders = {binder},
+ .extraFds = {},
+ };
+
+ auto retFds = parcel->debugReadAllFileDescriptors();
+ for (size_t i = 0; i < retFds.size(); ++i) {
+ options.extraFds.push_back(base::unique_fd(dup(retFds[i])));
+ }
+ int8_t iterations = provider.ConsumeIntegralInRange(kMinIterations, kMaxIterations);
+ while (--iterations >= 0) {
+ auto fillFunc = provider.PickValueInArray>({
+ // write data
+ [&]() {
+ size_t toWrite = provider.ConsumeIntegralInRange(kMinBytes, kMaxBytes);
+ std::vector data = provider.ConsumeBytes(toWrite);
+ CHECK(OK == parcel->write(data.data(), data.size()));
+ },
+ // write FD
+ [&]() {
+ if (options.extraFds.size() > 0 && provider.ConsumeBool()) {
+ const base::unique_fd& fd =
+ options.extraFds.at(provider.ConsumeIntegralInRange(
+ kMinExtraFDs, options.extraFds.size() - 1));
+ CHECK(OK == parcel->writeFileDescriptor(fd.get(), false /*takeOwnership*/));
+ } else {
+ // b/260119717 - Adding more FDs can eventually lead to FD limit exhaustion
+ if (options.extraFds.size() > kMaxFDs) {
+ return;
+ }
+
+ std::vector fds = getRandomFds(&provider);
+ CHECK(OK == parcel->writeFileDescriptor(fds.begin()->release(),
+ true /*takeOwnership*/));
+
+ options.extraFds.insert(options.extraFds.end(),
+ std::make_move_iterator(fds.begin() + 1),
+ std::make_move_iterator(fds.end()));
+ }
+ },
+ // write binder
+ [&]() {
+ sp binder;
+ if (options.extraBinders.size() > 0 && provider.ConsumeBool()) {
+ binder = options.extraBinders.at(provider.ConsumeIntegralInRange(
+ kMinExtraBinder, options.extraBinders.size() - 1));
+ } else {
+ binder = getRandomBinder(&provider);
+ }
+ CHECK(OK == parcel->writeStrongBinder(binder));
+ },
+ });
+ fillFunc();
+ }
+}
+
template
void invokeReadWriteNullParcel(type* obj) {
Parcel* parcelNull = nullptr;
@@ -52,4 +135,24 @@ void invokeReadWriteParcelsp(sp obj) {
delete parcel;
}
+template
+void invokeNewReadWriteParcel(type* obj, FuzzedDataProvider& provider) {
+ Parcel* parcel = new Parcel();
+ obj->writeToParcel(parcel);
+ randomizeParcel(parcel, provider);
+ parcel->setDataPosition(0);
+ obj->readFromParcel(parcel);
+ delete parcel;
+}
+
+template
+void invokeNewReadWriteParcelsp(sp obj, FuzzedDataProvider& provider) {
+ Parcel* parcel = new Parcel();
+ obj->writeToParcel(parcel);
+ randomizeParcel(parcel, provider);
+ parcel->setDataPosition(0);
+ obj->readFromParcel(parcel);
+ delete parcel;
+}
+
#endif // CAMERA2COMMON_H
diff --git a/camera/tests/fuzzer/camera_Parameters_fuzzer.cpp b/camera/tests/fuzzer/camera_Parameters_fuzzer.cpp
index 45b35264a3bf190d3b2ca8a76f2be927f37e8e3b..07efc205af42c1d6230e2eb0b64311db6040f031 100644
--- a/camera/tests/fuzzer/camera_Parameters_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_Parameters_fuzzer.cpp
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
using namespace std;
using namespace android;
@@ -77,7 +78,7 @@ void CameraParametersFuzzer::initCameraParameters(type** obj) {
} else {
params = mFDP->ConsumeRandomLengthString();
}
- *obj = new type(String8(params.c_str()));
+ *obj = new type(toString8(params));
}
}
diff --git a/camera/tests/fuzzer/camera_SessionStats_fuzzer.cpp b/camera/tests/fuzzer/camera_SessionStats_fuzzer.cpp
index 2f2ad773710ea67c2ba7f0e4da72416153251c32..c9bb20c66b47e21d34258b35b4e458ba9793a0ce 100644
--- a/camera/tests/fuzzer/camera_SessionStats_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_SessionStats_fuzzer.cpp
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include "camera2common.h"
using namespace std;
@@ -100,10 +101,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (fdp.ConsumeBool()) {
cameraSessionStats = new CameraSessionStats();
} else {
- string camId = fdp.ConsumeRandomLengthString();
- String16 cameraId(camId.c_str());
+ string cameraId = fdp.ConsumeRandomLengthString();
if (fdp.ConsumeBool()) {
- parcelCamSessionStats.writeString16(cameraId);
+ parcelCamSessionStats.writeString16(toString16(cameraId));
}
int32_t facing = fdp.ConsumeIntegral();
if (fdp.ConsumeBool()) {
@@ -113,10 +113,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (fdp.ConsumeBool()) {
parcelCamSessionStats.writeInt32(newCameraState);
}
- string name = fdp.ConsumeRandomLengthString();
- String16 clientName(name.c_str());
+ string clientName = fdp.ConsumeRandomLengthString();
if (fdp.ConsumeBool()) {
- parcelCamSessionStats.writeString16(clientName);
+ parcelCamSessionStats.writeString16(toString16(clientName));
}
int32_t apiLevel = fdp.ConsumeIntegral();
if (fdp.ConsumeBool()) {
diff --git a/camera/tests/fuzzer/camera_c2CaptureRequest_fuzzer.cpp b/camera/tests/fuzzer/camera_c2CaptureRequest_fuzzer.cpp
index 06215a5563af4aa6faf36ded5be3b774e3eb90a1..494ec1b594ca320092039062ff542949d67155e3 100644
--- a/camera/tests/fuzzer/camera_c2CaptureRequest_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_c2CaptureRequest_fuzzer.cpp
@@ -15,6 +15,7 @@
*/
#include
+#include
#include
#include
#include
@@ -45,7 +46,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
for (size_t idx = 0; idx < physicalCameraSettingsSize; ++idx) {
string id = fdp.ConsumeRandomLengthString();
if (fdp.ConsumeBool()) {
- parcelCamCaptureReq.writeString16(String16(id.c_str()));
+ parcelCamCaptureReq.writeString16(toString16(id));
}
CameraMetadata cameraMetadata;
if (fdp.ConsumeBool()) {
diff --git a/camera/tests/fuzzer/camera_c2OutputConfiguration_fuzzer.cpp b/camera/tests/fuzzer/camera_c2OutputConfiguration_fuzzer.cpp
index 51ac4e8719188dc4c366bc907fdd05c501b1afd3..2fe9a94ba9ed7dcddbe96775794cdc245300e65b 100644
--- a/camera/tests/fuzzer/camera_c2OutputConfiguration_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_c2OutputConfiguration_fuzzer.cpp
@@ -38,8 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
outputConfiguration = new OutputConfiguration();
} else {
int32_t rotation = fdp.ConsumeIntegral();
- string phyCameraId = fdp.ConsumeRandomLengthString();
- String16 physicalCameraId(phyCameraId.c_str());
+ string physicalCameraId = fdp.ConsumeRandomLengthString();
int32_t surfaceSetID = fdp.ConsumeIntegral();
bool isShared = fdp.ConsumeBool();
diff --git a/camera/tests/fuzzer/camera_c2SessionConfiguration_fuzzer.cpp b/camera/tests/fuzzer/camera_c2SessionConfiguration_fuzzer.cpp
index b2de95d739f5533ac1102815defc9a63059f7f9c..7cd0e5966181eebb5b9633aadac5134fc1e8a909 100644
--- a/camera/tests/fuzzer/camera_c2SessionConfiguration_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_c2SessionConfiguration_fuzzer.cpp
@@ -65,8 +65,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
surface.clear();
}
int32_t rotation = fdp.ConsumeIntegral();
- string phyCameraId = fdp.ConsumeRandomLengthString();
- String16 physicalCameraId(phyCameraId.c_str());
+ string physicalCameraId = fdp.ConsumeRandomLengthString();
int32_t surfaceSetID = fdp.ConsumeIntegral();
bool isShared = fdp.ConsumeBool();
outputConfiguration =
diff --git a/camera/tests/fuzzer/camera_captureResult_fuzzer.cpp b/camera/tests/fuzzer/camera_captureResult_fuzzer.cpp
index 1396431961e81635ca9960d16a9b3efac76ef6ce..dd857d4e3ef11d3af541f3ed2dfbedc9e16c031a 100644
--- a/camera/tests/fuzzer/camera_captureResult_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_captureResult_fuzzer.cpp
@@ -32,8 +32,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (fdp.ConsumeBool()) {
physicalCaptureResultInfo = new PhysicalCaptureResultInfo();
} else {
- string camId = fdp.ConsumeRandomLengthString();
- String16 cameraId(camId.c_str());
+ string cameraId = fdp.ConsumeRandomLengthString();
CameraMetadata cameraMetadata = CameraMetadata();
physicalCaptureResultInfo = new PhysicalCaptureResultInfo(cameraId, cameraMetadata);
}
@@ -47,9 +46,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
if (fdp.ConsumeBool()) {
captureResult->mResultExtras = CaptureResultExtras();
- string errCamId = fdp.ConsumeRandomLengthString();
- String16 errCameraId(errCamId.c_str());
- captureResult->mResultExtras.errorPhysicalCameraId = errCameraId;
+ captureResult->mResultExtras.errorPhysicalCameraId = fdp.ConsumeRandomLengthString();
captureResult->mResultExtras.isValid();
invokeReadWriteNullParcel(&(captureResult->mResultExtras));
}
diff --git a/camera/tests/fuzzer/camera_fuzzer.cpp b/camera/tests/fuzzer/camera_fuzzer.cpp
index f9ef98e4f4c24e21f0677426a1f26dee9c7d7c5b..c2a7549871dd0cfe0b8c5ce52a1873c9f120ba2c 100644
--- a/camera/tests/fuzzer/camera_fuzzer.cpp
+++ b/camera/tests/fuzzer/camera_fuzzer.cpp
@@ -15,36 +15,24 @@
*/
#include
-#include
-#include
#include
-#include
-#include
-#include
#include
#include
-#include
#include
#include
-#include
#include "camera2common.h"
-#include
using namespace std;
using namespace android;
using namespace android::hardware;
constexpr int32_t kFrameRateMin = 1;
-constexpr int32_t kFrameRateMax = 120;
-constexpr int32_t kCamIdMin = 0;
-constexpr int32_t kCamIdMax = 1;
+constexpr int32_t kFrameRateMax = 1000;
constexpr int32_t kNumMin = 0;
constexpr int32_t kNumMax = 1024;
constexpr int32_t kMemoryDealerSize = 1000;
-constexpr int32_t kRangeMin = 0;
-constexpr int32_t kRangeMax = 1000;
-constexpr int32_t kSizeMin = 0;
-constexpr int32_t kSizeMax = 1000;
+constexpr int8_t kMinElements = 1;
+constexpr int8_t kMaxElements = 10;
constexpr int32_t kValidCMD[] = {CAMERA_CMD_START_SMOOTH_ZOOM,
CAMERA_CMD_STOP_SMOOTH_ZOOM,
@@ -68,11 +56,6 @@ constexpr int32_t kValidPreviewCallbackFlag[] = {
CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER, CAMERA_FRAME_CALLBACK_FLAG_CAMERA,
CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER};
-constexpr int32_t kValidFacing[] = {android::hardware::CAMERA_FACING_BACK,
- android::hardware::CAMERA_FACING_FRONT};
-
-constexpr int32_t kValidOrientation[] = {0, 90, 180, 270};
-
class TestCameraListener : public CameraListener {
public:
virtual ~TestCameraListener() = default;
@@ -100,36 +83,12 @@ class TestCameraListener : public CameraListener {
class CameraFuzzer : public ::android::hardware::BnCameraClient {
public:
void process(const uint8_t* data, size_t size);
- ~CameraFuzzer() {
- delete mCameraMetadata;
- mComposerClient.clear();
- mSurfaceControl.clear();
- mSurface.clear();
- mCamera.clear();
- mMemoryDealer.clear();
- mIMem.clear();
- mCameraListener.clear();
- mCameraService.clear();
- }
private:
bool initCamera();
- void initCameraMetadata();
void invokeCamera();
- void invokeCameraUtils();
- void invokeCameraBase();
- void invokeCameraMetadata();
void invokeSetParameters();
sp mCamera = nullptr;
- CameraMetadata* mCameraMetadata = nullptr;
- sp mComposerClient = nullptr;
- sp mSurfaceControl = nullptr;
- sp mSurface = nullptr;
- sp mMemoryDealer = nullptr;
- sp mIMem = nullptr;
- sp mCameraListener = nullptr;
- sp mCameraService = nullptr;
- sp cameraDevice = nullptr;
FuzzedDataProvider* mFDP = nullptr;
// CameraClient interface
@@ -147,12 +106,26 @@ bool CameraFuzzer::initCamera() {
ProcessState::self()->startThreadPool();
sp sm = defaultServiceManager();
sp binder = sm->getService(String16("media.camera"));
- mCameraService = interface_cast(binder);
- mCameraService->connect(this, mFDP->ConsumeIntegral() /* cameraId */,
- String16("CAMERAFUZZ"), hardware::ICameraService::USE_CALLING_UID,
- hardware::ICameraService::USE_CALLING_PID,
- /*targetSdkVersion*/ __ANDROID_API_FUTURE__,
- /*overrideToPortrait*/false, /*forceSlowJpegMode*/false, &cameraDevice);
+ sp cameraService = nullptr;
+ cameraService = interface_cast(binder);
+ sp cameraDevice = nullptr;
+ if (mFDP->ConsumeBool()) {
+ cameraService->connect(this, mFDP->ConsumeIntegral() /* cameraId */, "CAMERAFUZZ",
+ hardware::ICameraService::USE_CALLING_UID,
+ hardware::ICameraService::USE_CALLING_PID,
+ /*targetSdkVersion*/ __ANDROID_API_FUTURE__,
+ /*overrideToPortrait*/ false, /*forceSlowJpegMode*/ false,
+ &cameraDevice);
+ } else {
+ cameraService->connect(this, mFDP->ConsumeIntegral() /* cameraId */,
+ mFDP->ConsumeRandomLengthString(kMaxBytes).c_str(),
+ mFDP->ConsumeIntegral() /* clientUid */,
+ mFDP->ConsumeIntegral() /* clientPid */,
+ /*targetSdkVersion*/ mFDP->ConsumeIntegral(),
+ /*overrideToPortrait*/ mFDP->ConsumeBool(),
+ /*forceSlowJpegMode*/ mFDP->ConsumeBool(), &cameraDevice);
+ }
+
mCamera = Camera::create(cameraDevice);
if (!mCamera) {
return false;
@@ -176,224 +149,195 @@ void CameraFuzzer::invokeCamera() {
return;
}
- int32_t cameraId = mFDP->ConsumeIntegralInRange(kCamIdMin, kCamIdMax);
+ int32_t cameraId = mFDP->ConsumeIntegral();
Camera::getNumberOfCameras();
CameraInfo cameraInfo;
cameraInfo.facing = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFacing)
- : mFDP->ConsumeIntegral();
+ : mFDP->ConsumeIntegral();
cameraInfo.orientation = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidOrientation)
- : mFDP->ConsumeIntegral();
+ : mFDP->ConsumeIntegral();
Camera::getCameraInfo(cameraId, /*overrideToPortrait*/false, &cameraInfo);
mCamera->reconnect();
- mComposerClient = new SurfaceComposerClient;
- mSurfaceControl = mComposerClient->createSurface(
- static_cast(mFDP->ConsumeRandomLengthString().c_str()) /* name */,
- mFDP->ConsumeIntegral() /* width */,
- mFDP->ConsumeIntegral() /* height */,
- mFDP->ConsumeIntegral() /* format */,
- mFDP->ConsumeIntegral() /* flags */);
- if (mSurfaceControl) {
- mSurface = mSurfaceControl->getSurface();
- mCamera->setPreviewTarget(mSurface->getIGraphicBufferProducer());
- mCamera->startPreview();
- mCamera->stopPreview();
- mCamera->previewEnabled();
- mCamera->startRecording();
- mCamera->stopRecording();
- }
-
- mCamera->lock();
- mCamera->unlock();
- mCamera->autoFocus();
- mCamera->cancelAutoFocus();
-
- int32_t msgType = mFDP->ConsumeIntegral();
- mCamera->takePicture(msgType);
- invokeSetParameters();
- int32_t cmd;
+ sp composerClient = new SurfaceComposerClient;
+ sp surfaceControl = nullptr;
if (mFDP->ConsumeBool()) {
- cmd = mFDP->PickValueInArray(kValidCMD);
+ surfaceControl = composerClient->createSurface(String8("FUZZSURFACE"), 1280, 800,
+ HAL_PIXEL_FORMAT_YV12);
} else {
- cmd = mFDP->ConsumeIntegral();
+ surfaceControl = composerClient->createSurface(
+ static_cast(mFDP->ConsumeRandomLengthString(kMaxBytes).c_str()) /* name */,
+ mFDP->ConsumeIntegral() /* width */,
+ mFDP->ConsumeIntegral() /* height */,
+ mFDP->ConsumeIntegral() /* format */,
+ mFDP->ConsumeIntegral() /* flags */);
}
- int32_t arg1 = mFDP->ConsumeIntegral();
- int32_t arg2 = mFDP->ConsumeIntegral();
- mCamera->sendCommand(cmd, arg1, arg2);
- int32_t videoBufferMode = mFDP->PickValueInArray(kValidVideoBufferMode);
- mCamera->setVideoBufferMode(videoBufferMode);
- if (mSurfaceControl) {
- mSurface = mSurfaceControl->getSurface();
- mCamera->setVideoTarget(mSurface->getIGraphicBufferProducer());
- }
- mCameraListener = sp::make();
- mCamera->setListener(mCameraListener);
- int32_t previewCallbackFlag;
if (mFDP->ConsumeBool()) {
- previewCallbackFlag = mFDP->PickValueInArray(kValidPreviewCallbackFlag);
- } else {
- previewCallbackFlag = mFDP->ConsumeIntegral();
+ invokeSetParameters();
}
- mCamera->setPreviewCallbackFlags(previewCallbackFlag);
- if (mSurfaceControl) {
- mSurface = mSurfaceControl->getSurface();
- mCamera->setPreviewCallbackTarget(mSurface->getIGraphicBufferProducer());
+ sp surface = nullptr;
+ if (surfaceControl) {
+ surface = surfaceControl->getSurface();
}
-
- mCamera->getRecordingProxy();
- int32_t mode = mFDP->ConsumeIntegral();
- mCamera->setAudioRestriction(mode);
- mCamera->getGlobalAudioRestriction();
- mCamera->recordingEnabled();
-
- mMemoryDealer = new MemoryDealer(kMemoryDealerSize);
- mIMem = mMemoryDealer->allocate(kMemoryDealerSize);
- mCamera->releaseRecordingFrame(mIMem);
-
- int32_t numFds = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
- int32_t numInts = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
- native_handle_t* handle = native_handle_create(numFds, numInts);
- mCamera->releaseRecordingFrameHandle(handle);
-
- int32_t msgTypeNC = mFDP->ConsumeIntegral();
- int32_t ext = mFDP->ConsumeIntegral();
- int32_t ext2 = mFDP->ConsumeIntegral();
- mCamera->notifyCallback(msgTypeNC, ext, ext2);
-
- int64_t timestamp = mFDP->ConsumeIntegral();
- mCamera->dataCallbackTimestamp(timestamp, msgTypeNC, mIMem);
- mCamera->recordingFrameHandleCallbackTimestamp(timestamp, handle);
-}
-
-void CameraFuzzer::invokeCameraUtils() {
- CameraMetadata staticMetadata;
- int32_t orientVal = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidOrientation)
- : mFDP->ConsumeIntegral();
- uint8_t facingVal = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFacing)
- : mFDP->ConsumeIntegral();
- staticMetadata.update(ANDROID_SENSOR_ORIENTATION, &orientVal, 1);
- staticMetadata.update(ANDROID_LENS_FACING, &facingVal, 1);
- int32_t transform = 0;
- CameraUtils::getRotationTransform(
- staticMetadata, mFDP->ConsumeIntegral() /* mirrorMode */, &transform /*out*/);
- CameraUtils::isCameraServiceDisabled();
-}
-
-void CameraFuzzer::invokeCameraBase() {
- CameraInfo cameraInfo;
- cameraInfo.facing = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidFacing)
- : mFDP->ConsumeIntegral();
- cameraInfo.orientation = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidOrientation)
- : mFDP->ConsumeIntegral();
- invokeReadWriteParcel(&cameraInfo);
-
- CameraStatus* cameraStatus = nullptr;
-
- if (mFDP->ConsumeBool()) {
- cameraStatus = new CameraStatus();
- } else {
- string cid = mFDP->ConsumeRandomLengthString();
- String8 id(cid.c_str());
- int32_t status = mFDP->ConsumeIntegral();
- size_t unavailSubIdsSize = mFDP->ConsumeIntegralInRange(kSizeMin, kSizeMax);
- vector unavailSubIds;
- for (size_t idx = 0; idx < unavailSubIdsSize; ++idx) {
- string subId = mFDP->ConsumeRandomLengthString();
- String8 unavailSubId(subId.c_str());
- unavailSubIds.push_back(unavailSubId);
- }
- string clientPkg = mFDP->ConsumeRandomLengthString();
- String8 clientPackage(clientPkg.c_str());
- cameraStatus = new CameraStatus(id, status, unavailSubIds, clientPackage);
- }
-
- invokeReadWriteParcel(cameraStatus);
- delete cameraStatus;
-}
-
-void CameraFuzzer::initCameraMetadata() {
- if (mFDP->ConsumeBool()) {
- mCameraMetadata = new CameraMetadata();
- } else {
- size_t entryCapacity = mFDP->ConsumeIntegralInRange(kSizeMin, kSizeMax);
- size_t dataCapacity = mFDP->ConsumeIntegralInRange(kSizeMin, kSizeMax);
- mCameraMetadata = new CameraMetadata(entryCapacity, dataCapacity);
- }
-}
-
-void CameraFuzzer::invokeCameraMetadata() {
- initCameraMetadata();
-
- const camera_metadata_t* metadataBuffer = nullptr;
- if (mFDP->ConsumeBool()) {
- metadataBuffer = mCameraMetadata->getAndLock();
+ sp memoryDealer = nullptr;
+ sp iMem = nullptr;
+ sp cameraListener = nullptr;
+
+ while (mFDP->remaining_bytes()) {
+ auto callCameraAPIs = mFDP->PickValueInArray>({
+ [&]() {
+ if (surfaceControl) {
+ mCamera->setPreviewTarget(surface->getIGraphicBufferProducer());
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->startPreview();
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->stopPreview();
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->stopPreview();
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->previewEnabled();
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->startRecording();
+ }
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->stopRecording();
+ }
+ },
+ [&]() { mCamera->lock(); },
+ [&]() { mCamera->unlock(); },
+ [&]() { mCamera->autoFocus(); },
+ [&]() { mCamera->cancelAutoFocus(); },
+ [&]() {
+ int32_t msgType = mFDP->ConsumeIntegral();
+ mCamera->takePicture(msgType);
+ },
+ [&]() {
+ int32_t cmd;
+ cmd = mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidCMD)
+ : mFDP->ConsumeIntegral();
+ int32_t arg1 = mFDP->ConsumeIntegral();
+ int32_t arg2 = mFDP->ConsumeIntegral();
+ mCamera->sendCommand(cmd, arg1, arg2);
+ },
+ [&]() {
+ int32_t videoBufferMode =
+ mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidVideoBufferMode)
+ : mFDP->ConsumeIntegral();
+ mCamera->setVideoBufferMode(videoBufferMode);
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->setVideoTarget(surface->getIGraphicBufferProducer());
+ }
+ },
+ [&]() {
+ cameraListener = sp::make();
+ mCamera->setListener(cameraListener);
+ },
+ [&]() {
+ int32_t previewCallbackFlag;
+ previewCallbackFlag =
+ mFDP->ConsumeBool() ? mFDP->PickValueInArray(kValidPreviewCallbackFlag)
+ : mFDP->ConsumeIntegral();
+ mCamera->setPreviewCallbackFlags(previewCallbackFlag);
+ },
+ [&]() {
+ if (surfaceControl) {
+ mCamera->setPreviewCallbackTarget(surface->getIGraphicBufferProducer());
+ }
+ },
+ [&]() { mCamera->getRecordingProxy(); },
+ [&]() {
+ int32_t mode = mFDP->ConsumeIntegral();
+ mCamera->setAudioRestriction(mode);
+ },
+ [&]() { mCamera->getGlobalAudioRestriction(); },
+ [&]() { mCamera->recordingEnabled(); },
+ [&]() {
+ memoryDealer = new MemoryDealer(kMemoryDealerSize);
+ iMem = memoryDealer->allocate(kMemoryDealerSize);
+ },
+ [&]() {
+ int32_t msgTypeNC = mFDP->ConsumeIntegral();
+ int32_t ext = mFDP->ConsumeIntegral();
+ int32_t ext2 = mFDP->ConsumeIntegral();
+ mCamera->notifyCallback(msgTypeNC, ext, ext2);
+ },
+ [&]() {
+ int32_t msgTypeNC = mFDP->ConsumeIntegral();
+ int64_t timestamp = mFDP->ConsumeIntegral();
+ mCamera->dataCallbackTimestamp(timestamp, msgTypeNC, iMem);
+ },
+ [&]() {
+ int64_t timestamp = mFDP->ConsumeIntegral();
+ int32_t numFds = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ int32_t numInts = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ native_handle_t* handle = native_handle_create(numFds, numInts);
+ mCamera->recordingFrameHandleCallbackTimestamp(timestamp, handle);
+ },
+ [&]() {
+ int32_t numFds = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ int32_t numInts = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ native_handle_t* handle = native_handle_create(numFds, numInts);
+ mCamera->releaseRecordingFrameHandle(handle);
+ },
+ [&]() { mCamera->releaseRecordingFrame(iMem); },
+ [&]() {
+ std::vector handles;
+ for (int8_t i = 0;
+ i < mFDP->ConsumeIntegralInRange(kMinElements, kMaxElements);
+ ++i) {
+ int32_t numFds = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ int32_t numInts = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ native_handle_t* handle = native_handle_create(numFds, numInts);
+ handles.push_back(handle);
+ }
+ mCamera->releaseRecordingFrameHandleBatch(handles);
+ },
+ [&]() {
+ std::vector handles;
+ for (int8_t i = 0;
+ i < mFDP->ConsumeIntegralInRange(kMinElements, kMaxElements);
+ ++i) {
+ int32_t numFds = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ int32_t numInts = mFDP->ConsumeIntegralInRange(kNumMin, kNumMax);
+ native_handle_t* handle = native_handle_create(numFds, numInts);
+ handles.push_back(handle);
+ }
+ std::vector timestamps;
+ for (int8_t i = 0;
+ i < mFDP->ConsumeIntegralInRange(kMinElements, kMaxElements);
+ ++i) {
+ timestamps.push_back(mFDP->ConsumeIntegral());
+ }
+ mCamera->recordingFrameHandleCallbackTimestampBatch(timestamps, handles);
+ },
+ });
+ callCameraAPIs();
}
-
- mCameraMetadata->entryCount();
- mCameraMetadata->isEmpty();
- mCameraMetadata->bufferSize();
- mCameraMetadata->sort();
-
- uint32_t tag = mFDP->ConsumeIntegral();
- uint8_t dataUint8 = mFDP->ConsumeIntegral();
- int32_t dataInt32 = mFDP->ConsumeIntegral();
- int64_t dataInt64 = mFDP->ConsumeIntegral();
- float dataFloat = mFDP->ConsumeFloatingPoint();
- double dataDouble = mFDP->ConsumeFloatingPoint();
- camera_metadata_rational dataRational;
- dataRational.numerator = mFDP->ConsumeIntegral();
- dataRational.denominator = mFDP->ConsumeIntegral();
- string dataStr = mFDP->ConsumeRandomLengthString();
- String8 dataString(dataStr.c_str());
- size_t data_count = 1;
- mCameraMetadata->update(tag, &dataUint8, data_count);
- mCameraMetadata->update(tag, &dataInt32, data_count);
- mCameraMetadata->update(tag, &dataFloat, data_count);
- mCameraMetadata->update(tag, &dataInt64, data_count);
- mCameraMetadata->update(tag, &dataRational, data_count);
- mCameraMetadata->update(tag, &dataDouble, data_count);
- mCameraMetadata->update(tag, dataString);
-
- uint32_t tagExists = mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
- mCameraMetadata->exists(tagExists);
-
- uint32_t tagFind = mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
- mCameraMetadata->find(tagFind);
-
- uint32_t tagErase = mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
- mCameraMetadata->erase(tagErase);
-
- mCameraMetadata->unlock(metadataBuffer);
- std::vector tagsRemoved;
- uint64_t vendorId = mFDP->ConsumeIntegral();
- mCameraMetadata->removePermissionEntries(vendorId, &tagsRemoved);
-
- string name = mFDP->ConsumeRandomLengthString();
- VendorTagDescriptor vTags;
- uint32_t tagName = mFDP->ConsumeIntegral();
- mCameraMetadata->getTagFromName(name.c_str(), &vTags, &tagName);
-
- invokeReadWriteNullParcel(mCameraMetadata);
- invokeReadWriteParcel(mCameraMetadata);
-
- int32_t fd = open("/dev/null", O_CLOEXEC | O_RDWR | O_CREAT);
- int32_t verbosity = mFDP->ConsumeIntegralInRange(kRangeMin, kRangeMax);
- int32_t indentation = mFDP->ConsumeIntegralInRange(kRangeMin, kRangeMax);
- mCameraMetadata->dump(fd, verbosity, indentation);
-
- CameraMetadata metadataCopy(mCameraMetadata->release());
- CameraMetadata otherCameraMetadata;
- mCameraMetadata->swap(otherCameraMetadata);
- close(fd);
}
void CameraFuzzer::process(const uint8_t* data, size_t size) {
mFDP = new FuzzedDataProvider(data, size);
invokeCamera();
- invokeCameraUtils();
- invokeCameraBase();
- invokeCameraMetadata();
delete mFDP;
}
diff --git a/camera/tests/fuzzer/camera_metadata_fuzzer.cpp b/camera/tests/fuzzer/camera_metadata_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a609e19d3489ded058083ceb284b07626d318e7e
--- /dev/null
+++ b/camera/tests/fuzzer/camera_metadata_fuzzer.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include
+#include "camera2common.h"
+
+using namespace std;
+using namespace android;
+using namespace android::hardware;
+
+constexpr int32_t kSizeMin = 0;
+constexpr int32_t kSizeMax = 1000;
+constexpr int32_t kMinMetadataCapacity = 0;
+constexpr int32_t kMaxMetadataCapacity = 1000;
+constexpr int32_t kRangeMin = 0;
+constexpr int32_t kRangeMax = 1000;
+
+class CameraMetadataFuzzer {
+ public:
+ void process(const uint8_t* data, size_t size);
+
+ private:
+ void initCameraMetadata();
+ void invokeCameraMetadata();
+ CameraMetadata* mCameraMetadata = nullptr;
+ FuzzedDataProvider* mFDP = nullptr;
+ camera_metadata* mMetaBuffer = nullptr;
+ bool mMetadataLocked = false;
+ template
+ void callCameraMetadataUpdate(size_t dataCount, T data) {
+ uint32_t tag = mFDP->ConsumeIntegral();
+ mCameraMetadata->update(tag, &data, dataCount);
+ }
+};
+
+void CameraMetadataFuzzer::initCameraMetadata() {
+ auto selectMetadataConstructor = mFDP->PickValueInArray>({
+ [&]() {
+ mMetaBuffer = allocate_camera_metadata(
+ mFDP->ConsumeIntegralInRange(
+ kMinMetadataCapacity, kMaxMetadataCapacity) /* entry_capacity */,
+ mFDP->ConsumeIntegralInRange(
+ kMinMetadataCapacity, kMaxMetadataCapacity) /* data_capacity */);
+ mCameraMetadata = new CameraMetadata(mMetaBuffer);
+ },
+ [&]() {
+ mCameraMetadata = new CameraMetadata();
+ },
+ [&]() {
+ size_t entryCapacity = mFDP->ConsumeIntegralInRange(kSizeMin, kSizeMax);
+ size_t dataCapacity = mFDP->ConsumeIntegralInRange(kSizeMin, kSizeMax);
+ mCameraMetadata = new CameraMetadata(entryCapacity, dataCapacity);
+ },
+ });
+ selectMetadataConstructor();
+}
+void CameraMetadataFuzzer::invokeCameraMetadata() {
+ initCameraMetadata();
+
+ const camera_metadata_t* metadataBuffer = nullptr;
+ mMetadataLocked = mFDP->ConsumeBool();
+ if (mMetadataLocked) {
+ metadataBuffer = mCameraMetadata->getAndLock();
+ }
+
+ size_t dataCount = 1;
+ while (mFDP->remaining_bytes()) {
+ auto callMetadataAPIs = mFDP->PickValueInArray>({
+
+ [&]() { mCameraMetadata->entryCount(); },
+ [&]() { mCameraMetadata->isEmpty(); },
+ [&]() { mCameraMetadata->bufferSize(); },
+ [&]() { mCameraMetadata->sort(); },
+ [&]() {
+ uint8_t dataUint8 = mFDP->ConsumeIntegral();
+ callCameraMetadataUpdate(dataCount, dataUint8);
+ },
+ [&]() {
+ int32_t dataInt32 = mFDP->ConsumeIntegral();
+ callCameraMetadataUpdate(dataCount, dataInt32);
+ },
+ [&]() {
+ int64_t dataInt64 = mFDP->ConsumeIntegral();
+ callCameraMetadataUpdate(dataCount, dataInt64);
+ },
+ [&]() {
+ float dataFloat = mFDP->ConsumeFloatingPoint();
+ callCameraMetadataUpdate(dataCount, dataFloat);
+ },
+ [&]() {
+ double dataDouble = mFDP->ConsumeFloatingPoint();
+ callCameraMetadataUpdate(dataCount, dataDouble);
+ },
+ [&]() {
+ camera_metadata_rational dataRational;
+ dataRational.numerator = mFDP->ConsumeIntegral();
+ dataRational.denominator = mFDP->ConsumeIntegral();
+ callCameraMetadataUpdate(dataCount, dataRational);
+ },
+ [&]() {
+ uint32_t tag = mFDP->ConsumeIntegral();
+ string dataStr = mFDP->ConsumeRandomLengthString(kMaxBytes);
+ String8 dataString(dataStr.c_str());
+ mCameraMetadata->update(tag, dataString);
+ },
+ [&]() {
+ uint32_t tag = mFDP->ConsumeIntegral();
+ uint32_t tagExists =
+ mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
+ mCameraMetadata->exists(tagExists);
+ },
+ [&]() {
+ uint32_t tag = mFDP->ConsumeIntegral();
+ uint32_t tagFind =
+ mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
+ mCameraMetadata->find(tagFind);
+ },
+ [&]() {
+ uint32_t tag = mFDP->ConsumeIntegral();
+ uint32_t tagErase =
+ mFDP->ConsumeBool() ? tag : mFDP->ConsumeIntegral();
+ mCameraMetadata->erase(tagErase);
+ },
+ [&]() { mCameraMetadata->unlock(metadataBuffer); },
+ [&]() {
+ std::vector tagsRemoved;
+ uint64_t vendorId = mFDP->ConsumeIntegral();
+ mCameraMetadata->removePermissionEntries(vendorId, &tagsRemoved);
+ },
+ [&]() {
+ string name = mFDP->ConsumeRandomLengthString(kMaxBytes);
+ VendorTagDescriptor vTags;
+ uint32_t tagName = mFDP->ConsumeIntegral();
+ mCameraMetadata->getTagFromName(name.c_str(), &vTags, &tagName);
+ },
+ [&]() {
+ int32_t fd = open("/dev/null", O_CLOEXEC | O_RDWR | O_CREAT);
+ int32_t verbosity = mFDP->ConsumeIntegralInRange(kRangeMin, kRangeMax);
+ int32_t indentation =
+ mFDP->ConsumeIntegralInRange(kRangeMin, kRangeMax);
+ mCameraMetadata->dump(fd, verbosity, indentation);
+ close(fd);
+ },
+ [&]() { CameraMetadata metadataCopy(mCameraMetadata->release()); },
+ [&]() {
+ if (mFDP->ConsumeBool()) {
+ CameraMetadata otherCameraMetadata;
+ mCameraMetadata->swap(otherCameraMetadata);
+ } else {
+ std::vector entryCapacityVector =
+ mFDP->ConsumeBytes(kMaxBytes);
+ /**
+ * Resizing vector to a size between 1 to 1000 so that vector is not empty.
+ */
+ entryCapacityVector.resize(0, mFDP->ConsumeIntegralInRange(
+ kMinCapacity, kMaxCapacity));
+ CameraMetadata otherCameraMetadata(entryCapacityVector.size());
+ mCameraMetadata->swap(otherCameraMetadata);
+ }
+ },
+ [&]() {
+ if (!mMetadataLocked) {
+ camera_metadata* metaBuffer = allocate_camera_metadata(
+ mFDP->ConsumeIntegralInRange(
+ kMinMetadataCapacity,
+ kMaxMetadataCapacity) /* entry_capacity */,
+ mFDP->ConsumeIntegralInRange(
+ kMinMetadataCapacity,
+ kMaxMetadataCapacity) /* data_capacity */);
+ mCameraMetadata->acquire(metaBuffer);
+ }
+ },
+ [&]() {
+ if (!mMetadataLocked) {
+ camera_metadata* metaBuffer = allocate_camera_metadata(
+ mFDP->ConsumeIntegralInRange