diff options
Diffstat (limited to 'android/hardware/camera2')
-rw-r--r-- | android/hardware/camera2/CameraManager.java | 34 | ||||
-rw-r--r-- | android/hardware/camera2/CaptureRequest.java | 6 | ||||
-rw-r--r-- | android/hardware/camera2/CaptureResult.java | 6 |
3 files changed, 42 insertions, 4 deletions
diff --git a/android/hardware/camera2/CameraManager.java b/android/hardware/camera2/CameraManager.java index 4124536d..7ebe0f9a 100644 --- a/android/hardware/camera2/CameraManager.java +++ b/android/hardware/camera2/CameraManager.java @@ -43,6 +43,9 @@ import android.util.ArrayMap; 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; @@ -924,6 +927,37 @@ public final class CameraManager { idCount++; } } + + // The sort logic must match the logic in + // libcameraservice/common/CameraProviderManager.cpp::getAPI1CompatibleCameraDeviceIds + Arrays.sort(cameraIds, new Comparator<String>() { + @Override + public int compare(String s1, String s2) { + int s1Int = 0, s2Int = 0; + try { + s1Int = Integer.parseInt(s1); + } catch (NumberFormatException e) { + s1Int = -1; + } + + try { + s2Int = Integer.parseInt(s2); + } catch (NumberFormatException e) { + s2Int = -1; + } + + // Uint device IDs first + if (s1Int >= 0 && s2Int >= 0) { + return s1Int - s2Int; + } else if (s1Int >= 0) { + return -1; + } else if (s2Int >= 0) { + return 1; + } else { + // Simple string compare if both id are not uint + return s1.compareTo(s2); + } + }}); return cameraIds; } diff --git a/android/hardware/camera2/CaptureRequest.java b/android/hardware/camera2/CaptureRequest.java index 22525719..411a97e3 100644 --- a/android/hardware/camera2/CaptureRequest.java +++ b/android/hardware/camera2/CaptureRequest.java @@ -2105,8 +2105,8 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * the thumbnail data will also be rotated.</p> * <p>Note that this orientation is relative to the orientation of the camera sensor, given * by {@link CameraCharacteristics#SENSOR_ORIENTATION android.sensor.orientation}.</p> - * <p>To translate from the device orientation given by the Android sensor APIs, the following - * sample code may be used:</p> + * <p>To translate from the device orientation given by the Android sensor APIs for camera + * sensors which are not EXTERNAL, the following sample code may be used:</p> * <pre><code>private int getJpegOrientation(CameraCharacteristics c, int deviceOrientation) { * if (deviceOrientation == android.view.OrientationEventListener.ORIENTATION_UNKNOWN) return 0; * int sensorOrientation = c.get(CameraCharacteristics.SENSOR_ORIENTATION); @@ -2125,6 +2125,8 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>> * return jpegOrientation; * } * </code></pre> + * <p>For EXTERNAL cameras the sensor orientation will always be set to 0 and the facing will + * also be set to EXTERNAL. The above code is not relevant in such case.</p> * <p><b>Units</b>: Degrees in multiples of 90</p> * <p><b>Range of valid values:</b><br> * 0, 90, 180, 270</p> diff --git a/android/hardware/camera2/CaptureResult.java b/android/hardware/camera2/CaptureResult.java index 8df54472..c1566161 100644 --- a/android/hardware/camera2/CaptureResult.java +++ b/android/hardware/camera2/CaptureResult.java @@ -2422,8 +2422,8 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * the thumbnail data will also be rotated.</p> * <p>Note that this orientation is relative to the orientation of the camera sensor, given * by {@link CameraCharacteristics#SENSOR_ORIENTATION android.sensor.orientation}.</p> - * <p>To translate from the device orientation given by the Android sensor APIs, the following - * sample code may be used:</p> + * <p>To translate from the device orientation given by the Android sensor APIs for camera + * sensors which are not EXTERNAL, the following sample code may be used:</p> * <pre><code>private int getJpegOrientation(CameraCharacteristics c, int deviceOrientation) { * if (deviceOrientation == android.view.OrientationEventListener.ORIENTATION_UNKNOWN) return 0; * int sensorOrientation = c.get(CameraCharacteristics.SENSOR_ORIENTATION); @@ -2442,6 +2442,8 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> { * return jpegOrientation; * } * </code></pre> + * <p>For EXTERNAL cameras the sensor orientation will always be set to 0 and the facing will + * also be set to EXTERNAL. The above code is not relevant in such case.</p> * <p><b>Units</b>: Degrees in multiples of 90</p> * <p><b>Range of valid values:</b><br> * 0, 90, 180, 270</p> |