summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2016-06-07 19:05:00 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-08-13 20:29:24 (GMT)
commita0ee49710369c26506deff779e04456a2ba489e2 (patch)
treeccb26fb27c42b55ec4e45b23aec859caed2bb911
parent20be19923f218494ff42f7c300a74855f61495e9 (diff)
downloadandroid_packages_apps_Gallery2-a0ee49710369c26506deff779e04456a2ba489e2.zip
android_packages_apps_Gallery2-a0ee49710369c26506deff779e04456a2ba489e2.tar.gz
android_packages_apps_Gallery2-a0ee49710369c26506deff779e04456a2ba489e2.tar.bz2
Gallery: Remove more possible NPEs
getCache can return null -> check this before proceeding Change-Id: I834780a4dafbe22f2d345fe5571cb20f3f3e5e2e
-rwxr-xr-xsrc/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 2ef7c2e..e0ee2ad 100755
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -1658,6 +1658,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 1c7cb8c..9d3a625 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 {
@@ -78,6 +80,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);
@@ -93,6 +97,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);
synchronized (mCache) {