From 375fb9bfd29ea4480aa9582bf3956b435152c8d9 Mon Sep 17 00:00:00 2001 From: Christer Fletcher Date: Mon, 21 Mar 2011 15:56:27 +0100 Subject: Handle OutOfMemoryError when decoding images in ThumbnailUtils Added handling of OutOfMemoryError handling to createImageThumbnail method in ThumbnailUtils.java. During mediascanner run it would run out of memory when trying to decode very large images. Now it handles this error and returns null which is handled by the media scanner. Change-Id: Ie68722dfa1cedd3c0847bf483baa40c4827ad5a8 --- media/java/android/media/ThumbnailUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'media') diff --git a/media/java/android/media/ThumbnailUtils.java b/media/java/android/media/ThumbnailUtils.java index 494b4cb..b276e33 100644 --- a/media/java/android/media/ThumbnailUtils.java +++ b/media/java/android/media/ThumbnailUtils.java @@ -83,7 +83,7 @@ public class ThumbnailUtils { * * @param filePath the path of image file * @param kind could be MINI_KIND or MICRO_KIND - * @return Bitmap + * @return Bitmap, or null on failures * * @hide This method is only used by media framework and media provider internally. */ @@ -123,6 +123,8 @@ public class ThumbnailUtils { bitmap = BitmapFactory.decodeFileDescriptor(fd, null, options); } catch (IOException ex) { Log.e(TAG, "", ex); + } catch (OutOfMemoryError oom) { + Log.e(TAG, "Unable to decode file " + filePath + ". OutOfMemoryError.", oom); } } -- cgit v1.1