1 /* 2 * Copyright (C) 2023 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 package com.android.cts.verifier.camera.its; 18 19 import android.hardware.camera2.CaptureResult; 20 import android.hardware.camera2.TotalCaptureResult; 21 22 import java.util.HashMap; 23 import java.util.List; 24 import java.util.Set; 25 26 /** Convenience class to record certain fields of a CaptureResult. */ 27 public class RecordingResult { 28 public static final List<CaptureResult.Key<?>> PREVIEW_RESULT_TRACKED_KEYS = List.of( 29 CaptureResult.CONTROL_ZOOM_RATIO, 30 CaptureResult.LENS_FOCAL_LENGTH, 31 CaptureResult.LENS_FOCUS_DISTANCE, 32 CaptureResult.SCALER_CROP_REGION, 33 CaptureResult.LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID, 34 CaptureResult.LENS_INTRINSIC_CALIBRATION, 35 // TODO: b/332581106 - Evaluate if data added by samples surpasses socket limit 36 CaptureResult.STATISTICS_LENS_INTRINSICS_SAMPLES, 37 CaptureResult.SENSOR_TIMESTAMP 38 ); 39 40 HashMap<CaptureResult.Key<?>, Object> mMap; 41 RecordingResult()42 public RecordingResult() { 43 mMap = new HashMap<>(); 44 } addKey(TotalCaptureResult result, CaptureResult.Key<?> key)45 public void addKey(TotalCaptureResult result, CaptureResult.Key<?> key) { 46 mMap.put(key, result.get(key)); 47 } addKeys(TotalCaptureResult result, Iterable<CaptureResult.Key<?>> keys)48 public void addKeys(TotalCaptureResult result, 49 Iterable<CaptureResult.Key<?>> keys) { 50 for (CaptureResult.Key<?> k : keys) { 51 this.addKey(result, k); 52 } 53 } getKeys()54 public Set<CaptureResult.Key<?>> getKeys() { 55 return mMap.keySet(); 56 } getResult(CaptureResult.Key<T> key)57 public <T> T getResult(CaptureResult.Key<T> key) { 58 return (T) mMap.get(key); 59 } 60 }