Move display orientation calculations out of app code

Because they're needed by every app, these are being relocated into the
portability layer. As such, the CameraUtil#getDisplayOrientation() and
CameraUtil#getJpegRotation() methods are being replaced by the API-agnostic
CameraDeviceInfo.Characteristics#getPreviewOrientation() and
CameraDeviceInfo.Characteristics#getJpegOrientation() calls, respectively.

Change-Id: I5048e6f1a5ff655e4ea260b109e7c104bbe790b0
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index c39766b..8e642de 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1275,17 +1275,14 @@
         // Set rotation and gps data.
         int orientation;
 
-        // We need to be consistent with the framework orientation (i.e. the
-        // orientation of the UI.) when the auto-rotate screen setting is on.
         if (mActivity.isAutoRotateScreen()) {
-            orientation = (360 - mDisplayRotation) % 360;
+            orientation = mDisplayRotation;
         } else {
             orientation = mOrientation;
         }
         Characteristics info =
                 mActivity.getCameraProvider().getCharacteristics(mCameraId);
-        mJpegRotation = CameraUtil.getJpegRotation(info, orientation);
-        mCameraSettings.setPhotoRotationDegrees(mJpegRotation);
+        mJpegRotation = info.getJpegOrientation(orientation);
         Location loc = mActivity.getLocationManager().getCurrentLocation();
         CameraUtil.setGpsParameters(mCameraSettings, loc);
         mCameraDevice.applySettings(mCameraSettings);
@@ -1860,7 +1857,7 @@
         mDisplayRotation = CameraUtil.getDisplayRotation(mActivity);
         Characteristics info =
                 mActivity.getCameraProvider().getCharacteristics(mCameraId);
-        mDisplayOrientation = CameraUtil.getDisplayOrientation(mDisplayRotation, info);
+        mDisplayOrientation = info.getPreviewOrientation(mDisplayRotation);
         mCameraDisplayOrientation = mDisplayOrientation;
         mUI.setDisplayOrientation(mDisplayOrientation);
         if (mFocusManager != null) {
@@ -1868,7 +1865,7 @@
         }
         // Change the camera display orientation
         if (mCameraDevice != null) {
-            mCameraDevice.setDisplayOrientation(mCameraDisplayOrientation);
+            mCameraDevice.setDisplayOrientation(mDisplayRotation);
         }
     }