Merge "Native 16x9 viewfinder stream for Gcam to reduce switching jank and eliminate black bar overlay hack." into ub-camera-glacier
diff --git a/res/layout/camera.xml b/res/layout/camera.xml
index bc6dfdb..650ad8f 100644
--- a/res/layout/camera.xml
+++ b/res/layout/camera.xml
@@ -100,21 +100,4 @@
             android:text="@string/btn_filmstrip_toggle"
             android:contentDescription="@string/accessibility_filmstrip_toggle"/>
     </LinearLayout>
-
-    <View
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:background="@android:color/black"
-        android:id="@+id/leftLetterBoxer1"
-        android:visibility="gone"
-        />
-
-    <View
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:background="@android:color/black"
-        android:id="@+id/leftLetterBoxer2"
-        android:visibility="gone"
-        />
-
 </FrameLayout>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 9358381..12edaf5 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -2168,7 +2168,6 @@
 
         mCameraAppUI.resetBottomControls(mCurrentModule, modeIndex);
         mCameraAppUI.addShutterListener(mCurrentModule);
-        mCameraAppUI.hideLetterboxing();
         openModule(mCurrentModule);
         mCurrentModule.onOrientationChanged(mLastRawOrientation);
         // Store the module index so we can use it the next time the Camera
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index f6895bb..d410bc6 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1141,7 +1141,6 @@
                     - centerY);
 
             mAppController.updatePreviewTransform(mPreviewTranformationMatrix);
-            mAppController.getCameraAppUI().hideLetterboxing();
             // if (mGcamProxy != null) {
             // mGcamProxy.postSetAspectRatio(mFinalAspectRatio);
             // }
diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java
index a3e553a..962a253 100644
--- a/src/com/android/camera/app/CameraAppUI.java
+++ b/src/com/android/camera/app/CameraAppUI.java
@@ -27,7 +27,6 @@
 import android.hardware.display.DisplayManager;
 import android.util.CameraPerformanceTracker;
 import android.view.GestureDetector;
-import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.TextureView;
@@ -511,8 +510,6 @@
     private TextureView mTextureView;
     private FrameLayout mModuleUI;
     private ShutterButton mShutterButton;
-    private View mLetterBoxer1;
-    private View mLetterBoxer2;
     private BottomBar mBottomBar;
     private ModeOptionsOverlay mModeOptionsOverlay;
     private IndicatorIconController mIndicatorIconController;
@@ -1235,9 +1232,6 @@
         addShutterListener(mModeOptionsOverlay);
         addShutterListener(this);
 
-        mLetterBoxer1 = mCameraRootView.findViewById(R.id.leftLetterBoxer1);
-        mLetterBoxer2 = mCameraRootView.findViewById(R.id.leftLetterBoxer2);
-
         mGridLines = (GridLines) mCameraRootView.findViewById(R.id.grid_lines);
         mTextureViewHelper.addPreviewAreaSizeChangedListener(mGridLines);
 
@@ -1775,49 +1769,6 @@
         mShutterButton.addOnShutterButtonListener(listener);
     }
 
-
-    /**
-     * This adds letterboxing around the preview, one on each side
-     *
-     * @param width the width in pixels of each letterboxing cover
-     */
-    public void addLetterboxing(int width) {
-        FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) mLetterBoxer1
-                .getLayoutParams();
-        FrameLayout.LayoutParams params2 = (FrameLayout.LayoutParams) mLetterBoxer2
-                .getLayoutParams();
-
-        if (mCameraRootView.getWidth() < mCameraRootView.getHeight()) {
-            params1.width = width;
-            params1.height = mCameraRootView.getHeight();
-            params1.gravity = Gravity.LEFT;
-            mLetterBoxer1.setVisibility(View.VISIBLE);
-
-            params2.width = width;
-            params2.height = mCameraRootView.getHeight();
-            params2.gravity = Gravity.RIGHT;
-            mLetterBoxer2.setVisibility(View.VISIBLE);
-        } else {
-            params1.height = width;
-            params1.width = mCameraRootView.getWidth();
-            params1.gravity = Gravity.TOP;
-            mLetterBoxer1.setVisibility(View.VISIBLE);
-
-            params2.height = width;
-            params2.width = mCameraRootView.getWidth();
-            params2.gravity = Gravity.BOTTOM;
-            mLetterBoxer2.setVisibility(View.VISIBLE);
-        }
-    }
-
-    /**
-     * Remove the letter boxing strips if they happen to be present.
-     */
-    public void hideLetterboxing() {
-        mLetterBoxer1.setVisibility(View.GONE);
-        mLetterBoxer2.setVisibility(View.GONE);
-    }
-
     /**
      * Remove a {@link #ShutterButton.OnShutterButtonListener} from the shutter button.
      */
diff --git a/src/com/android/camera/util/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java
index df335c7..efdee85 100644
--- a/src/com/android/camera/util/ApiHelper.java
+++ b/src/com/android/camera/util/ApiHelper.java
@@ -42,6 +42,7 @@
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
 
     public static final boolean HAS_CAMERA_HDR_PLUS = isKitKatOrHigher();
+    public static final boolean HDR_PLUS_CAN_USE_ARBITRARY_ASPECT_RATIOS = isKitKatMR2OrHigher();
     public static final boolean HAS_CAMERA_HDR =
             Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
     public static final boolean HAS_DISPLAY_LISTENER =
@@ -78,6 +79,12 @@
                 || "KeyLimePie".equals(Build.VERSION.CODENAME);
     }
 
+    public static boolean isKitKatMR2OrHigher() {
+        return isLOrHigher()
+                || (isKitKatOrHigher() &&
+                       ("4.4.4".equals(Build.VERSION.RELEASE) || "4.4.3".equals(Build.VERSION.RELEASE)));
+    }
+
     public static boolean isLOrHigher() {
         return Build.VERSION.SDK_INT >= Build.VERSION_CODES.L
                 || "L".equals(Build.VERSION.CODENAME);