summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuiwan <huiwan@codeaurora.com>2017-08-01 13:21:13 +0800
committerjianzhou <jianzhou@codeaurora.org>2017-08-14 16:17:38 +0800
commite54349fda51592cc16ccd244bd95ebbebb055502 (patch)
tree4f4533e210138906f1ec8b9d6ec01b6667c26b30
parent75c9e4d594daac0a1d40f1d75c7620d4659471a7 (diff)
downloadbase-e54349fda51592cc16ccd244bd95ebbebb055502.tar.gz
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
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java
index c1a3f865bed4..d556b641454b 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<ViewHolder> {
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));