diff options
| -rw-r--r-- | core/java/android/view/DisplayListCanvas.java | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/ImageWallpaper.java | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/view/DisplayListCanvas.java b/core/java/android/view/DisplayListCanvas.java index df4d5c415b98..dbbfa298f572 100644 --- a/core/java/android/view/DisplayListCanvas.java +++ b/core/java/android/view/DisplayListCanvas.java @@ -39,7 +39,7 @@ public final class DisplayListCanvas extends RecordingCanvas { // view hierarchy because display lists are generated recursively. private static final int POOL_LIMIT = 25; - private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB + public static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB private static final SynchronizedPool<DisplayListCanvas> sPool = new SynchronizedPool<>(POOL_LIMIT); diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 50d862dee29c..39e315566daf 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -30,6 +30,7 @@ import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.Display; import android.view.DisplayInfo; +import android.view.DisplayListCanvas; import android.view.Surface; import android.view.SurfaceHolder; import android.view.WindowManager; @@ -366,7 +367,12 @@ public class ImageWallpaper extends WallpaperService { protected Bitmap doInBackground(Void... params) { Throwable exception; try { - return mWallpaperManager.getBitmap(true /* hardware */); + Bitmap wallpaper = mWallpaperManager.getBitmap(true /* hardware */); + if (wallpaper != null + && wallpaper.getByteCount() > DisplayListCanvas.MAX_BITMAP_SIZE) { + throw new RuntimeException("Wallpaper is too large to draw!"); + } + return wallpaper; } catch (RuntimeException | OutOfMemoryError e) { exception = e; } |