summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CaptureModule.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-08-22 20:17:37 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-27 11:15:34 -0700
commit035160fb849ed565fc419cd7deadb486338b755c (patch)
tree3492f4d575a0e1a4e254d9aca0efbc2fbfef6870 /src/com/android/camera/CaptureModule.java
parent4b5b4aaaed98a4156beb1a6fa2f1e1ee124731b5 (diff)
downloadandroid_packages_apps_Snap-035160fb849ed565fc419cd7deadb486338b755c.tar.gz
android_packages_apps_Snap-035160fb849ed565fc419cd7deadb486338b755c.tar.bz2
android_packages_apps_Snap-035160fb849ed565fc419cd7deadb486338b755c.zip
SnapdragonCamera: Fix memory leak when updating thumbnails.
Fix a memory leak with jpeg data buffers saved for updating thumbnails. Ensure that all references are freed and released when exiting. CRs-Fixed: 1054441 Change-Id: Idc79f51f0e70b0b3e39d614ff3dd7f5d1f85aaad
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r--src/com/android/camera/CaptureModule.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 92b95e5ec..85722457d 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -357,7 +357,6 @@ public class CaptureModule implements CameraModule, PhotoController,
if (uri != null) {
mActivity.notifyNewMedia(uri);
}
- if (mLastJpegData != null) mActivity.updateThumbnail(mLastJpegData);
}
}
};
@@ -1353,7 +1352,6 @@ public class CaptureModule implements CameraModule, PhotoController,
long date = (name == null) ? -1 : name.date;
byte[] bytes = getJpegData(image);
- mLastJpegData = bytes;
ExifInterface exif = Exif.getExif(bytes);
int orientation = Exif.getOrientation(exif);
@@ -1361,6 +1359,12 @@ public class CaptureModule implements CameraModule, PhotoController,
mActivity.getMediaSaveService().addImage(bytes, title, date,
null, image.getWidth(), image.getHeight(), orientation, null,
mOnMediaSavedListener, mContentResolver, "jpeg");
+
+ if(mLongshotActive) {
+ mLastJpegData = bytes;
+ } else {
+ mActivity.updateThumbnail(bytes);
+ }
image.close();
}
}
@@ -1395,7 +1399,6 @@ public class CaptureModule implements CameraModule, PhotoController,
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.remaining()];
- mLastJpegData = bytes;
buffer.get(bytes);
ExifInterface exif = Exif.getExif(bytes);
@@ -1404,6 +1407,8 @@ public class CaptureModule implements CameraModule, PhotoController,
mActivity.getMediaSaveService().addImage(bytes, title, date,
null, image.getWidth(), image.getHeight(), orientation, null,
mOnMediaSavedListener, mContentResolver, "jpeg");
+
+ mActivity.updateThumbnail(bytes);
image.close();
}
}, mImageAvailableHandler);
@@ -1716,6 +1721,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mUI.hideSurfaceView();
mFirstPreviewLoaded = false;
stopBackgroundThread();
+ mLastJpegData = null;
}
@Override
@@ -3490,7 +3496,6 @@ public class CaptureModule implements CameraModule, PhotoController,
byte[] bayerBytes = getJpegData(bayerImage);
byte[] monoBytes = getJpegData(monoImage);
- mLastJpegData = bayerBytes;
ExifInterface exif = Exif.getExif(bayerBytes);
int orientation = Exif.getOrientation(exif);
@@ -3498,6 +3503,8 @@ public class CaptureModule implements CameraModule, PhotoController,
null, bayerBytes, monoBytes, width, height, title,
date, null, orientation, mOnMediaSavedListener, mContentResolver, "jpeg");
+ mActivity.updateThumbnail(bayerBytes);
+
bayerImage.close();
bayerImage = null;
monoImage.close();