diff options
author | George Mount <mount@google.com> | 2012-10-11 10:35:46 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-10-11 10:35:46 -0700 |
commit | 968e68d546ca9c8943afe1e179d6c2174390c39e (patch) | |
tree | db6dd4527aaf5c1a34d84efe36c02c659b796414 | |
parent | 98cc24e5356e36053e82ffb3188b0b3e464a4b17 (diff) | |
parent | 1ac23d436d226a926adc5685b8cf30a32a0afea7 (diff) | |
download | android_packages_apps_Snap-968e68d546ca9c8943afe1e179d6c2174390c39e.tar.gz android_packages_apps_Snap-968e68d546ca9c8943afe1e179d6c2174390c39e.tar.bz2 android_packages_apps_Snap-968e68d546ca9c8943afe1e179d6c2174390c39e.zip |
am 37a93336: Merge "Clear cached stitching preview thumbnails." into gb-ub-photos-arches
* commit '37a9333651cead185d982d9b809cb3425a24d3d8':
Clear cached stitching preview thumbnails.
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/BlobCache.java | 14 | ||||
-rw-r--r-- | src/com/android/gallery3d/data/ImageCacheService.java | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BlobCache.java b/gallerycommon/src/com/android/gallery3d/common/BlobCache.java index 7788e61f5..3c131e591 100644 --- a/gallerycommon/src/com/android/gallery3d/common/BlobCache.java +++ b/gallerycommon/src/com/android/gallery3d/common/BlobCache.java @@ -74,6 +74,7 @@ import java.io.RandomAccessFile; import java.nio.ByteOrder; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.util.Arrays; import java.util.zip.Adler32; public class BlobCache implements Closeable { @@ -379,6 +380,16 @@ public class BlobCache implements Closeable { updateIndexHeader(); } + public void clearEntry(long key) throws IOException { + if (!lookupInternal(key, mActiveHashStart)) { + return; // Nothing to clear + } + byte[] header = mBlobHeader; + Arrays.fill(header, (byte) 0); + mActiveDataFile.seek(mFileOffset); + mActiveDataFile.write(header); + } + // Appends the data to the active file. It also updates the hash entry. // The proper hash entry (suitable for insertion or replacement) must be // pointed by mSlotOffset. @@ -485,6 +496,9 @@ public class BlobCache implements Closeable { return false; } long blobKey = readLong(header, BH_KEY); + if (blobKey == 0) { + return false; // This entry has been cleared. + } if (blobKey != req.key) { Log.w(TAG, "blob key does not match: " + blobKey); return false; diff --git a/src/com/android/gallery3d/data/ImageCacheService.java b/src/com/android/gallery3d/data/ImageCacheService.java index 38e32cbee..d42e9521d 100644 --- a/src/com/android/gallery3d/data/ImageCacheService.java +++ b/src/com/android/gallery3d/data/ImageCacheService.java @@ -91,6 +91,18 @@ public class ImageCacheService { } } + public void clearImageData(Path path, int type) { + byte[] key = makeKey(path, type); + long cacheKey = Utils.crc64Long(key); + synchronized (mCache) { + try { + mCache.clearEntry(cacheKey); + } catch (IOException ex) { + // ignore. + } + } + } + private static byte[] makeKey(Path path, int type) { return GalleryUtils.getBytes(path.toString() + "+" + type); } |