From f0906253f83fc67f694f7f1b40b8762120d0c433 Mon Sep 17 00:00:00 2001 From: Yin-Chia Yeh Date: Tue, 26 Feb 2019 14:02:15 -0800 Subject: [PATCH] Camera: fix filter logic for depth only camera Test: partner testing Bug: 126408288 Merged-In: I5c3abcd72e64b40e7cbac467646d99a1f5b362d0 Change-Id: I5c3abcd72e64b40e7cbac467646d99a1f5b362d0 --- camera/ndk/impl/ACameraMetadata.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/camera/ndk/impl/ACameraMetadata.cpp b/camera/ndk/impl/ACameraMetadata.cpp index d73f7440e7..9d341aeaf3 100644 --- a/camera/ndk/impl/ACameraMetadata.cpp +++ b/camera/ndk/impl/ACameraMetadata.cpp @@ -159,7 +159,7 @@ ACameraMetadata::filterStreamConfigurations() { const int STREAM_HEIGHT_OFFSET = 2; const int STREAM_IS_INPUT_OFFSET = 3; camera_metadata_entry entry = mData.find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS); - if (entry.count == 0 || entry.count % 4 || entry.type != TYPE_INT32) { + if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) { ALOGE("%s: malformed available stream configuration key! count %zu, type %d", __FUNCTION__, entry.count, entry.type); return; @@ -187,9 +187,17 @@ ACameraMetadata::filterStreamConfigurations() { filteredStreamConfigs.push_back(isInput); } - mData.update(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, filteredStreamConfigs); + if (filteredStreamConfigs.size() > 0) { + mData.update(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, filteredStreamConfigs); + } entry = mData.find(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS); + if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) { + ALOGE("%s: malformed available depth stream configuration key! count %zu, type %d", + __FUNCTION__, entry.count, entry.type); + return; + } + Vector filteredDepthStreamConfigs; filteredDepthStreamConfigs.setCapacity(entry.count); @@ -214,7 +222,12 @@ ACameraMetadata::filterStreamConfigurations() { filteredDepthStreamConfigs.push_back(height); filteredDepthStreamConfigs.push_back(isInput); } - mData.update(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, filteredDepthStreamConfigs); + + if (filteredDepthStreamConfigs.size() > 0) { + mData.update(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, + filteredDepthStreamConfigs); + } + } bool