summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/RefocusActivity.java
diff options
context:
space:
mode:
authorpezhan <pezhan@codeaurora.org>2017-03-01 14:28:34 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2017-03-07 01:34:26 -0800
commit47864ee5ce477ce938ee2f5637b8e9e67ad72cf8 (patch)
tree6962b3751c5f124f0c5be2058178d37a10d6d4a3 /src/com/android/camera/RefocusActivity.java
parentfb7a974380cf55206f546ffba5ee58d9b607d409 (diff)
downloadandroid_packages_apps_Snap-47864ee5ce477ce938ee2f5637b8e9e67ad72cf8.tar.gz
android_packages_apps_Snap-47864ee5ce477ce938ee2f5637b8e9e67ad72cf8.tar.bz2
android_packages_apps_Snap-47864ee5ce477ce938ee2f5637b8e9e67ad72cf8.zip
SnapdragonCamera:Fix Camera1 force close when refocusing the picture.
When the screen is PORTRAIT mode, we get the screen always height < width. But we get the image always height < width.Under this circumstance, the inSampleSize maybe incorrect , which will cause OOM when create bitmap. Need to check the screen's orientation,and choose the correct width and height to calculate the inSampleSize. Change-Id: I11743c862ebdb9d35c4fc5de7bf40003c69b7219 CRs-Fixed: 2013250
Diffstat (limited to 'src/com/android/camera/RefocusActivity.java')
-rw-r--r--src/com/android/camera/RefocusActivity.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/camera/RefocusActivity.java b/src/com/android/camera/RefocusActivity.java
index a3d5c0862..9b7cd65d1 100644
--- a/src/com/android/camera/RefocusActivity.java
+++ b/src/com/android/camera/RefocusActivity.java
@@ -39,6 +39,7 @@ import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -234,6 +235,8 @@ public class RefocusActivity extends Activity {
private class LoadImageTask extends AsyncTask<String, Void, Bitmap> {
protected Bitmap doInBackground(String... path) {
final BitmapFactory.Options o = new BitmapFactory.Options();
+ int height;
+ int width;
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path[0], o);
ExifInterface exif = new ExifInterface();
@@ -245,13 +248,24 @@ public class RefocusActivity extends Activity {
}
int h = o.outHeight;
int w = o.outWidth;
+ int screenOrientation = RefocusActivity.this.getResources().getConfiguration()
+ .orientation;
+ if (screenOrientation == Configuration.ORIENTATION_PORTRAIT) {
+ height = mWidth;
+ width = mHeight;
+ } else {
+ height = mHeight;
+ width = mWidth;
+ }
int sample = 1;
- if (h > mHeight || w > mWidth) {
- while (h / sample / 2 > mHeight && w / sample / 2 > mWidth) {
+ if (h > height || w > width) {
+ while (h / sample / 2 > height && w / sample / 2 > width) {
sample *= 2;
}
}
-
+ Log.d(TAG, "sample = " + sample);
+ Log.d(TAG, "h = " + h + " height = " + height);
+ Log.d(TAG, "w = " + w + " width = " + width);
o.inJustDecodeBounds = false;
o.inSampleSize = sample;
Bitmap bitmap = BitmapFactory.decodeFile(path[0], o);