Skip to content

Commit 7c65585

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Make sure OutOfMemoryError is handled by WallpaperManager"
2 parents 4940ff8 + 2c4a56a commit 7c65585

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

core/java/android/app/WallpaperManager.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,13 @@ private Bitmap getCurrentWallpaperLocked(Context context) {
235235
if (width <= 0 || height <= 0) {
236236
// Degenerate case: no size requested, just load
237237
// bitmap as-is.
238-
Bitmap bm = BitmapFactory.decodeFileDescriptor(
239-
fd.getFileDescriptor(), null, null);
238+
Bitmap bm = null;
239+
try {
240+
bm = BitmapFactory.decodeFileDescriptor(
241+
fd.getFileDescriptor(), null, null);
242+
} catch (OutOfMemoryError e) {
243+
Log.w(TAG, "Can't decode file", e);
244+
}
240245
try {
241246
fd.close();
242247
} catch (IOException e) {
@@ -277,7 +282,12 @@ private Bitmap getDefaultWallpaperLocked(Context context) {
277282
if (width <= 0 || height <= 0) {
278283
// Degenerate case: no size requested, just load
279284
// bitmap as-is.
280-
Bitmap bm = BitmapFactory.decodeStream(is, null, null);
285+
Bitmap bm = null;
286+
try {
287+
bm = BitmapFactory.decodeStream(is, null, null);
288+
} catch (OutOfMemoryError e) {
289+
Log.w(TAG, "Can't decode stream", e);
290+
}
281291
try {
282292
is.close();
283293
} catch (IOException e) {

0 commit comments

Comments
 (0)