diff options
| author | Sunny Goyal <sunnygoyal@google.com> | 2016-11-09 17:05:06 -0800 |
|---|---|---|
| committer | Sunny Goyal <sunnygoyal@google.com> | 2016-11-15 05:22:04 +0000 |
| commit | 4f05d8d76beef330339dea55170eddb86c58b03c (patch) | |
| tree | d287dd80ecaeb259101531afc80a1e283c7cbff5 /core/java/android/widget/RemoteViews.java | |
| parent | 96d4aadb4cde594465575229b0b4462fc9eee6c0 (diff) | |
Preventing widgets from exceeding Bitmap memory limit
> Moving the size check to a comman place so that it is executed in
all related code
> Fixing size calculation when views are merged as a result of partial
update
Test: Manually tested with a dummy app
Bug: 31790171
Change-Id: Id0ea776796f156455d2cba31c8392d4875116949
(cherry picked from commit 349b412b4ba93e6ab835e3f0c45a998979339b4f)
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
| -rw-r--r-- | core/java/android/widget/RemoteViews.java | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index d0d233ebe975..7cc539cba2fc 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -390,6 +390,7 @@ public class RemoteViews implements Parcelable, Filter { // Because pruning can remove the need for bitmaps, we reconstruct the bitmap cache mBitmapCache = new BitmapCache(); setBitmapCache(mBitmapCache); + recalculateMemoryUsage(); } private class SetEmptyView extends Action { @@ -2057,26 +2058,8 @@ public class RemoteViews implements Parcelable, Filter { return mMemoryUsage; } - @SuppressWarnings("deprecation") public void addBitmapMemory(Bitmap b) { - final Bitmap.Config c = b.getConfig(); - // If we don't know, be pessimistic and assume 4 - int bpp = 4; - if (c != null) { - switch (c) { - case ALPHA_8: - bpp = 1; - break; - case RGB_565: - case ARGB_4444: - bpp = 2; - break; - case ARGB_8888: - bpp = 4; - break; - } - } - increment(b.getWidth() * b.getHeight() * bpp); + increment(b.getAllocationByteCount()); } int mMemoryUsage; |
