diff options
author | Chih-Chung Chang <chihchung@google.com> | 2010-08-25 15:54:51 +0800 |
---|---|---|
committer | Chih-Chung Chang <chihchung@google.com> | 2010-08-25 15:54:51 +0800 |
commit | 9439241d35afc203d47b327619a49b5d70cf722b (patch) | |
tree | 663b4d539595b4da32de3807276fa8f83d56d2e1 /core/java/android/provider | |
parent | 96b2516496e9ad0424d99c244d82eee8af3813cd (diff) | |
parent | 20afae515054ca0d2d4a1cdc169c7faaaa287e40 (diff) | |
download | frameworks_base-9439241d35afc203d47b327619a49b5d70cf722b.zip frameworks_base-9439241d35afc203d47b327619a49b5d70cf722b.tar.gz frameworks_base-9439241d35afc203d47b327619a49b5d70cf722b.tar.bz2 |
resolved conflicts for merge of 20afae51 to master
Change-Id: Ief637e412e4d716526de68c7761bdb8cbf436333
Diffstat (limited to 'core/java/android/provider')
-rw-r--r-- | core/java/android/provider/MediaStore.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index 227d94d..60ccdaf 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -322,6 +322,8 @@ public final class MediaStore { private static final int MICRO_KIND = 3; private static final String[] PROJECTION = new String[] {_ID, MediaColumns.DATA}; static final int DEFAULT_GROUP_ID = 0; + private static final Object sThumbBufLock = new Object(); + private static byte[] sThumbBuf; private static Bitmap getMiniThumbFromFile(Cursor c, Uri baseUri, ContentResolver cr, BitmapFactory.Options options) { Bitmap bitmap = null; @@ -397,11 +399,15 @@ public final class MediaStore { long magic = thumbFile.getMagic(origId); if (magic != 0) { if (kind == MICRO_KIND) { - byte[] data = new byte[MiniThumbFile.BYTES_PER_MINTHUMB]; - if (thumbFile.getMiniThumbFromFile(origId, data) != null) { - bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); - if (bitmap == null) { - Log.w(TAG, "couldn't decode byte array."); + synchronized (sThumbBufLock) { + if (sThumbBuf == null) { + sThumbBuf = new byte[MiniThumbFile.BYTES_PER_MINTHUMB]; + } + if (thumbFile.getMiniThumbFromFile(origId, sThumbBuf) != null) { + bitmap = BitmapFactory.decodeByteArray(sThumbBuf, 0, sThumbBuf.length); + if (bitmap == null) { + Log.w(TAG, "couldn't decode byte array."); + } } } return bitmap; @@ -427,11 +433,15 @@ public final class MediaStore { // Assuming thumbnail has been generated, at least original image exists. if (kind == MICRO_KIND) { - byte[] data = new byte[MiniThumbFile.BYTES_PER_MINTHUMB]; - if (thumbFile.getMiniThumbFromFile(origId, data) != null) { - bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); - if (bitmap == null) { - Log.w(TAG, "couldn't decode byte array."); + synchronized (sThumbBufLock) { + if (sThumbBuf == null) { + sThumbBuf = new byte[MiniThumbFile.BYTES_PER_MINTHUMB]; + } + if (thumbFile.getMiniThumbFromFile(origId, sThumbBuf) != null) { + bitmap = BitmapFactory.decodeByteArray(sThumbBuf, 0, sThumbBuf.length); + if (bitmap == null) { + Log.w(TAG, "couldn't decode byte array."); + } } } } else if (kind == MINI_KIND) { |