summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorJohan Alfven <johan.alfven@sonyericsson.com>2010-09-02 14:26:54 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-09-03 08:43:24 +0200
commit2c4a56af4d56f87a1bbf14386f045bcf57602ef2 (patch)
tree57f8b716e5a39fb00c91d928ae3866669492426b /core/java
parent75a2ae937f5354a3432d0a2382e98177bd9b80d5 (diff)
Make sure OutOfMemoryError is handled by WallpaperManager
Make sure exception OutOfMemoryError is handled when calling BitmapFactory.decodeFileDescriptor and BitmapFactory.decodeStream to avoid crash in the system server. Change-Id: I954a6388d1225dab86d2617ab0602154b2a7f493
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/WallpaperManager.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java
index e455a5966c8a..92b7cf519887 100644
--- a/core/java/android/app/WallpaperManager.java
+++ b/core/java/android/app/WallpaperManager.java
@@ -235,8 +235,13 @@ public class WallpaperManager {
if (width <= 0 || height <= 0) {
// Degenerate case: no size requested, just load
// bitmap as-is.
- Bitmap bm = BitmapFactory.decodeFileDescriptor(
- fd.getFileDescriptor(), null, null);
+ Bitmap bm = null;
+ try {
+ bm = BitmapFactory.decodeFileDescriptor(
+ fd.getFileDescriptor(), null, null);
+ } catch (OutOfMemoryError e) {
+ Log.w(TAG, "Can't decode file", e);
+ }
try {
fd.close();
} catch (IOException e) {
@@ -277,7 +282,12 @@ public class WallpaperManager {
if (width <= 0 || height <= 0) {
// Degenerate case: no size requested, just load
// bitmap as-is.
- Bitmap bm = BitmapFactory.decodeStream(is, null, null);
+ Bitmap bm = null;
+ try {
+ bm = BitmapFactory.decodeStream(is, null, null);
+ } catch (OutOfMemoryError e) {
+ Log.w(TAG, "Can't decode stream", e);
+ }
try {
is.close();
} catch (IOException e) {