Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96d9c3f9 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Do not allow wallpapers that are too large"

parents b2339319 d8e12442
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,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);
+7 −1
Original line number Diff line number Diff line
@@ -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;
                    }