diff options
author | Daniel Sandler <dsandler@android.com> | 2015-06-24 02:09:56 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-24 02:09:58 +0000 |
commit | 25a5f3012805e0fbcf3610dc57ab5c28d25aab0f (patch) | |
tree | 309e0be97d705e7d8fcf771a1fb04ecebe6862f2 | |
parent | 29124960c6a39bf062caaccfc6810bea54d45cef (diff) | |
parent | a0d58ae574a3a69145512e0cd92e7842f0fbf83d (diff) | |
download | frameworks_base-25a5f3012805e0fbcf3610dc57ab5c28d25aab0f.zip frameworks_base-25a5f3012805e0fbcf3610dc57ab5c28d25aab0f.tar.gz frameworks_base-25a5f3012805e0fbcf3610dc57ab5c28d25aab0f.tar.bz2 |
Merge "Use ashmem backed bitmaps for passing around notifications" into mnc-dev
-rw-r--r-- | core/java/android/app/Notification.java | 21 | ||||
-rw-r--r-- | graphics/java/android/graphics/drawable/Icon.java | 16 |
2 files changed, 35 insertions, 2 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 5a0d246..af9decc 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -3586,12 +3586,19 @@ public class Notification implements Parcelable * object. */ public Notification build() { + if (mSmallIcon != null) { + mSmallIcon.convertToAshmem(); + } + if (mLargeIcon != null) { + mLargeIcon.convertToAshmem(); + } mOriginatingUserId = mContext.getUserId(); mHasThreeLines = hasThreeLines(); Notification n = buildUnstyled(); if (mStyle != null) { + mStyle.purgeResources(); n = mStyle.buildStyled(n); } @@ -3790,6 +3797,8 @@ public class Notification implements Parcelable return wip; } + public void purgeResources() {} + // The following methods are split out so we can re-create notification partially. /** * @hide @@ -3901,8 +3910,18 @@ public class Notification implements Parcelable return this; } - private RemoteViews makeBigContentView() { + @Override + public void purgeResources() { + super.purgeResources(); + if (mPicture != null && mPicture.isMutable()) { + mPicture = mPicture.createAshmemBitmap(); + } + if (mBigLargeIcon != null) { + mBigLargeIcon.convertToAshmem(); + } + } + private RemoteViews makeBigContentView() { // Replace mLargeIcon with mBigLargeIcon if mBigLargeIconSet // This covers the following cases: // 1. mBigLargeIconSet -> mBigLargeIcon (null or non-null) applies, overrides diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java index 85db6a1..09386c0 100644 --- a/graphics/java/android/graphics/drawable/Icon.java +++ b/graphics/java/android/graphics/drawable/Icon.java @@ -109,6 +109,10 @@ public final class Icon implements Parcelable { return (Bitmap) mObj1; } + private void setBitmap(Bitmap b) { + mObj1 = b; + } + /** * @return The length of the compressed bitmap byte array held by this {@link #TYPE_DATA} Icon. * @hide @@ -347,6 +351,16 @@ public final class Icon implements Parcelable { } /** + * Puts the memory used by this instance into Ashmem memory, if possible. + * @hide + */ + public void convertToAshmem() { + if (mType == TYPE_BITMAP && getBitmap().isMutable()) { + setBitmap(getBitmap().createAshmemBitmap()); + } + } + + /** * Writes a serialized version of an Icon to the specified stream. * * @param stream The stream on which to serialize the Icon. @@ -466,7 +480,7 @@ public final class Icon implements Parcelable { throw new IllegalArgumentException("Bitmap must not be null."); } final Icon rep = new Icon(TYPE_BITMAP); - rep.mObj1 = bits; + rep.setBitmap(bits); return rep; } |