From 14dface2f352ed0dc815884d18e22ef79dfcbbbf Mon Sep 17 00:00:00 2001 From: weijiew Date: Thu, 8 Sep 2016 10:59:12 +0800 Subject: SnapdragonCamera: Pictures were rotated when the device is in flat position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally, the picture taken by front camera needs to rotate 270 degree and the picture taken by rear camera needs to rotate 90 degree. Launch camera app when the device is in a close to flat position, camera app can’t get device’s orientation. The picture will not be rotated when the orientation is unknown. Change-Id: I41d19f162f28aa6838b0246f14475480c8703e06 CRs-Fixed: 1063452 --- src/com/android/camera/util/CameraUtil.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 5af83bcf9..bda83a1d9 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -882,13 +882,14 @@ public class CameraUtil { // See android.hardware.Camera.Parameters.setRotation for // documentation. int rotation = 0; - if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) { - CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId]; - if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { - rotation = (info.orientation - orientation + 360) % 360; - } else { // back-facing camera - rotation = (info.orientation + orientation) % 360; - } + if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) { + orientation = 0; + } + CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId]; + if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { + rotation = (info.orientation - orientation + 360) % 360; + } else { // back-facing camera + rotation = (info.orientation + orientation) % 360; } return rotation; } -- cgit v1.2.3