camera: add fixed-focus camera identification
Test: GCA
Bug: 157138779
Change-Id: I3a021777fb4d4f49c23c60b201d298b3e498b012
diff --git a/common/hal/google_camera_hal/hal_utils.cc b/common/hal/google_camera_hal/hal_utils.cc
index fb4e969..22635da 100644
--- a/common/hal/google_camera_hal/hal_utils.cc
+++ b/common/hal/google_camera_hal/hal_utils.cc
@@ -210,6 +210,24 @@
return false;
}
+bool IsFixedFocusCamera(const HalCameraMetadata* characteristics) {
+ if (characteristics == nullptr) {
+ ALOGE("%s: characteristics (%p) is nullptr", __FUNCTION__, characteristics);
+ return false;
+ }
+
+ camera_metadata_ro_entry entry = {};
+ status_t res =
+ characteristics->Get(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, &entry);
+ if (res != OK || entry.count != 1) {
+ ALOGE("%s: Getting ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE failed: %s(%d)",
+ __FUNCTION__, strerror(-res), res);
+ return false;
+ }
+
+ return entry.data.f[0] == 0.0f;
+}
+
bool IsRequestHdrplusCompatible(const CaptureRequest& request,
int32_t preview_stream_id) {
if (request.settings == nullptr) {
diff --git a/common/hal/google_camera_hal/hal_utils.h b/common/hal/google_camera_hal/hal_utils.h
index ec73805..1ae517d 100644
--- a/common/hal/google_camera_hal/hal_utils.h
+++ b/common/hal/google_camera_hal/hal_utils.h
@@ -67,6 +67,9 @@
bool IsRequestHdrplusCompatible(const CaptureRequest& request,
int32_t preview_stream_id);
+// Return true if this is a fixed-focus camera.
+bool IsFixedFocusCamera(const HalCameraMetadata* characteristics);
+
// Return if HDR+ stream is supported
bool IsStreamHdrplusCompatible(const StreamConfiguration& stream_config,
const HalCameraMetadata* characteristics);