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:

*