From 01f5f347cf33813b51bd0865dc620d001c8d8735 Mon Sep 17 00:00:00 2001 From: Paramananda Date: Tue, 24 Mar 2015 17:51:29 +0530 Subject: Gallery2 : Uses internal Drm image decoder api in Gallery app - Remove all previous drm implementation which is basically uses base bitmap decode apis to decode drm image files. - Introduced new hidden apis on BitmapFactory and BitmapRegionDecoder specific to DRM content which is more practical to DRM framework. - Uses DrmHelper a utility drm api library to code reusability. - This approch will fix the issue on sharing images from Third party application. CRs-fixed : 804191 Change-Id: I2e9489800c57df4fdeeb21f1548fbccc6dfbd3f9 --- src/com/android/gallery3d/data/LocalVideo.java | 45 +++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src/com/android/gallery3d/data/LocalVideo.java') diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java index 12b3c7acd..98ae18d0b 100644 --- a/src/com/android/gallery3d/data/LocalVideo.java +++ b/src/com/android/gallery3d/data/LocalVideo.java @@ -17,10 +17,8 @@ package com.android.gallery3d.data; import android.content.ContentResolver; -import android.content.ContentValues; import android.database.Cursor; -import android.drm.DrmManagerClientWrapper; -import android.drm.DrmStore.DrmDeliveryType; +import android.drm.DrmHelper; import android.graphics.Bitmap; import android.graphics.BitmapRegionDecoder; import android.net.Uri; @@ -155,18 +153,24 @@ public class LocalVideo extends LocalMediaItem { @Override public Job requestImage(int type) { - // Drm start - return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec,type, filePath, mimeType); - // Drm end + return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec, + type, filePath, mimeType); } public static class LocalVideoRequest extends ImageCacheRequest { private String mLocalFilePath; LocalVideoRequest(GalleryApp application, Path path, long timeModified, - int type, String localFilePath, String mimetype) { + int type, String localFilePath) { super(application, path, timeModified, type, - MediaItem.getTargetSize(type),localFilePath, mimetype); + MediaItem.getTargetSize(type)); + mLocalFilePath = localFilePath; + } + + LocalVideoRequest(GalleryApp application, Path path, long timeModified, + int type, String localFilePath, String mimeType) { + super(application, path, timeModified, type, + MediaItem.getTargetSize(type), localFilePath, mimeType); mLocalFilePath = localFilePath; } @@ -186,24 +190,15 @@ public class LocalVideo extends LocalMediaItem { @Override public int getSupportedOperations() { - int supported = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO; - if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) { - supported |= SUPPORT_DRM_INFO; - DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext()); - ContentValues values = drmClient.getMetadata(filePath); - int drmType = values.getAsInteger("DRM-TYPE"); - Log.d("LocalVideo", "getSupportedOperations:drmType returned= " - + Integer.toString(drmType) + " for path= " + filePath); - if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) { - supported |= SUPPORT_SHARE; + int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO | SUPPORT_TRIM | SUPPORT_MUTE; + if (DrmHelper.isDrmFile(getFilePath())) { + operation |= SUPPORT_DRM_INFO; + if (DrmHelper.isShareableDrmFile(getFilePath())) { + operation |= SUPPORT_SHARE; } - if (drmClient != null) drmClient.release(); - } else { - Log.e("LocalVideo", "yy:share added for path= " + filePath); - supported |= SUPPORT_SHARE; } - return supported; + return operation; } @Override @@ -232,6 +227,10 @@ public class LocalVideo extends LocalMediaItem { @Override public int getMediaType() { + if (DrmHelper.isDrmFile(getFilePath())) { + return MEDIA_TYPE_DRM_VIDEO; + } + return MEDIA_TYPE_VIDEO; } -- cgit v1.2.3