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
This commit is contained in:
huiwan
2017-08-01 13:21:13 +08:00
committed by jianzhou
parent 75c9e4d594
commit e54349fda5

View File

@@ -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));