Revert "Camera2: Fix for Camera Preview upside down in 0v5670 module"

This is no longer needed given the solution/workaround in framework now.

This reverts commit 37c0d3e2a61683c5cdf68c56740e675e9268f842.

Issue: FP2A10-176
Change-Id: Id9b829bc5357dc23e01c2091f4f1f6c7ea6d0ff0
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 7dbee6b..ddba88e 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -22,7 +22,6 @@
 import android.graphics.Point;
 import android.graphics.RectF;
 import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
 import android.location.Location;
 import android.media.MediaActionSound;
 import android.net.Uri;
@@ -149,8 +148,6 @@
     private CaptureModuleUI mUI;
     /** The camera manager used to open cameras. */
     private OneCameraOpener mOneCameraOpener;
-
-    private int mCameraId;
     /** The manager to query for camera device information */
     private OneCameraManager mOneCameraManager;
     /** The currently opened camera device, or null if the camera is closed. */
@@ -328,7 +325,6 @@
     /** Whether the module is paused right now. */
     private boolean mPaused;
 
-    private int curcameraid;
     /** Main thread. */
     private final MainThread mMainThread;
     /** Handler thread for camera-related operations. */
@@ -452,8 +448,6 @@
         }
 
         mDisplayRotation = CameraUtil.getDisplayRotation();
-        curcameraid = mSettingsManager.getInteger(
-              mAppController.getModuleScope(), Keys.KEY_CAMERA_ID);
         mCameraFacing = getFacingFromCameraId(
               mSettingsManager.getInteger(mAppController.getModuleScope(), Keys.KEY_CAMERA_ID));
         mShowErrorAndFinish = !updateCameraCharacteristics();
@@ -1212,7 +1206,6 @@
                             cameraId);
 
                     Log.d(TAG, "Start to switch camera. cameraId=" + cameraId);
-                    curcameraid = cameraId;
                     mCameraFacing = getFacingFromCameraId(cameraId);
                     mShowErrorAndFinish = !updateCameraCharacteristics();
                     switchCamera();
@@ -1316,20 +1309,10 @@
                     }
                 }
             } else {
-                if (curcameraid == Camera.CameraInfo.CAMERA_FACING_FRONT) {
-                    int sensororientation =  mCameraCharacteristics.getSensorOrientation();
-                    int result = (sensororientation - mDisplayRotation + 360) % 360;
-                    Matrix transformMatrix = mPreviewTransformCalculator.toFp2TransformMatrix(
-                            new Size(mScreenWidth, mScreenHeight),
-                            new Size(mPreviewBufferWidth, mPreviewBufferHeight), result);
-                    mAppController.updatePreviewTransform(transformMatrix);
-                }
-                else {
-                    Matrix transformMatrix = mPreviewTransformCalculator.toTransformMatrix(
-                            new Size(mScreenWidth, mScreenHeight),
-                            new Size(mPreviewBufferWidth, mPreviewBufferHeight));
-                    mAppController.updatePreviewTransform(transformMatrix);
-                }
+                Matrix transformMatrix = mPreviewTransformCalculator.toTransformMatrix(
+                        new Size(mScreenWidth, mScreenHeight),
+                        new Size(mPreviewBufferWidth, mPreviewBufferHeight));
+                mAppController.updatePreviewTransform(transformMatrix);
             }
         }
     }
diff --git a/src/com/android/camera/captureintent/PreviewTransformCalculator.java b/src/com/android/camera/captureintent/PreviewTransformCalculator.java
index 2080a03..fd3ec02 100644
--- a/src/com/android/camera/captureintent/PreviewTransformCalculator.java
+++ b/src/com/android/camera/captureintent/PreviewTransformCalculator.java
@@ -73,82 +73,6 @@
 
         // Rotate buffer contents to proper orientation
         int rotateDegree = mOrientationManager.getDisplayRotation().getDegrees();
-        transformMatrix.postRotate(rotateDegree, previewViewCenter.x, previewViewCenter.y);
-
-        /**
-         * Scale to fit view, cropping the longest dimension.
-         *
-         * surfaceTextureSize is changed with the device orientation. Since
-         * previewStreamSize is always in landscape. To calculate the scale
-         * factor, previewStreamSize needs to be rotated if in portrait.
-         */
-        Size rotatedPreviewSize = previewStreamSize;
-        if (mOrientationManager.isInPortrait()) {
-            rotatedPreviewSize = new Size(previewStreamSize.height(), previewStreamSize.width());
-        }
-        float scale = Math.min(
-                (float) previewViewSize.width() / (float) rotatedPreviewSize.width(),
-                (float) previewViewSize.height() / (float) rotatedPreviewSize.height());
-        transformMatrix.postScale(scale, scale, previewViewCenter.x, previewViewCenter.y);
-
-        RectF scaledPreviewStreamRect = new RectF(
-                0.0f, 0.0f, previewStreamSize.width() * scale, previewStreamSize.height() * scale);
-        PointF scaledPreviewStreamCenter =
-                new PointF(scaledPreviewStreamRect.centerX(), scaledPreviewStreamRect.centerY());
-        transformMatrix.postTranslate(
-                scaledPreviewStreamCenter.x - previewViewCenter.x,
-                scaledPreviewStreamCenter.y - previewViewCenter.y);
-
-        return transformMatrix;
-    }
-
-    public Matrix toFp2TransformMatrix(Size previewViewSize, Size previewStreamSize , int result) {
-        RectF previewViewRect =
-                new RectF(0.0f, 0.0f, previewViewSize.width(), previewViewSize.height());
-        PointF previewViewCenter = new PointF(previewViewRect.centerX(), previewViewRect.centerY());
-
-        // If natural orientation is portrait, rotate the buffer dimensions.
-        Size previewBufferSize = previewStreamSize;
-
-        if (mOrientationManager.getDeviceNaturalOrientation() == OrientationManager.DeviceNaturalOrientation.PORTRAIT) {
-            previewBufferSize = new Size(previewStreamSize.height(), previewStreamSize.width());
-        }
-
-        Matrix transformMatrix = new Matrix();
-
-        // Adjust the effective preview rect to the center of the texture view.
-        final RectF PreviewBufferRect =
-                new RectF(0.0f, 0.0f, previewBufferSize.width(), previewBufferSize.height());
-        final PointF previewBufferCenter =
-                new PointF(PreviewBufferRect.centerX(), PreviewBufferRect.centerY());
-
-        final RectF centeredEffectivePreviewRect = new RectF(PreviewBufferRect);
-        centeredEffectivePreviewRect.offset(
-                previewViewCenter.x - previewBufferCenter.x,
-                previewViewCenter.y - previewBufferCenter.y);
-
-        // Undo ScaleToFit.FILL done by the surface
-        transformMatrix.setRectToRect(
-                previewViewRect, centeredEffectivePreviewRect, Matrix.ScaleToFit.FILL);
-
-        // Rotate buffer contents to proper orientation
-        int rotateDegree = mOrientationManager.getDisplayRotation().getDegrees();
-
-        switch (result) {
-            case 90:
-                rotateDegree = 180;
-                break;
-            case 180:
-                rotateDegree = 90;
-                break;
-            case 270:
-                break;
-            case 0:
-                break;
-            default:
-                break;
-        }
-
         transformMatrix.postRotate(
                 rotateDegree,
                 previewViewCenter.x, previewViewCenter.y);