summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2016-06-07 21:05:00 +0200
committerArne Coucheron <arco68@gmail.com>2017-03-10 07:20:38 +0100
commit31186d480d2c957cccf271fde8e2354268f2a722 (patch)
treef09ef018414a744f0dcc3162bd7600a9266a0c8f
parent56e5d2b0060531c49d9fab5ffe40d7e19838eb61 (diff)
downloadandroid_packages_apps_Gallery2-31186d480d2c957cccf271fde8e2354268f2a722.tar.gz
android_packages_apps_Gallery2-31186d480d2c957cccf271fde8e2354268f2a722.tar.bz2
android_packages_apps_Gallery2-31186d480d2c957cccf271fde8e2354268f2a722.zip
Gallery2: Remove more possible NPEs
getCache can return null -> check this before proceeding Change-Id: I834780a4dafbe22f2d345fe5571cb20f3f3e5e2e
-rw-r--r--src/com/android/gallery3d/app/MoviePlayer.java1
-rw-r--r--src/com/android/gallery3d/data/ImageCacheService.java6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 5c900acd6..646692085 100644
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -1718,6 +1718,7 @@ class Bookmarker {
BlobCache cache = CacheManager.getCache(mContext,
BOOKMARK_CACHE_FILE, BOOKMARK_CACHE_MAX_ENTRIES,
BOOKMARK_CACHE_MAX_BYTES, BOOKMARK_CACHE_VERSION);
+ if (cache == null) return null;
byte[] data = cache.lookup(uri.hashCode());
if (data == null) return null;
diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java
index 129c113a6..861d4b766 100644
--- a/src/com/android/gallery3d/data/ImageCacheService.java
+++ b/src/com/android/gallery3d/data/ImageCacheService.java
@@ -56,6 +56,8 @@ public class ImageCacheService {
* @return true if the image data is found; false if not found.
*/
public boolean getImageData(Path path, long timeModified, int type, BytesBuffer buffer) {
+ if (mCache == null) return false;
+
byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
try {
@@ -81,6 +83,8 @@ public class ImageCacheService {
}
public void putImageData(Path path, long timeModified, int type, byte[] value) {
+ if (mCache == null) return;
+
byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
ByteBuffer buffer = ByteBuffer.allocate(key.length + value.length);
@@ -99,6 +103,8 @@ public class ImageCacheService {
}
public void clearImageData(Path path, long timeModified, int type) {
+ if (mCache == null) return;
+
byte[] key = makeKey(path, timeModified, type);
long cacheKey = Utils.crc64Long(key);
if (mCache == null) {