From 7648ccaa3b2ff2f058bd9909d1ecc1e8049bc5be Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Thu, 7 May 2020 16:00:11 -0400 Subject: [PATCH] Remove instances of @hide from RecordingCanvas Bug: 155905258 Test: make Remove MAX_BITMAP_SIZE. It was based on a limitation of the old renderer. Remove override of throwIfCannotDraw, which was only there for comparing the size of a Bitmap against MAX_BITMAP_SIZE and throwing if it was too big. Remove MAX_BITMAP_SIZE from WallpaperManagerService, which was a copy of the one in RecordingCanvas, and only there due to it. Mark obtain, recycle, and finishRecording as being used by the package. Change-Id: I141d6d79520871df1a3c2a9267ec872a8314ffdb --- .../android/graphics/RecordingCanvas.java | 21 +++---------------- .../wallpaper/WallpaperManagerService.java | 21 +++---------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/graphics/java/android/graphics/RecordingCanvas.java b/graphics/java/android/graphics/RecordingCanvas.java index 7fe6f888fe696..4242ead0e4dfb 100644 --- a/graphics/java/android/graphics/RecordingCanvas.java +++ b/graphics/java/android/graphics/RecordingCanvas.java @@ -39,9 +39,6 @@ public final class RecordingCanvas extends BaseRecordingCanvas { // view hierarchy because display lists are generated recursively. private static final int POOL_LIMIT = 25; - /** @hide */ - public static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; // 100 MB - private static final SynchronizedPool sPool = new SynchronizedPool<>(POOL_LIMIT); @@ -52,7 +49,7 @@ public final class RecordingCanvas extends BaseRecordingCanvas { private int mWidth; private int mHeight; - /** @hide */ + /*package*/ static RecordingCanvas obtain(@NonNull RenderNode node, int width, int height) { if (node == null) throw new IllegalArgumentException("node cannot be null"); RecordingCanvas canvas = sPool.acquire(); @@ -68,13 +65,13 @@ public final class RecordingCanvas extends BaseRecordingCanvas { return canvas; } - /** @hide */ + /*package*/ void recycle() { mNode = null; sPool.release(this); } - /** @hide */ + /*package*/ long finishRecording() { return nFinishRecording(mNativeCanvasWrapper); } @@ -263,18 +260,6 @@ public final class RecordingCanvas extends BaseRecordingCanvas { paint.getNativeContainer()); } - /** @hide */ - @Override - protected void throwIfCannotDraw(Bitmap bitmap) { - super.throwIfCannotDraw(bitmap); - int bitmapSize = bitmap.getByteCount(); - if (bitmapSize > MAX_BITMAP_SIZE) { - throw new RuntimeException( - "Canvas: trying to draw too large(" + bitmapSize + "bytes) bitmap."); - } - } - - // ------------------ Fast JNI ------------------------ @FastNative diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 63952b086c1c8..747e11ad4068e 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -137,9 +137,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub private static final boolean DEBUG = false; private static final boolean DEBUG_LIVE = true; - // This 100MB limitation is defined in RecordingCanvas. - private static final int MAX_BITMAP_SIZE = 100 * 1024 * 1024; - public static class Lifecycle extends SystemService { private IWallpaperManagerService mService; @@ -657,14 +654,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub // may be we can try to remove this optimized way in the future, // that means, we will always go into the 'else' block. - // This is just a quick estimation, may be smaller than it is. - long estimateSize = options.outWidth * options.outHeight * 4; - - // A bitmap over than MAX_BITMAP_SIZE will make drawBitmap() fail. - // Please see: RecordingCanvas#throwIfCannotDraw. - if (estimateSize < MAX_BITMAP_SIZE) { - success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile); - } + success = FileUtils.copyFile(wallpaper.wallpaperFile, wallpaper.cropFile); if (!success) { wallpaper.cropFile.delete(); @@ -672,6 +662,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub } if (DEBUG) { + // This is just a quick estimation, may be smaller than it is. + long estimateSize = options.outWidth * options.outHeight * 4; Slog.v(TAG, "Null crop of new wallpaper, estimate size=" + estimateSize + ", success=" + success); } @@ -753,13 +745,6 @@ public class WallpaperManagerService extends IWallpaperManager.Stub + " h=" + finalCrop.getHeight()); } - // A bitmap over than MAX_BITMAP_SIZE will make drawBitmap() fail. - // Please see: RecordingCanvas#throwIfCannotDraw. - if (finalCrop.getByteCount() > MAX_BITMAP_SIZE) { - throw new RuntimeException( - "Too large bitmap, limit=" + MAX_BITMAP_SIZE); - } - f = new FileOutputStream(wallpaper.cropFile); bos = new BufferedOutputStream(f, 32*1024); finalCrop.compress(Bitmap.CompressFormat.JPEG, 100, bos);