summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorShuzhen Wang <shuzhenwang@google.com>2018-08-20 12:00:05 -0700
committerShuzhen Wang <shuzhenwang@google.com>2018-09-12 09:53:46 -0700
commit123deefc2cff55e26b40332453b9428dea03a85f (patch)
treea2531bd6fafdc6fb221c36d75fcd382640e21316 /core/java
parent1941814f8e9b44d91f996b137e8683fbf80bc70a (diff)
Camera: Add support for hidden physical camera ID
Add the support where characteristics of a hidden physical camera ID can be queried by getCameraCharacteristics, but openCamera() cannot open that camera. Test: make offline-sdk-docs Test: Camera CTS Bug: 79523700 Change-Id: I0876f924da13e0e70ed0bf09ad937f08b076d492
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/hardware/camera2/CameraCharacteristics.java7
-rw-r--r--core/java/android/hardware/camera2/CameraManager.java42
-rw-r--r--core/java/android/hardware/camera2/CameraMetadata.java10
3 files changed, 52 insertions, 7 deletions
diff --git a/core/java/android/hardware/camera2/CameraCharacteristics.java b/core/java/android/hardware/camera2/CameraCharacteristics.java
index 35584ae21869..07fe73066fd0 100644
--- a/core/java/android/hardware/camera2/CameraCharacteristics.java
+++ b/core/java/android/hardware/camera2/CameraCharacteristics.java
@@ -474,6 +474,13 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
* REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA capability. If the camera device
* doesn't have the capability, the return value will be an empty set. </p>
*
+ * <p>Prior to API level 29, all returned IDs are guaranteed to be returned by {@link
+ * CameraManager#getCameraIdList}, and can be opened directly by
+ * {@link CameraManager#openCamera}. Starting from API level 29, for each of the returned ID,
+ * if it's also returned by {@link CameraManager#getCameraIdList}, it can be used as a
+ * standalone camera by {@link CameraManager#openCamera}. Otherwise, the camera ID can only be
+ * used as part of the current logical camera.</p>
+ *
* <p>The set returned is not modifiable, so any attempts to modify it will throw
* a {@code UnsupportedOperationException}.</p>
*
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index 7ebe0f9a8d8d..44d7364ce43c 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -34,7 +34,6 @@ import android.os.Binder;
import android.os.DeadObjectException;
import android.os.Handler;
import android.os.IBinder;
-import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
@@ -45,7 +44,6 @@ import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
-
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
@@ -97,6 +95,9 @@ public final class CameraManager {
* identifiers, while removable cameras have a unique identifier for each
* individual device, even if they are the same model.</p>
*
+ * <p>This list doesn't contain physical cameras that can only used as part of a logical
+ * multi-camera device.</p>
+ *
* @return The list of currently connected camera devices.
*/
@NonNull
@@ -234,7 +235,13 @@ public final class CameraManager {
* <p>Query the capabilities of a camera device. These capabilities are
* immutable for a given camera.</p>
*
- * @param cameraId The id of the camera device to query
+ * <p>From API level 29, this function can also be used to query the capabilities of physical
+ * cameras that can only be used as part of logical multi-camera. These cameras cannot not be
+ * opened directly via {@link #openCamera}</p>
+ *
+ * @param cameraId The id of the camera device to query. This could be either a standalone
+ * camera ID which can be directly opened by {@link #openCamera}, or a physical camera ID that
+ * can only used as part of a logical multi-camera.
* @return The properties of the given camera
*
* @throws IllegalArgumentException if the cameraId does not match any
@@ -262,7 +269,9 @@ public final class CameraManager {
"Camera service is currently unavailable");
}
try {
- if (!supportsCamera2ApiLocked(cameraId)) {
+ // First check isHiddenPhysicalCamera to avoid supportsCamera2ApiLocked throwing
+ // exception in case cameraId is a hidden physical camera.
+ if (!isHiddenPhysicalCamera(cameraId) && !supportsCamera2ApiLocked(cameraId)) {
// Legacy backwards compatibility path; build static info from the camera
// parameters
int id = Integer.parseInt(cameraId);
@@ -454,7 +463,7 @@ public final class CameraManager {
*
* @throws IllegalArgumentException if cameraId or the callback was null,
* or the cameraId does not match any currently or previously available
- * camera device.
+ * camera device returned by {@link #getCameraIdList}.
*
* @throws SecurityException if the application does not have permission to
* access the camera
@@ -778,6 +787,29 @@ public final class CameraManager {
}
/**
+ * Queries the camera service if a cameraId is a hidden physical camera that belongs to a
+ * logical camera device.
+ *
+ * A hidden physical camera is a camera that cannot be opened by the application. But it
+ * can be used as part of a logical camera.
+ *
+ * @param cameraId a non-{@code null} camera identifier
+ * @return {@code true} if cameraId is a hidden physical camera device
+ */
+ private boolean isHiddenPhysicalCamera(String cameraId) {
+ try {
+ ICameraService cameraService = CameraManagerGlobal.get().getCameraService();
+ // If no camera service, no support
+ if (cameraService == null) return false;
+
+ return cameraService.isHiddenPhysicalCamera(cameraId);
+ } catch (RemoteException e) {
+ // Camera service is now down, no support for any API level
+ }
+ return false;
+ }
+
+ /**
* A per-process global camera manager instance, to retain a connection to the camera service,
* and to distribute camera availability notices to API-registered callbacks
*/
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index caa99d5cb2a8..b6db6f22a498 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -811,8 +811,14 @@ public abstract class CameraMetadata<TKey> {
public static final int REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING = 10;
/**
- * <p>The camera device is a logical camera backed by two or more physical cameras that are
- * also exposed to the application.</p>
+ * <p>The camera device is a logical camera backed by two or more physical cameras. In
+ * API level 28, the physical cameras must also be exposed to the application via
+ * {@link android.hardware.camera2.CameraManager#getCameraIdList }. Starting from API
+ * level 29, some or all physical cameras may not be independently exposed to the
+ * application, in which case the physical camera IDs will not be available in
+ * {@link android.hardware.camera2.CameraManager#getCameraIdList }. But the application
+ * can still query the physical cameras' characteristics by calling
+ * {@link android.hardware.camera2.CameraManager#getCameraCharacteristics }.</p>
* <p>Camera application shouldn't assume that there are at most 1 rear camera and 1 front
* camera in the system. For an application that switches between front and back cameras,
* the recommendation is to switch between the first rear camera and the first front