From 9382a979292e52de5c60a39ba24688362dce8bc1 Mon Sep 17 00:00:00 2001 From: Paramananda Pradhan Date: Sun, 14 Dec 2014 17:27:31 +0530 Subject: Gallery2: Make Gallery2 support OMADRM feature - Make Gallery2 can recognize and consume DRM images and videos. Change-Id: I1655d295bcec31b5760c2c86c06f815cf6ed57ee --- .../android/gallery3d/data/ImageCacheRequest.java | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/com/android/gallery3d/data/ImageCacheRequest.java') 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 { 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 { 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); -- cgit v1.2.3