From e54349fda51592cc16ccd244bd95ebbebb055502 Mon Sep 17 00:00:00 2001 From: huiwan Date: Tue, 1 Aug 2017 13:21:13 +0800 Subject: [PATCH] PrintSpooler: fix monkey crash if height&width small than 0 During the monkey test, should add check height & width before create the bitmap, to avoid the monkey test fail. Change-Id: I5619c30af63afa3d74d0417e37c67c4920e099ba Test: build & run --- .../src/com/android/printspooler/ui/PageAdapter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java index c1a3f865bed46..d556b641454b1 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java @@ -467,6 +467,12 @@ public final class PageAdapter extends Adapter { loadingContent.layout(0, 0, loadingContent.getMeasuredWidth(), loadingContent.getMeasuredHeight()); + // To create a bitmap, height & width should be larger than 0 + if (mPageContentHeight <= 0 || mPageContentWidth <= 0) { + Log.w(LOG_TAG, "Unable to create bitmap, height or width smaller than 0!"); + return; + } + Bitmap loadingBitmap = Bitmap.createBitmap(mPageContentWidth, mPageContentHeight, Bitmap.Config.ARGB_8888); loadingContent.draw(new Canvas(loadingBitmap));