diff options
| author | Jay Wang <jaywang@codeaurora.org> | 2016-08-22 20:17:37 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-09-15 15:06:57 -0700 |
| commit | 1e35ddbc3328515c0bd4c370f6829a3acf1b35cd (patch) | |
| tree | 8be55e3d438a0ea291b7c7121892833a5cce14d5 /src/com/android/camera/CaptureModule.java | |
| parent | ca9a3f991cb2f18f64c36ab6f4e870cbade6c6b1 (diff) | |
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.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index 81d85847e..c418db1b3 100644 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -363,7 +363,6 @@ public class CaptureModule implements CameraModule, PhotoController, if (uri != null) { mActivity.notifyNewMedia(uri); } - if (mLastJpegData != null) mActivity.updateThumbnail(mLastJpegData); } } }; @@ -1372,7 +1371,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); @@ -1380,6 +1378,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(); } } @@ -1414,7 +1418,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); @@ -1423,6 +1426,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); @@ -1734,6 +1739,7 @@ public class CaptureModule implements CameraModule, PhotoController, mUI.hideSurfaceView(); mFirstPreviewLoaded = false; stopBackgroundThread(); + mLastJpegData = null; } @Override @@ -3516,7 +3522,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); @@ -3524,6 +3529,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(); |
