Merge "Remove jank on camera options switching" into ub-camera-glacier
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index e5237d8..07215cc 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1007,8 +1007,7 @@
             // some automated scenarios, just return it as a valid separate scope
             // this could cause user issues, so log a stack trace noting the call path
             // which resulted in this scenario.
-            Log.w(TAG, "getting camera scope with no open camera, using id: " + currentCameraId,
-                    new Exception());
+            Log.w(TAG, "getting camera scope with no open camera, using id: " + currentCameraId);
         }
         return CAMERA_SCOPE_PREFIX + Integer.toString(currentCameraId);
     }
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 8fe036a..94585e4 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -38,7 +38,6 @@
 import android.view.TextureView;
 import android.view.View;
 import android.view.View.OnLayoutChangeListener;
-import android.widget.Toast;
 
 import com.android.camera.app.AppController;
 import com.android.camera.app.CameraAppUI;
@@ -67,7 +66,6 @@
 import com.android.camera.ui.CountDownView;
 import com.android.camera.ui.PreviewStatusListener;
 import com.android.camera.ui.TouchCoordinate;
-import com.android.camera.util.ApiHelper;
 import com.android.camera.util.CameraUtil;
 import com.android.camera.util.GcamHelper;
 import com.android.camera.util.Size;
@@ -544,13 +542,6 @@
         mAppController.getCameraAppUI().enableModeOptions();
         mAppController.setShutterEnabled(true);
 
-        // TODO: Remove once Gcam is properly tuned on Shamu and ready for
-        // quality feedback.
-        if (mStickyGcamCamera && ApiHelper.IS_NEXUS_6) {
-            Toast.makeText(mContext,
-                    "Shamu HDR+ still in tuning, don't file image quality issues yet",
-                    Toast.LENGTH_SHORT).show();
-        }
         // Get events from the accelerometer and magnetic sensor.
         if (mAccelerometerSensor != null) {
             mSensorManager.registerListener(this, mAccelerometerSensor,
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 8a3ced8..2844808 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -484,6 +484,7 @@
 
     private void onPreviewStarted() {
         mAppController.onPreviewStarted();
+        mAppController.setShutterEnabled(true);
         setCameraState(IDLE);
         startFaceDetection();
         settingsFirstRun();
@@ -999,6 +1000,18 @@
         int xOffset = (originalWidth - newWidth)/2;
         int yOffset = (originalHeight - newHeight)/2;
 
+        // For some reason L needs this to work.
+        // This code is only run on the Nexus 5.
+        // TODO: Determine why this is needed.
+        if (Build.VERSION.SDK_INT >= 21 || Build.VERSION.CODENAME.equals("L")) {
+            Log.v(TAG,"xOffset = " + xOffset);
+            Log.v(TAG,"yOffset = " + yOffset);
+            xOffset *= 2;
+            yOffset = 0;
+            Log.v(TAG,"new xOffset = " + xOffset);
+            Log.v(TAG,"new yOffset = " + yOffset);
+        }
+
         if (xOffset < 0 || yOffset < 0) {
             return dataBundle;
         }
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 87cdb1f..3c2305e 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1031,6 +1031,7 @@
         if (valid) {
             resultCode = Activity.RESULT_OK;
             resultIntent.setData(mCurrentVideoUri);
+            resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         } else {
             resultCode = Activity.RESULT_CANCELED;
         }
diff --git a/src/com/android/camera/one/OneCamera.java b/src/com/android/camera/one/OneCamera.java
index 1b7ecca..4e95f7f 100644
--- a/src/com/android/camera/one/OneCamera.java
+++ b/src/com/android/camera/one/OneCamera.java
@@ -310,7 +310,7 @@
      * The preview size requested from the camera device will depend on this as
      * well as the requested photo/video aspect ratio.
      */
-    public void setViewFinderSize(int width, int height);
+    public void setViewfinderSize(int width, int height);
 
     /**
      * @return Whether this camera supports flash.
@@ -341,7 +341,7 @@
      * @return The aspect ratio of the full size capture (usually the native
      *         resolution of the camera).
      */
-    public double getFullSizeAspectRatio();
+    public float getFullSizeAspectRatio();
 
     /**
      * @return Whether this camera is facing to the back.
diff --git a/src/com/android/camera/one/v2/OneCameraImpl.java b/src/com/android/camera/one/v2/OneCameraImpl.java
index e27755d..258eadd 100644
--- a/src/com/android/camera/one/v2/OneCameraImpl.java
+++ b/src/com/android/camera/one/v2/OneCameraImpl.java
@@ -157,7 +157,7 @@
             CameraCaptureSession.CaptureCallback() {
                 @Override
                 public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request,
-                                             long timestamp) {
+                                             long timestamp, long frameNumber) {
                     if (request.getTag() == RequestTag.CAPTURE && mLastPictureCallback != null) {
                         mLastPictureCallback.onQuickExpose();
                     }
@@ -202,7 +202,7 @@
      * The aspect ratio (width/height) of the full resolution for this camera.
      * Usually the native aspect ratio of this camera.
      */
-    private final double mFullSizeAspectRatio;
+    private final float mFullSizeAspectRatio;
     /** The Camera2 API capture session currently active. */
     private CameraCaptureSession mCaptureSession;
     /** The surface onto which to render the preview. */
@@ -344,7 +344,7 @@
     }
 
     @Override
-    public void setViewFinderSize(int width, int height) {
+    public void setViewfinderSize(int width, int height) {
         throw new RuntimeException("Not implemented yet.");
     }
 
@@ -383,7 +383,7 @@
     }
 
     @Override
-    public double getFullSizeAspectRatio() {
+    public float getFullSizeAspectRatio() {
         return mFullSizeAspectRatio;
     }
 
@@ -662,10 +662,10 @@
      * @return The aspect ration, in terms of width/height of the full capture
      *         size.
      */
-    private static double calculateFullSizeAspectRatio(CameraCharacteristics characteristics) {
+    private static float calculateFullSizeAspectRatio(CameraCharacteristics characteristics) {
         Rect activeArraySize =
                 characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
-        return (double) activeArraySize.width() / activeArraySize.height();
+        return ((float)(activeArraySize.width())) / activeArraySize.height();
     }
 
     /**
diff --git a/src/com/android/camera/one/v2/OneCameraZslImpl.java b/src/com/android/camera/one/v2/OneCameraZslImpl.java
index 34284dd..4d6f632 100644
--- a/src/com/android/camera/one/v2/OneCameraZslImpl.java
+++ b/src/com/android/camera/one/v2/OneCameraZslImpl.java
@@ -120,8 +120,9 @@
      * continuous AF.
      */
     private static final String FOCUS_RESUME_CALLBACK_TOKEN = "RESUME_CONTINUOUS_AF";
+
     /** Zero weight 3A region, to reset regions per API. */
-    MeteringRectangle[] ZERO_WEIGHT_3A_REGION = AutoFocusHelper.getZeroWeightRegion();
+    /*package*/ MeteringRectangle[] ZERO_WEIGHT_3A_REGION = AutoFocusHelper.getZeroWeightRegion();
 
     /**
      * Thread on which high-priority camera operations, such as grabbing preview
@@ -144,7 +145,7 @@
      * The aspect ratio (width/height) of the full resolution for this camera.
      * Usually the native aspect ratio of this camera.
      */
-    private final double mFullSizeAspectRatio;
+    private final float mFullSizeAspectRatio;
     /** The Camera2 API capture session currently active. */
     private CameraCaptureSession mCaptureSession;
     /** The surface onto which to render the preview. */
@@ -349,7 +350,6 @@
                 largestSupportedSize.getHeight());
     }
 
-
     private void onShutterInvokeUI(final PhotoCaptureParameters params) {
         // Tell CaptureModule shutter has occurred so it can flash the screen.
         params.callback.onQuickExpose();
@@ -518,7 +518,7 @@
     }
 
     @Override
-    public void setViewFinderSize(int width, int height) {
+    public void setViewfinderSize(int width, int height) {
         throw new RuntimeException("Not implemented yet.");
     }
 
@@ -558,7 +558,7 @@
     }
 
     @Override
-    public double getFullSizeAspectRatio() {
+    public float getFullSizeAspectRatio() {
         return mFullSizeAspectRatio;
     }
 
@@ -917,10 +917,10 @@
      * @return The aspect ration, in terms of width/height of the full capture
      *         size.
      */
-    private static double calculateFullSizeAspectRatio(CameraCharacteristics characteristics) {
+    private static float calculateFullSizeAspectRatio(CameraCharacteristics characteristics) {
         Rect activeArraySize =
                 characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
-        return (double) activeArraySize.width() / activeArraySize.height();
+        return ((float) activeArraySize.width()) / activeArraySize.height();
     }
 
     /**