diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-11-08 11:10:07 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-11-08 12:38:48 +0800 |
commit | 07b88fefd4e6386ad3265da47d008b40e6a58891 (patch) | |
tree | 289956f94c54708c3b10b6767f189cdee7f8dc57 /core/java | |
parent | 31dc911aee2b50752c0eb7785176075cdaed139c (diff) | |
download | frameworks_base-07b88fefd4e6386ad3265da47d008b40e6a58891.zip frameworks_base-07b88fefd4e6386ad3265da47d008b40e6a58891.tar.gz frameworks_base-07b88fefd4e6386ad3265da47d008b40e6a58891.tar.bz2 |
android.hardware.Camera.open only returns back-facing camera.
bug:3173302
Change-Id: I813e41b36c776246f151b66ef289cdf13a05dc2c
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/hardware/Camera.java | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 275e2eb..378189e 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -211,8 +211,7 @@ public class Camera { * blocking the main application UI thread. * * @param cameraId the hardware camera to access, between 0 and - * {@link #getNumberOfCameras()}-1. Use {@link #CAMERA_ID_DEFAULT} - * to access the default camera. + * {@link #getNumberOfCameras()}-1. * @return a new Camera object, connected, locked and ready for use. * @throws RuntimeException if connection to the camera service fails (for * example, if the camera is in use by another process). @@ -222,18 +221,21 @@ public class Camera { } /** - * The id for the default camera. - * @see #open(int) - */ - public static int CAMERA_ID_DEFAULT = 0; - - /** - * Equivalent to Camera.open(Camera.CAMERA_ID_DEFAULT). - * Creates a new Camera object to access the default camera. + * Creates a new Camera object to access the first back-facing camera on the + * device. If the device does not have a back-facing camera, this returns + * null. * @see #open(int) */ public static Camera open() { - return new Camera(CAMERA_ID_DEFAULT); + int numberOfCameras = getNumberOfCameras(); + CameraInfo cameraInfo = new CameraInfo(); + for (int i = 0; i < numberOfCameras; i++) { + getCameraInfo(i, cameraInfo); + if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { + return new Camera(i); + } + } + return null; } Camera(int cameraId) { |