summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-10-31 12:31:58 -0700
committerJohn Reck <jreck@google.com>2011-10-31 12:31:58 -0700
commita98c83b24d2459e3af2b251facec446199190a4e (patch)
treef56c5d573de44158c4333d56debe6c21bf3ea183 /src/com
parentd7383a28ac34ba7379e6ec733e9c5397baf4a293 (diff)
downloadpackages_apps_browser-a98c83b24d2459e3af2b251facec446199190a4e.zip
packages_apps_browser-a98c83b24d2459e3af2b251facec446199190a4e.tar.gz
packages_apps_browser-a98c83b24d2459e3af2b251facec446199190a4e.tar.bz2
Monkey proofing
Bug: 5531453 Change-Id: I0a8158212d8b2de638bae3c66bb2b9aa3bf85c1d
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/browser/PhoneUi.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index ffcaaf8..a13eca3 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -529,12 +529,14 @@ public class PhoneUi extends BaseUi {
if (mTitleBarBitmap == null
|| mTitleBarBitmap.getWidth() != tbar.getWidth()
|| mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) {
- mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(),
- tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565);
+ mTitleBarBitmap = safeCreateBitmap(tbar.getWidth(),
+ tbar.getEmbeddedHeight());
+ }
+ if (mTitleBarBitmap != null) {
+ Canvas c = new Canvas(mTitleBarBitmap);
+ tbar.draw(c);
+ c.setBitmap(null);
}
- Canvas c = new Canvas(mTitleBarBitmap);
- tbar.draw(c);
- c.setBitmap(null);
} else {
mTitleBarBitmap = null;
}
@@ -544,18 +546,28 @@ public class PhoneUi extends BaseUi {
if (mContentBitmap == null
|| mContentBitmap.getWidth() != web.getWidth()
|| mContentBitmap.getHeight() != h) {
- mContentBitmap = Bitmap.createBitmap(web.getWidth(), h,
- Bitmap.Config.RGB_565);
+ mContentBitmap = safeCreateBitmap(web.getWidth(), h);
+ }
+ if (mContentBitmap != null) {
+ Canvas c = new Canvas(mContentBitmap);
+ int tx = web.getScrollX();
+ int ty = web.getScrollY();
+ c.translate(-tx, -ty - tbar.getEmbeddedHeight());
+ web.draw(c);
+ c.setBitmap(null);
}
- Canvas c = new Canvas(mContentBitmap);
- int tx = web.getScrollX();
- int ty = web.getScrollY();
- c.translate(-tx, -ty - tbar.getEmbeddedHeight());
- web.draw(c);
- c.setBitmap(null);
mContent.setImageBitmap(mContentBitmap);
}
+ private Bitmap safeCreateBitmap(int width, int height) {
+ if (width <= 0 || height <= 0) {
+ Log.w(LOGTAG, "safeCreateBitmap failed! width: " + width
+ + ", height: " + height);
+ return null;
+ }
+ return Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
+ }
+
public void set(Bitmap image) {
mTitle.setVisibility(View.GONE);
mContent.setImageBitmap(image);