From 7ce697009dd1d29154a38bf78f37d6a8e9232c8e 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(-) (limited to 'src/com/android/camera/util/CameraUtil.java') diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 172a54582..524595bcc 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -842,13 +842,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