Merge "DeviceInfo: Collect hidden physical camera characteristics" into rvc-dev am: e2ea63d089
Original change: https://googleplex-android-review.googlesource.com/c/platform/cts/+/12037678
Change-Id: Ia0b715dadd69397946598588291b043b8047c00e
diff --git a/tools/cts-device-info/src/com/android/cts/deviceinfo/CameraDeviceInfo.java b/tools/cts-device-info/src/com/android/cts/deviceinfo/CameraDeviceInfo.java
index 698990f..e0fcbb0 100644
--- a/tools/cts-device-info/src/com/android/cts/deviceinfo/CameraDeviceInfo.java
+++ b/tools/cts-device-info/src/com/android/cts/deviceinfo/CameraDeviceInfo.java
@@ -41,6 +41,8 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -79,6 +81,23 @@
return;
}
+ public void storePhysicalCameraInfo(String cameraId, List<String> logicalCameras)
+ throws Exception {
+ try {
+ CameraCharacteristics chars = mCameraManager.getCameraCharacteristics(cameraId);
+ mStore.startGroup(); // per camera chars
+ mStore.addResult("cameraId", cameraId);
+ mStore.addListResult("parentLogicalCameraIds", logicalCameras);
+ storeCameraChars(chars);
+ mStore.endGroup(); // per camera chars
+ } catch (CameraAccessException e) {
+ Log.e(TAG,
+ "Unable to get camera camera static info, skip this camera, error: "
+ + e.getMessage());
+ }
+ return;
+ }
+
private void storeRational(
Rational rat, String protoName) throws Exception {
if (protoName == null) {
@@ -420,6 +439,8 @@
getContext().getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIdList = cameraManager.getCameraIdList();
+ HashMap<String, ArrayList<String>> physicalLogicalIdMap =
+ new HashMap<String, ArrayList<String>>();
store.addResult("num_of_camera", cameraIdList.length);
if (cameraIdList.length > 0) {
CameraCharacteristicsStorer charsStorer =
@@ -427,8 +448,32 @@
store.startArray("per_camera_info");
for (int i = 0; i < cameraIdList.length; i++) {
charsStorer.storeCameraInfo(cameraIdList[i]);
+
+ // Get the physical camera ids
+ CameraCharacteristics ch = cameraManager.getCameraCharacteristics(
+ cameraIdList[i]);
+ for (String physicalId : ch.getPhysicalCameraIds()) {
+ if (physicalLogicalIdMap.get(physicalId) == null) {
+ physicalLogicalIdMap.put(physicalId, new ArrayList<String>());
+ }
+ physicalLogicalIdMap.get(physicalId).add(cameraIdList[i]);
+ }
}
store.endArray(); // per_camera_info
+
+ // Store characteristics for hidden physical camera ids
+ for (int i = 0; i < cameraIdList.length; ++i) {
+ physicalLogicalIdMap.remove(cameraIdList[i]);
+ }
+ if (physicalLogicalIdMap.size() > 0) {
+ store.addResult("num_of_hidden_physical_camera", physicalLogicalIdMap.size());
+ store.startArray("per_hidden_physical_camera_info");
+ for (String physicalId : physicalLogicalIdMap.keySet()) {
+ charsStorer.storePhysicalCameraInfo(physicalId,
+ physicalLogicalIdMap.get(physicalId));
+ }
+ store.endArray(); // per_hidden_physical_camera_info
+ }
}
} catch (CameraAccessException e) {
Log.e(TAG,