1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "ACameraMetadata"
19 
20 #include "ACameraMetadata.h"
21 #include <utils/Vector.h>
22 #include <system/graphics.h>
23 #include <media/NdkImage.h>
24 
25 using namespace android;
26 
27 /**
28  * ACameraMetadata Implementation
29  */
ACameraMetadata(camera_metadata_t * buffer,ACAMERA_METADATA_TYPE type)30 ACameraMetadata::ACameraMetadata(camera_metadata_t* buffer, ACAMERA_METADATA_TYPE type) :
31         mData(std::make_shared<CameraMetadata>(buffer)),
32         mType(type) {
33     init();
34 }
35 
ACameraMetadata(const std::shared_ptr<CameraMetadata> & cameraMetadata,ACAMERA_METADATA_TYPE type)36 ACameraMetadata::ACameraMetadata(const std::shared_ptr<CameraMetadata>& cameraMetadata,
37         ACAMERA_METADATA_TYPE type) :
38         mData(cameraMetadata),
39         mType(type) {
40     init();
41 }
42 
ACameraMetadata(const ACameraMetadata & other)43 ACameraMetadata::ACameraMetadata(const ACameraMetadata& other) :
44         mData(std::make_shared<CameraMetadata>(*(other.mData))),
45         mType(other.mType) {
46 }
47 
~ACameraMetadata()48 ACameraMetadata::~ACameraMetadata() {
49 }
50 
51 void
init()52 ACameraMetadata::init() {
53     if (mType == ACM_CHARACTERISTICS) {
54         filterUnsupportedFeatures();
55         filterStreamConfigurations();
56         filterDurations(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS);
57         filterDurations(ANDROID_SCALER_AVAILABLE_STALL_DURATIONS);
58         filterDurations(ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS);
59         filterDurations(ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS);
60         filterDurations(ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS);
61         filterDurations(ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS);
62         filterDurations(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS);
63         filterDurations(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS);
64     }
65     // TODO: filter request/result keys
66 }
67 
68 bool
isNdkSupportedCapability(int32_t capability)69 ACameraMetadata::isNdkSupportedCapability(int32_t capability) {
70     switch (capability) {
71         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING:
72         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING:
73         case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO:
74             return false;
75         default:
76             // Assuming every capability passed to this function is actually a
77             // valid capability.
78             return true;
79     }
80 }
81 
82 void
filterUnsupportedFeatures()83 ACameraMetadata::filterUnsupportedFeatures() {
84     // Hide unsupported capabilities (reprocessing)
85     camera_metadata_entry entry = mData->find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
86     if (entry.count == 0 || entry.type != TYPE_BYTE) {
87         ALOGE("%s: malformed available capability key! count %zu, type %d",
88                 __FUNCTION__, entry.count, entry.type);
89         return;
90     }
91 
92     Vector<uint8_t> capabilities;
93     capabilities.setCapacity(entry.count);
94     for (size_t i = 0; i < entry.count; i++) {
95         uint8_t capability = entry.data.u8[i];
96         if (isNdkSupportedCapability(capability)) {
97             capabilities.push(capability);
98 
99             if (capability == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
100                 derivePhysicalCameraIds();
101             }
102         }
103     }
104     mData->update(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capabilities);
105 }
106 
107 void
derivePhysicalCameraIds()108 ACameraMetadata::derivePhysicalCameraIds() {
109     ACameraMetadata_const_entry entry;
110     auto ret = getConstEntry(ACAMERA_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS, &entry);
111     if (ret != ACAMERA_OK) {
112         ALOGE("%s: Get ACAMERA_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS key failed. ret %d",
113                 __FUNCTION__, ret);
114         return;
115     }
116 
117     const uint8_t* ids = entry.data.u8;
118     size_t start = 0;
119     for (size_t i = 0; i < entry.count; ++i) {
120         if (ids[i] == '\0') {
121             if (start != i) {
122                 mStaticPhysicalCameraIdValues.push_back(String8((const char *)ids+start));
123                 mStaticPhysicalCameraIds.push_back(mStaticPhysicalCameraIdValues.back().string());
124             }
125             start = i+1;
126         }
127     }
128 
129     if (mStaticPhysicalCameraIds.size() < 2) {
130         ALOGW("%s: Logical multi-camera device only has %zu physical cameras",
131                 __FUNCTION__, mStaticPhysicalCameraIds.size());
132     }
133 }
134 
135 void
filterDurations(uint32_t tag)136 ACameraMetadata::filterDurations(uint32_t tag) {
137     const int STREAM_CONFIGURATION_SIZE = 4;
138     const int STREAM_FORMAT_OFFSET = 0;
139     const int STREAM_WIDTH_OFFSET = 1;
140     const int STREAM_HEIGHT_OFFSET = 2;
141     const int STREAM_DURATION_OFFSET = 3;
142 
143     camera_metadata_entry entry = mData->find(tag);
144 
145     if (entry.count == 0) {
146         // Duration keys can be missing when corresponding capture feature is not supported
147         return;
148     }
149 
150     if (entry.count % 4 || entry.type != TYPE_INT64) {
151         ALOGE("%s: malformed duration key %d! count %zu, type %d",
152                 __FUNCTION__, tag, entry.count, entry.type);
153         return;
154     }
155 
156     Vector<int64_t> filteredDurations;
157     filteredDurations.setCapacity(entry.count * 2);
158 
159     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
160         int64_t format = entry.data.i64[i + STREAM_FORMAT_OFFSET];
161         int64_t width = entry.data.i64[i + STREAM_WIDTH_OFFSET];
162         int64_t height = entry.data.i64[i + STREAM_HEIGHT_OFFSET];
163         int64_t duration = entry.data.i32[i + STREAM_DURATION_OFFSET];
164 
165         // Leave the unfiltered format in so apps depending on previous wrong
166         // filter behavior continue to work
167         filteredDurations.push_back(format);
168         filteredDurations.push_back(width);
169         filteredDurations.push_back(height);
170         filteredDurations.push_back(duration);
171 
172         // Translate HAL formats to NDK format
173         switch (tag) {
174             case ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS:
175             case ANDROID_SCALER_AVAILABLE_STALL_DURATIONS:
176                 if (format == HAL_PIXEL_FORMAT_BLOB) {
177                     format = AIMAGE_FORMAT_JPEG;
178                     filteredDurations.push_back(format);
179                     filteredDurations.push_back(width);
180                     filteredDurations.push_back(height);
181                     filteredDurations.push_back(duration);
182                 }
183                 break;
184             case ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS:
185             case ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS:
186                 if (format == HAL_PIXEL_FORMAT_BLOB) {
187                     format = AIMAGE_FORMAT_DEPTH_POINT_CLOUD;
188                     filteredDurations.push_back(format);
189                     filteredDurations.push_back(width);
190                     filteredDurations.push_back(height);
191                     filteredDurations.push_back(duration);
192                 } else if (format == HAL_PIXEL_FORMAT_Y16) {
193                     format = AIMAGE_FORMAT_DEPTH16;
194                     filteredDurations.push_back(format);
195                     filteredDurations.push_back(width);
196                     filteredDurations.push_back(height);
197                     filteredDurations.push_back(duration);
198                 }
199                 break;
200             case ANDROID_HEIC_AVAILABLE_HEIC_MIN_FRAME_DURATIONS:
201             case ANDROID_HEIC_AVAILABLE_HEIC_STALL_DURATIONS:
202                 if (format == HAL_PIXEL_FORMAT_BLOB) {
203                     format = AIMAGE_FORMAT_HEIC;
204                     filteredDurations.push_back(format);
205                     filteredDurations.push_back(width);
206                     filteredDurations.push_back(height);
207                     filteredDurations.push_back(duration);
208                 }
209                 break;
210             case ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS:
211             case ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS:
212                 if (format == HAL_PIXEL_FORMAT_BLOB) {
213                     format = AIMAGE_FORMAT_DEPTH_JPEG;
214                     filteredDurations.push_back(format);
215                     filteredDurations.push_back(width);
216                     filteredDurations.push_back(height);
217                     filteredDurations.push_back(duration);
218                 }
219                 break;
220             default:
221                 // Should not reach here
222                 ALOGE("%s: Unkown tag 0x%x", __FUNCTION__, tag);
223         }
224     }
225 
226     mData->update(tag, filteredDurations);
227 }
228 
229 void
filterStreamConfigurations()230 ACameraMetadata::filterStreamConfigurations() {
231     const int STREAM_CONFIGURATION_SIZE = 4;
232     const int STREAM_FORMAT_OFFSET = 0;
233     const int STREAM_WIDTH_OFFSET = 1;
234     const int STREAM_HEIGHT_OFFSET = 2;
235     const int STREAM_IS_INPUT_OFFSET = 3;
236     camera_metadata_entry entry = mData->find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
237     if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) {
238         ALOGE("%s: malformed available stream configuration key! count %zu, type %d",
239                 __FUNCTION__, entry.count, entry.type);
240         return;
241     }
242 
243     Vector<int32_t> filteredStreamConfigs;
244     filteredStreamConfigs.setCapacity(entry.count);
245 
246     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
247         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
248         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
249         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
250         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
251         if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT) {
252             // Hide input streams
253             continue;
254         }
255         // Translate HAL formats to NDK format
256         if (format == HAL_PIXEL_FORMAT_BLOB) {
257             format = AIMAGE_FORMAT_JPEG;
258         }
259         filteredStreamConfigs.push_back(format);
260         filteredStreamConfigs.push_back(width);
261         filteredStreamConfigs.push_back(height);
262         filteredStreamConfigs.push_back(isInput);
263     }
264 
265     if (filteredStreamConfigs.size() > 0) {
266         mData->update(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, filteredStreamConfigs);
267     }
268 
269     entry = mData->find(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS);
270     if (entry.count > 0 && (entry.count % 4 || entry.type != TYPE_INT32)) {
271         ALOGE("%s: malformed available depth stream configuration key! count %zu, type %d",
272                 __FUNCTION__, entry.count, entry.type);
273         return;
274     }
275 
276     Vector<int32_t> filteredDepthStreamConfigs;
277     filteredDepthStreamConfigs.setCapacity(entry.count);
278 
279     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
280         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
281         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
282         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
283         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
284         if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT) {
285             // Hide input streams
286             continue;
287         }
288         // Translate HAL formats to NDK format
289         if (format == HAL_PIXEL_FORMAT_BLOB) {
290             format = AIMAGE_FORMAT_DEPTH_POINT_CLOUD;
291         } else if (format == HAL_PIXEL_FORMAT_Y16) {
292             format = AIMAGE_FORMAT_DEPTH16;
293         }
294 
295         filteredDepthStreamConfigs.push_back(format);
296         filteredDepthStreamConfigs.push_back(width);
297         filteredDepthStreamConfigs.push_back(height);
298         filteredDepthStreamConfigs.push_back(isInput);
299     }
300 
301     if (filteredDepthStreamConfigs.size() > 0) {
302         mData->update(ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS,
303                 filteredDepthStreamConfigs);
304     }
305 
306     entry = mData->find(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS);
307     Vector<int32_t> filteredHeicStreamConfigs;
308     filteredHeicStreamConfigs.setCapacity(entry.count);
309 
310     for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
311         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
312         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
313         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
314         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
315         if (isInput == ACAMERA_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS_INPUT) {
316             // Hide input streams
317             continue;
318         }
319         // Translate HAL formats to NDK format
320         if (format == HAL_PIXEL_FORMAT_BLOB) {
321             format = AIMAGE_FORMAT_HEIC;
322         }
323 
324         filteredHeicStreamConfigs.push_back(format);
325         filteredHeicStreamConfigs.push_back(width);
326         filteredHeicStreamConfigs.push_back(height);
327         filteredHeicStreamConfigs.push_back(isInput);
328     }
329     mData->update(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, filteredHeicStreamConfigs);
330 
331     entry = mData->find(ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS);
332     Vector<int32_t> filteredDynamicDepthStreamConfigs;
333     filteredDynamicDepthStreamConfigs.setCapacity(entry.count);
334 
335     for (size_t i = 0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
336         int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
337         int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
338         int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
339         int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
340         if (isInput == ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_INPUT) {
341             // Hide input streams
342             continue;
343         }
344         // Translate HAL formats to NDK format
345         if (format == HAL_PIXEL_FORMAT_BLOB) {
346             format = AIMAGE_FORMAT_DEPTH_JPEG;
347         }
348 
349         filteredDynamicDepthStreamConfigs.push_back(format);
350         filteredDynamicDepthStreamConfigs.push_back(width);
351         filteredDynamicDepthStreamConfigs.push_back(height);
352         filteredDynamicDepthStreamConfigs.push_back(isInput);
353     }
354     mData->update(ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS,
355             filteredDynamicDepthStreamConfigs);
356 }
357 
358 bool
isVendorTag(const uint32_t tag)359 ACameraMetadata::isVendorTag(const uint32_t tag) {
360     uint32_t tag_section = tag >> 16;
361     if (tag_section >= VENDOR_SECTION) {
362         return true;
363     }
364     return false;
365 }
366 
367 camera_status_t
getConstEntry(uint32_t tag,ACameraMetadata_const_entry * entry) const368 ACameraMetadata::getConstEntry(uint32_t tag, ACameraMetadata_const_entry* entry) const {
369     if (entry == nullptr) {
370         return ACAMERA_ERROR_INVALID_PARAMETER;
371     }
372 
373     Mutex::Autolock _l(mLock);
374 
375     camera_metadata_ro_entry rawEntry = static_cast<const CameraMetadata*>(mData.get())->find(tag);
376     if (rawEntry.count == 0) {
377         ALOGE("%s: cannot find metadata tag %d", __FUNCTION__, tag);
378         return ACAMERA_ERROR_METADATA_NOT_FOUND;
379     }
380     entry->tag = tag;
381     entry->type = rawEntry.type;
382     entry->count = rawEntry.count;
383     entry->data.u8 = rawEntry.data.u8;
384     return ACAMERA_OK;
385 }
386 
387 camera_status_t
update(uint32_t tag,uint32_t count,const uint8_t * data)388 ACameraMetadata::update(uint32_t tag, uint32_t count, const uint8_t* data) {
389     return updateImpl<uint8_t>(tag, count, data);
390 }
391 
392 camera_status_t
update(uint32_t tag,uint32_t count,const int32_t * data)393 ACameraMetadata::update(uint32_t tag, uint32_t count, const int32_t* data) {
394     return updateImpl<int32_t>(tag, count, data);
395 }
396 
397 camera_status_t
update(uint32_t tag,uint32_t count,const float * data)398 ACameraMetadata::update(uint32_t tag, uint32_t count, const float* data) {
399     return updateImpl<float>(tag, count, data);
400 }
401 
402 camera_status_t
update(uint32_t tag,uint32_t count,const double * data)403 ACameraMetadata::update(uint32_t tag, uint32_t count, const double* data) {
404     return updateImpl<double>(tag, count, data);
405 }
406 
407 camera_status_t
update(uint32_t tag,uint32_t count,const int64_t * data)408 ACameraMetadata::update(uint32_t tag, uint32_t count, const int64_t* data) {
409     return updateImpl<int64_t>(tag, count, data);
410 }
411 
412 camera_status_t
update(uint32_t tag,uint32_t count,const ACameraMetadata_rational * data)413 ACameraMetadata::update(uint32_t tag, uint32_t count, const ACameraMetadata_rational* data) {
414     return updateImpl<camera_metadata_rational_t>(tag, count, data);
415 }
416 
417 camera_status_t
getTags(int32_t * numTags,const uint32_t ** tags) const418 ACameraMetadata::getTags(/*out*/int32_t* numTags,
419                          /*out*/const uint32_t** tags) const {
420     Mutex::Autolock _l(mLock);
421     if (mTags.size() == 0) {
422         size_t entry_count = mData->entryCount();
423         mTags.setCapacity(entry_count);
424         const camera_metadata_t* rawMetadata = mData->getAndLock();
425         for (size_t i = 0; i < entry_count; i++) {
426             camera_metadata_ro_entry_t entry;
427             int ret = get_camera_metadata_ro_entry(rawMetadata, i, &entry);
428             if (ret != 0) {
429                 ALOGE("%s: error reading metadata index %zu", __FUNCTION__, i);
430                 return ACAMERA_ERROR_UNKNOWN;
431             }
432             // Hide system key from users
433             if (sSystemTags.count(entry.tag) == 0) {
434                 mTags.push_back(entry.tag);
435             }
436         }
437         mData->unlock(rawMetadata);
438     }
439 
440     *numTags = mTags.size();
441     *tags = mTags.array();
442     return ACAMERA_OK;
443 }
444 
445 const CameraMetadata&
getInternalData() const446 ACameraMetadata::getInternalData() const {
447     return (*mData);
448 }
449 
450 bool
isLogicalMultiCamera(size_t * count,const char * const ** physicalCameraIds) const451 ACameraMetadata::isLogicalMultiCamera(size_t* count, const char*const** physicalCameraIds) const {
452     if (mType != ACM_CHARACTERISTICS) {
453         ALOGE("%s must be called for a static metadata!", __FUNCTION__);
454         return false;
455     }
456     if (count == nullptr || physicalCameraIds == nullptr) {
457         ALOGE("%s: Invalid input count: %p, physicalCameraIds: %p", __FUNCTION__,
458                 count, physicalCameraIds);
459         return false;
460     }
461 
462     if (mStaticPhysicalCameraIds.size() >= 2) {
463         *count = mStaticPhysicalCameraIds.size();
464         *physicalCameraIds = mStaticPhysicalCameraIds.data();
465         return true;
466     }
467 
468     return false;
469 }
470 
471 // TODO: some of key below should be hidden from user
472 // ex: ACAMERA_REQUEST_ID and ACAMERA_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR
473 /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
474  * The key entries below this point are generated from metadata
475  * definitions in /system/media/camera/docs. Do not modify by hand or
476  * modify the comment blocks at the start or end.
477  *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~*/
478 
479 bool
isCaptureRequestTag(const uint32_t tag)480 ACameraMetadata::isCaptureRequestTag(const uint32_t tag) {
481     // Skip check for vendor keys
482     if (isVendorTag(tag)) {
483         return true;
484     }
485 
486     switch (tag) {
487         case ACAMERA_COLOR_CORRECTION_MODE:
488         case ACAMERA_COLOR_CORRECTION_TRANSFORM:
489         case ACAMERA_COLOR_CORRECTION_GAINS:
490         case ACAMERA_COLOR_CORRECTION_ABERRATION_MODE:
491         case ACAMERA_CONTROL_AE_ANTIBANDING_MODE:
492         case ACAMERA_CONTROL_AE_EXPOSURE_COMPENSATION:
493         case ACAMERA_CONTROL_AE_LOCK:
494         case ACAMERA_CONTROL_AE_MODE:
495         case ACAMERA_CONTROL_AE_REGIONS:
496         case ACAMERA_CONTROL_AE_TARGET_FPS_RANGE:
497         case ACAMERA_CONTROL_AE_PRECAPTURE_TRIGGER:
498         case ACAMERA_CONTROL_AF_MODE:
499         case ACAMERA_CONTROL_AF_REGIONS:
500         case ACAMERA_CONTROL_AF_TRIGGER:
501         case ACAMERA_CONTROL_AWB_LOCK:
502         case ACAMERA_CONTROL_AWB_MODE:
503         case ACAMERA_CONTROL_AWB_REGIONS:
504         case ACAMERA_CONTROL_CAPTURE_INTENT:
505         case ACAMERA_CONTROL_EFFECT_MODE:
506         case ACAMERA_CONTROL_MODE:
507         case ACAMERA_CONTROL_SCENE_MODE:
508         case ACAMERA_CONTROL_VIDEO_STABILIZATION_MODE:
509         case ACAMERA_CONTROL_POST_RAW_SENSITIVITY_BOOST:
510         case ACAMERA_CONTROL_ENABLE_ZSL:
511         case ACAMERA_CONTROL_EXTENDED_SCENE_MODE:
512         case ACAMERA_CONTROL_ZOOM_RATIO:
513         case ACAMERA_EDGE_MODE:
514         case ACAMERA_FLASH_MODE:
515         case ACAMERA_HOT_PIXEL_MODE:
516         case ACAMERA_JPEG_GPS_COORDINATES:
517         case ACAMERA_JPEG_GPS_PROCESSING_METHOD:
518         case ACAMERA_JPEG_GPS_TIMESTAMP:
519         case ACAMERA_JPEG_ORIENTATION:
520         case ACAMERA_JPEG_QUALITY:
521         case ACAMERA_JPEG_THUMBNAIL_QUALITY:
522         case ACAMERA_JPEG_THUMBNAIL_SIZE:
523         case ACAMERA_LENS_APERTURE:
524         case ACAMERA_LENS_FILTER_DENSITY:
525         case ACAMERA_LENS_FOCAL_LENGTH:
526         case ACAMERA_LENS_FOCUS_DISTANCE:
527         case ACAMERA_LENS_OPTICAL_STABILIZATION_MODE:
528         case ACAMERA_NOISE_REDUCTION_MODE:
529         case ACAMERA_SCALER_CROP_REGION:
530         case ACAMERA_SENSOR_EXPOSURE_TIME:
531         case ACAMERA_SENSOR_FRAME_DURATION:
532         case ACAMERA_SENSOR_SENSITIVITY:
533         case ACAMERA_SENSOR_TEST_PATTERN_DATA:
534         case ACAMERA_SENSOR_TEST_PATTERN_MODE:
535         case ACAMERA_SHADING_MODE:
536         case ACAMERA_STATISTICS_FACE_DETECT_MODE:
537         case ACAMERA_STATISTICS_HOT_PIXEL_MAP_MODE:
538         case ACAMERA_STATISTICS_LENS_SHADING_MAP_MODE:
539         case ACAMERA_STATISTICS_OIS_DATA_MODE:
540         case ACAMERA_TONEMAP_CURVE_BLUE:
541         case ACAMERA_TONEMAP_CURVE_GREEN:
542         case ACAMERA_TONEMAP_CURVE_RED:
543         case ACAMERA_TONEMAP_MODE:
544         case ACAMERA_TONEMAP_GAMMA:
545         case ACAMERA_TONEMAP_PRESET_CURVE:
546         case ACAMERA_BLACK_LEVEL_LOCK:
547         case ACAMERA_DISTORTION_CORRECTION_MODE:
548             return true;
549         default:
550             return false;
551     }
552 }
553 
554 // System tags that should be hidden from users
555 std::unordered_set<uint32_t> ACameraMetadata::sSystemTags ({
556     ANDROID_CONTROL_SCENE_MODE_OVERRIDES,
557     ANDROID_CONTROL_AE_PRECAPTURE_ID,
558     ANDROID_CONTROL_AF_TRIGGER_ID,
559     ANDROID_DEMOSAIC_MODE,
560     ANDROID_EDGE_STRENGTH,
561     ANDROID_FLASH_FIRING_POWER,
562     ANDROID_FLASH_FIRING_TIME,
563     ANDROID_FLASH_COLOR_TEMPERATURE,
564     ANDROID_FLASH_MAX_ENERGY,
565     ANDROID_FLASH_INFO_CHARGE_DURATION,
566     ANDROID_JPEG_MAX_SIZE,
567     ANDROID_JPEG_SIZE,
568     ANDROID_NOISE_REDUCTION_STRENGTH,
569     ANDROID_QUIRKS_METERING_CROP_REGION,
570     ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO,
571     ANDROID_QUIRKS_USE_ZSL_FORMAT,
572     ANDROID_REQUEST_INPUT_STREAMS,
573     ANDROID_REQUEST_METADATA_MODE,
574     ANDROID_REQUEST_OUTPUT_STREAMS,
575     ANDROID_REQUEST_TYPE,
576     ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS,
577     ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS,
578     ANDROID_SCALER_AVAILABLE_RAW_SIZES,
579     ANDROID_SENSOR_BASE_GAIN_FACTOR,
580     ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS,
581     ANDROID_SENSOR_TEMPERATURE,
582     ANDROID_SENSOR_PROFILE_HUE_SAT_MAP,
583     ANDROID_SENSOR_PROFILE_TONE_CURVE,
584     ANDROID_SENSOR_OPAQUE_RAW_SIZE,
585     ANDROID_SHADING_STRENGTH,
586     ANDROID_STATISTICS_HISTOGRAM_MODE,
587     ANDROID_STATISTICS_SHARPNESS_MAP_MODE,
588     ANDROID_STATISTICS_HISTOGRAM,
589     ANDROID_STATISTICS_SHARPNESS_MAP,
590     ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
591     ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT,
592     ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE,
593     ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE,
594     ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION,
595     ANDROID_DEPTH_MAX_DEPTH_SAMPLES,
596     ANDROID_HEIC_INFO_SUPPORTED,
597     ANDROID_HEIC_INFO_MAX_JPEG_APP_SEGMENTS_COUNT,
598 });
599 
600 /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
601  * End generated code
602  *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
603