diff options
author | Eric Erfanian <erfanian@google.com> | 2017-06-05 13:35:02 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-06-07 20:44:54 +0000 |
commit | 91ce7d2a476bd04fe525049a37a2f8b2824e9724 (patch) | |
tree | b9bbc285430ffb5363a70eb27e382c38f5a85b7a /java/com/android/dialer/callcomposer/camera | |
parent | 75233ff03785f24789b32039ac2c208805b7e506 (diff) |
Update AOSP Dialer source from internal google3 repository at
cl/158012278.
Test: make, treehugger
This CL updates the AOSP Dialer source with all the changes that have
gone into the private google3 repository. This includes all the
changes from cl/152373142 (4/06/2017) to cl/158012278 (6/05/2017).
This goal of these drops is to keep the AOSP source in sync with the
internal google3 repository. Currently these sync are done by hand
with very minor modifications to the internal source code.
See the Android.mk file for list of modifications.
Our current goal is to do frequent drops (daily if possible) and
eventually switched to an automated process.
Change-Id: I4d3f14b5140e2e51bead9497bc118a205b3ebe76
Diffstat (limited to 'java/com/android/dialer/callcomposer/camera')
-rw-r--r-- | java/com/android/dialer/callcomposer/camera/CameraManager.java | 19 | ||||
-rw-r--r-- | java/com/android/dialer/callcomposer/camera/ImagePersistTask.java | 38 |
2 files changed, 20 insertions, 37 deletions
diff --git a/java/com/android/dialer/callcomposer/camera/CameraManager.java b/java/com/android/dialer/callcomposer/camera/CameraManager.java index 4cc08ba32..977f063df 100644 --- a/java/com/android/dialer/callcomposer/camera/CameraManager.java +++ b/java/com/android/dialer/callcomposer/camera/CameraManager.java @@ -522,6 +522,7 @@ 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; @@ -531,31 +532,22 @@ 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) { - orientation = (mCameraInfo.orientation + degrees) % 360; - rotation = orientation; - // compensate the mirror but only for orientation - orientation = (360 - orientation) % 360; + mRotation = (mCameraInfo.orientation + degrees) % 360; } else { // back-facing - orientation = (mCameraInfo.orientation - degrees + 360) % 360; - rotation = orientation; + mRotation = (mCameraInfo.orientation - degrees + 360) % 360; } - mRotation = rotation; try { - mCamera.setDisplayOrientation(orientation); final Camera.Parameters params = mCamera.getParameters(); - params.setRotation(rotation); + params.setRotation(mRotation); mCamera.setParameters(params); } catch (final RuntimeException e) { LogUtil.e( @@ -589,7 +581,6 @@ public class CameraManager implements FocusOverlayManager.Listener { mOrientationHandler.disable(); mOrientationHandler = null; } - // releaseMediaRecorder(true /* cleanupFile */); mFocusOverlayManager.onPreviewStopped(); return; } diff --git a/java/com/android/dialer/callcomposer/camera/ImagePersistTask.java b/java/com/android/dialer/callcomposer/camera/ImagePersistTask.java index 31751e536..b5542ab6c 100644 --- a/java/com/android/dialer/callcomposer/camera/ImagePersistTask.java +++ b/java/com/android/dialer/callcomposer/camera/ImagePersistTask.java @@ -20,13 +20,11 @@ import android.annotation.TargetApi; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.Canvas; import android.graphics.Matrix; import android.net.Uri; import android.os.Build.VERSION_CODES; import android.support.v4.content.FileProvider; import com.android.dialer.callcomposer.camera.exif.ExifInterface; -import com.android.dialer.callcomposer.camera.exif.ExifTag; import com.android.dialer.callcomposer.util.BitmapResizer; import com.android.dialer.common.Assert; import com.android.dialer.common.concurrent.FallibleAsyncTask; @@ -71,13 +69,7 @@ public class ImagePersistTask extends FallibleAsyncTask<Void, Void, Uri> { File outputFile = DialerUtils.createShareableFile(mContext); try (OutputStream outputStream = new FileOutputStream(outputFile)) { - if (mHeightPercent != 1.0f) { - writeClippedBitmap(outputStream); - } else { - Bitmap bitmap = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length); - bitmap = BitmapResizer.resizeForEnrichedCalling(bitmap); - bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outputStream); - } + writeClippedBitmap(outputStream); } return FileProvider.getUriForFile( @@ -105,10 +97,12 @@ public class ImagePersistTask extends FallibleAsyncTask<Void, Void, Uri> { } catch (final IOException e) { // Couldn't get exif tags, not the end of the world } + Bitmap bitmap = BitmapFactory.decodeByteArray(mBytes, 0, mBytes.length); final int clippedWidth; final int clippedHeight; - if (ExifInterface.getOrientationParams(orientation).invertDimensions) { + boolean invert = ExifInterface.getOrientationParams(orientation).invertDimensions; + if (invert) { Assert.checkState(mWidth == bitmap.getHeight()); Assert.checkState(mHeight == bitmap.getWidth()); clippedWidth = (int) (mHeight * mHeightPercent); @@ -119,24 +113,22 @@ public class ImagePersistTask extends FallibleAsyncTask<Void, Void, Uri> { clippedWidth = mWidth; clippedHeight = (int) (mHeight * mHeightPercent); } - final int offsetTop = (bitmap.getHeight() - clippedHeight) / 2; - final int offsetLeft = (bitmap.getWidth() - clippedWidth) / 2; + + int offsetTop = (bitmap.getHeight() - clippedHeight) / 2; + int offsetLeft = (bitmap.getWidth() - clippedWidth) / 2; mWidth = clippedWidth; mHeight = clippedHeight; + + Matrix matrix = new Matrix(); + matrix.postRotate(invert ? 90 : 0); + Bitmap clippedBitmap = - Bitmap.createBitmap(clippedWidth, clippedHeight, Bitmap.Config.ARGB_8888); - clippedBitmap.setDensity(bitmap.getDensity()); - final Canvas clippedBitmapCanvas = new Canvas(clippedBitmap); - final Matrix matrix = new Matrix(); - matrix.postTranslate(-offsetLeft, -offsetTop); - clippedBitmapCanvas.drawBitmap(bitmap, matrix, null /* paint */); - clippedBitmapCanvas.save(); + Bitmap.createBitmap( + bitmap, offsetLeft, offsetTop, clippedWidth, clippedHeight, matrix, true); clippedBitmap = BitmapResizer.resizeForEnrichedCalling(clippedBitmap); - // EXIF data can take a big chunk of the file size and is often cleared by the - // carrier, only store orientation since that's critical - final ExifTag orientationTag = exifInterface.getTag(ExifInterface.TAG_ORIENTATION); + // EXIF data can take a big chunk of the file size and we've already manually rotated our image, + // so remove all of the exif data. exifInterface.clearExif(); - exifInterface.setTag(orientationTag); exifInterface.writeExif(clippedBitmap, outputStream); clippedBitmap.recycle(); |