diff options
author | Bobby Georgescu <georgescu@google.com> | 2013-01-18 12:47:56 -0800 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2013-01-18 12:48:53 -0800 |
commit | 5a1adfcb2d9a6a7402989d152dd3443f48c321dd (patch) | |
tree | 2b4150ad8d4aa4aae6204b143dee6fd57c95b4af /src/com/android/gallery3d | |
parent | eebf9e81673150a6c4fec89b64e3cdb595377c83 (diff) | |
download | android_packages_apps_Gallery2-5a1adfcb2d9a6a7402989d152dd3443f48c321dd.tar.gz android_packages_apps_Gallery2-5a1adfcb2d9a6a7402989d152dd3443f48c321dd.tar.bz2 android_packages_apps_Gallery2-5a1adfcb2d9a6a7402989d152dd3443f48c321dd.zip |
Fix importer crashes on unplug during scrolling
Bug: 8035040
Change-Id: If822b15f2210e2af42c8a38f6ac2acb25d535aa9
Diffstat (limited to 'src/com/android/gallery3d')
-rw-r--r-- | src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java b/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java index 66ac4301f..307531d5b 100644 --- a/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java +++ b/src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java @@ -34,6 +34,9 @@ public class MtpBitmapCache extends LruCache<Integer, Bitmap> { public synchronized static void onDeviceDisconnected(MtpDevice device) { if (sInstance != null && sInstance.mDevice == device) { + synchronized (sInstance) { + sInstance.mDevice = null; + } sInstance = null; } } @@ -56,7 +59,13 @@ public class MtpBitmapCache extends LruCache<Integer, Bitmap> { } private Bitmap createAndInsert(Integer key) { - byte[] imageBytes = mDevice.getThumbnail(key); + MtpDevice device; + synchronized (this) { + device = mDevice; + } + if (device == null) return null; + byte[] imageBytes = device.getThumbnail(key); + if (imageBytes == null) return null; Bitmap created = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); put(key, created); return created; |