diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-01-22 06:34:19 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-01-22 06:34:19 -0800 |
commit | d57ee4d7873f861f78cd42737ffb35cfdc9ebde7 (patch) | |
tree | 87c167912d5b17ecb4259fcb62a9a913667b9e5c /src/com/android/gallery3d/data/ImageCacheRequest.java | |
parent | e3a5ddeedc2dc81ff57f973f228cd80d472924aa (diff) | |
parent | 9382a979292e52de5c60a39ba24688362dce8bc1 (diff) | |
download | android_packages_apps_Gallery2-d57ee4d7873f861f78cd42737ffb35cfdc9ebde7.tar.gz android_packages_apps_Gallery2-d57ee4d7873f861f78cd42737ffb35cfdc9ebde7.tar.bz2 android_packages_apps_Gallery2-d57ee4d7873f861f78cd42737ffb35cfdc9ebde7.zip |
Merge "Gallery2: Make Gallery2 support OMADRM feature"
Diffstat (limited to 'src/com/android/gallery3d/data/ImageCacheRequest.java')
-rw-r--r-- | src/com/android/gallery3d/data/ImageCacheRequest.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java index 6cbc5c5ea..f93f6e28a 100644 --- a/src/com/android/gallery3d/data/ImageCacheRequest.java +++ b/src/com/android/gallery3d/data/ImageCacheRequest.java @@ -16,6 +16,9 @@ package com.android.gallery3d.data; +import android.drm.DrmManagerClient; +import android.drm.DrmStore.Action; +import android.drm.DrmStore.RightsStatus; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -32,14 +35,18 @@ abstract class ImageCacheRequest implements Job<Bitmap> { private Path mPath; private int mType; private int mTargetSize; + private String mFilePath; + private String mMimeType; private long mTimeModified; public ImageCacheRequest(GalleryApp application, - Path path, long timeModified, int type, int targetSize) { + Path path, long timeModified, int type, int targetSize, String filePath, String mimetype) { mApplication = application; mPath = path; mType = type; mTargetSize = targetSize; + mFilePath = filePath; + mMimeType = mimetype; mTimeModified = timeModified; } @@ -53,6 +60,31 @@ abstract class ImageCacheRequest implements Job<Bitmap> { public Bitmap run(JobContext jc) { ImageCacheService cacheService = mApplication.getImageCacheService(); + if (mFilePath != null && mFilePath.endsWith(".dcf")) { + DrmManagerClient drmClient = new DrmManagerClient(mApplication.getAndroidContext()); + mFilePath = mFilePath.replace("/storage/emulated/0", "/storage/emulated/legacy"); + + // This hack is added to work FL. It will remove after the sdcard permission issue solved + int statusDisplay = drmClient.checkRightsStatus(mFilePath, Action.DISPLAY); + statusDisplay = RightsStatus.RIGHTS_VALID; + int statusPlay = drmClient.checkRightsStatus(mFilePath, Action.PLAY); + statusPlay = RightsStatus.RIGHTS_VALID; + + if (mMimeType == null) { + if ((RightsStatus.RIGHTS_VALID != statusDisplay) + && (RightsStatus.RIGHTS_VALID != statusPlay)) { + return null; + } + } else if (mMimeType.startsWith("video/") + && RightsStatus.RIGHTS_VALID != statusPlay) { + return null; + } else if (mMimeType.startsWith("image/") + && RightsStatus.RIGHTS_VALID != statusDisplay) { + return null; + } + if (drmClient != null) drmClient.release(); + } + BytesBuffer buffer = MediaItem.getBytesBufferPool().get(); try { boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer); |