Loading core/java/android/hardware/camera2/CameraCharacteristics.java +7 −0 Original line number Diff line number Diff line Loading @@ -521,6 +521,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> * Loading core/java/android/hardware/camera2/CameraManager.java +37 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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 Loading Loading @@ -777,6 +786,29 @@ public final class CameraManager { return false; } /** * 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 Loading core/java/android/hardware/camera2/CameraMetadata.java +8 −2 Original line number Diff line number Diff line Loading @@ -813,8 +813,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 Loading Loading
core/java/android/hardware/camera2/CameraCharacteristics.java +7 −0 Original line number Diff line number Diff line Loading @@ -521,6 +521,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> * Loading
core/java/android/hardware/camera2/CameraManager.java +37 −5 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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 Loading Loading @@ -777,6 +786,29 @@ public final class CameraManager { return false; } /** * 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 Loading
core/java/android/hardware/camera2/CameraMetadata.java +8 −2 Original line number Diff line number Diff line Loading @@ -813,8 +813,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 Loading