summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ingest
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2013-01-18 12:47:56 -0800
committerBobby Georgescu <georgescu@google.com>2013-01-18 12:48:53 -0800
commit2f557640030af99c3aaf650dc7d7957f1a18c6e7 (patch)
tree87d3b1bd944b0b71d1f8c4a03c37bcdf1d04bd1f /src/com/android/gallery3d/ingest
parent6c95a5c97615593181365d8f320e733eb2df54e0 (diff)
downloadandroid_packages_apps_Snap-2f557640030af99c3aaf650dc7d7957f1a18c6e7.tar.gz
android_packages_apps_Snap-2f557640030af99c3aaf650dc7d7957f1a18c6e7.tar.bz2
android_packages_apps_Snap-2f557640030af99c3aaf650dc7d7957f1a18c6e7.zip
Fix importer crashes on unplug during scrolling
Bug: 8035040 Change-Id: If822b15f2210e2af42c8a38f6ac2acb25d535aa9
Diffstat (limited to 'src/com/android/gallery3d/ingest')
-rw-r--r--src/com/android/gallery3d/ingest/ui/MtpBitmapCache.java11
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;