diff options
Diffstat (limited to 'java/com/android/dialer/callcomposer/camera/CameraManager.java')
-rw-r--r-- | java/com/android/dialer/callcomposer/camera/CameraManager.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/java/com/android/dialer/callcomposer/camera/CameraManager.java b/java/com/android/dialer/callcomposer/camera/CameraManager.java index 977f063df..4cc08ba32 100644 --- a/java/com/android/dialer/callcomposer/camera/CameraManager.java +++ b/java/com/android/dialer/callcomposer/camera/CameraManager.java @@ -522,7 +522,6 @@ public class CameraManager implements FocusOverlayManager.Listener { switch (windowManager.getDefaultDisplay().getRotation()) { case Surface.ROTATION_0: degrees = 0; - mCamera.setDisplayOrientation(90); break; case Surface.ROTATION_90: degrees = 90; @@ -532,22 +531,31 @@ public class CameraManager implements FocusOverlayManager.Listener { break; case Surface.ROTATION_270: degrees = 270; - mCamera.setDisplayOrientation(180); break; default: throw Assert.createAssertionFailException(""); } + // The display orientation of the camera (this controls the preview image). + int orientation; + // The clockwise rotation angle relative to the orientation of the camera. This affects // pictures returned by the camera in Camera.PictureCallback. + int rotation; if (mCameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { - mRotation = (mCameraInfo.orientation + degrees) % 360; + orientation = (mCameraInfo.orientation + degrees) % 360; + rotation = orientation; + // compensate the mirror but only for orientation + orientation = (360 - orientation) % 360; } else { // back-facing - mRotation = (mCameraInfo.orientation - degrees + 360) % 360; + orientation = (mCameraInfo.orientation - degrees + 360) % 360; + rotation = orientation; } + mRotation = rotation; try { + mCamera.setDisplayOrientation(orientation); final Camera.Parameters params = mCamera.getParameters(); - params.setRotation(mRotation); + params.setRotation(rotation); mCamera.setParameters(params); } catch (final RuntimeException e) { LogUtil.e( @@ -581,6 +589,7 @@ public class CameraManager implements FocusOverlayManager.Listener { mOrientationHandler.disable(); mOrientationHandler = null; } + // releaseMediaRecorder(true /* cleanupFile */); mFocusOverlayManager.onPreviewStopped(); return; } |