Merge "Limit persistent ashmem backed fds to a minimum of 128kB." into mnc-dr-dev

am: 966d6040c6

* commit '966d6040c6b171c75e9fb0ca942e84f9cf4d0dff':
  Limit persistent ashmem backed fds to a minimum of 128kB.
This commit is contained in:
Ian Pedowitz
2015-11-03 22:05:23 +00:00
committed by android-build-merger
3 changed files with 8 additions and 3 deletions

View File

@@ -3972,7 +3972,9 @@ public class Notification implements Parcelable
@Override @Override
public void purgeResources() { public void purgeResources() {
super.purgeResources(); super.purgeResources();
if (mPicture != null && mPicture.isMutable()) { if (mPicture != null &&
mPicture.isMutable() &&
mPicture.getAllocationByteCount() >= (128 * (1 << 10))) {
mPicture = mPicture.createAshmemBitmap(); mPicture = mPicture.createAshmemBitmap();
} }
if (mBigLargeIcon != null) { if (mBigLargeIcon != null) {

View File

@@ -28,6 +28,7 @@
#include <cutils/ashmem.h> #include <cutils/ashmem.h>
#define DEBUG_PARCEL 0 #define DEBUG_PARCEL 0
#define ASHMEM_BITMAP_MIN_SIZE (128 * (1 << 10))
namespace android { namespace android {
@@ -993,7 +994,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
// Map the bitmap in place from the ashmem region if possible otherwise copy. // Map the bitmap in place from the ashmem region if possible otherwise copy.
Bitmap* nativeBitmap; Bitmap* nativeBitmap;
if (blob.fd() >= 0 && (blob.isMutable() || !isMutable)) { if (blob.fd() >= 0 && (blob.isMutable() || !isMutable) && (size >= ASHMEM_BITMAP_MIN_SIZE)) {
#if DEBUG_PARCEL #if DEBUG_PARCEL
ALOGD("Bitmap.createFromParcel: mapped contents of %s bitmap from %s blob " ALOGD("Bitmap.createFromParcel: mapped contents of %s bitmap from %s blob "
"(fds %s)", "(fds %s)",

View File

@@ -382,7 +382,9 @@ public final class Icon implements Parcelable {
* @hide * @hide
*/ */
public void convertToAshmem() { public void convertToAshmem() {
if (mType == TYPE_BITMAP && getBitmap().isMutable()) { if (mType == TYPE_BITMAP &&
getBitmap().isMutable() &&
getBitmap().getAllocationByteCount() >= (128 * (1 << 10))) {
setBitmap(getBitmap().createAshmemBitmap()); setBitmap(getBitmap().createAshmemBitmap());
} }
} }