summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2015-04-30 11:01:17 -0700
committerMatt Garnes <matt@cyngn.com>2015-05-05 10:43:36 -0700
commitfbab7f32d2014c2bdae4eccf99d31ca76d0bf8f6 (patch)
tree4b71b113c9c910bd4cb95efe81e84517634b3aa9 /src/com/android/gallery3d/data
parent3fcec525d3dc64e34539734bbcaf3471f40ec2db (diff)
parent725da2fbd78bf38ff71bdbe9e1f27667dbf0fa73 (diff)
downloadandroid_packages_apps_Gallery2-fbab7f32d2014c2bdae4eccf99d31ca76d0bf8f6.tar.gz
android_packages_apps_Gallery2-fbab7f32d2014c2bdae4eccf99d31ca76d0bf8f6.tar.bz2
android_packages_apps_Gallery2-fbab7f32d2014c2bdae4eccf99d31ca76d0bf8f6.zip
Merge remote-tracking branch 'caf/LA.BR.1.2.3' into caf/cm-12.1caf/cm-12.1
Conflicts: res/layout/action_mode.xml Change-Id: Id4005a098134f089e904ed090acec7ca6f786ad1
Diffstat (limited to 'src/com/android/gallery3d/data')
-rw-r--r--src/com/android/gallery3d/data/DecodeUtils.java22
-rwxr-xr-x[-rw-r--r--]src/com/android/gallery3d/data/FaceClustering.java2
-rw-r--r--src/com/android/gallery3d/data/FilterTypeSet.java3
-rw-r--r--src/com/android/gallery3d/data/ImageCacheRequest.java44
-rw-r--r--src/com/android/gallery3d/data/LocalImage.java79
-rw-r--r--src/com/android/gallery3d/data/LocalVideo.java47
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java10
-rw-r--r--src/com/android/gallery3d/data/UriImage.java78
-rw-r--r--src/com/android/gallery3d/data/UriSource.java15
9 files changed, 143 insertions, 157 deletions
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java
index b92e87712..fa709157d 100644
--- a/src/com/android/gallery3d/data/DecodeUtils.java
+++ b/src/com/android/gallery3d/data/DecodeUtils.java
@@ -85,7 +85,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
setOptionsMutable(options);
return ensureGLCompatibleBitmap(
- BitmapFactory.decodeByteArray(bytes, offset, length, options, false));
+ BitmapFactory.decodeByteArray(bytes, offset, length, options));
}
public static void decodeBounds(JobContext jc, byte[] bytes, int offset,
@@ -93,7 +93,7 @@ public class DecodeUtils {
Utils.assertTrue(options != null);
options.inJustDecodeBounds = true;
jc.setCancelListener(new DecodeCanceller(options));
- BitmapFactory.decodeByteArray(bytes, offset, length, options, false);
+ BitmapFactory.decodeByteArray(bytes, offset, length, options);
options.inJustDecodeBounds = false;
}
@@ -118,7 +118,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
options.inJustDecodeBounds = true;
- BitmapFactory.decodeFileDescriptor(fd, null, options, false);
+ BitmapFactory.decodeFileDescriptor(fd, null, options);
if (jc.isCancelled()) return null;
int w = options.outWidth;
@@ -146,7 +146,7 @@ public class DecodeUtils {
options.inJustDecodeBounds = false;
setOptionsMutable(options);
- Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options, false);
+ Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
if (result == null) return null;
// We need to resize down if the decoder does not support inSampleSize
@@ -172,7 +172,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
options.inJustDecodeBounds = true;
- BitmapFactory.decodeByteArray(data, 0, data.length, options, false);
+ BitmapFactory.decodeByteArray(data, 0, data.length, options);
if (jc.isCancelled()) return null;
if (options.outWidth < targetSize || options.outHeight < targetSize) {
return null;
@@ -182,16 +182,8 @@ public class DecodeUtils {
options.inJustDecodeBounds = false;
setOptionsMutable(options);
- Bitmap bitmap = null;
-
- try {
- bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options, false);
-
- } catch (OutOfMemoryError ex) {
- bitmap = null;
- Log.e(TAG, "OutOfMemoryError : image is too large");
- }
- return ensureGLCompatibleBitmap(bitmap);
+ return ensureGLCompatibleBitmap(
+ BitmapFactory.decodeByteArray(data, 0, data.length, options));
}
// TODO: This function should not be called directly from
diff --git a/src/com/android/gallery3d/data/FaceClustering.java b/src/com/android/gallery3d/data/FaceClustering.java
index 819915edb..a0d567902 100644..100755
--- a/src/com/android/gallery3d/data/FaceClustering.java
+++ b/src/com/android/gallery3d/data/FaceClustering.java
@@ -83,7 +83,7 @@ public class FaceClustering extends Clustering {
}
public FaceClustering(Context context) {
- mUntaggedString = context.getResources().getString(R.string.untagged);
+ mUntaggedString = context.getResources().getString(R.string.no_faces);
mContext = context;
}
diff --git a/src/com/android/gallery3d/data/FilterTypeSet.java b/src/com/android/gallery3d/data/FilterTypeSet.java
index 477ef73ad..e778ceb12 100644
--- a/src/com/android/gallery3d/data/FilterTypeSet.java
+++ b/src/com/android/gallery3d/data/FilterTypeSet.java
@@ -102,7 +102,8 @@ public class FilterTypeSet extends MediaSet implements ContentListener {
mBaseSet.enumerateMediaItems(new MediaSet.ItemConsumer() {
@Override
public void consume(int index, MediaItem item) {
- if (item.getMediaType() == mMediaType) {
+ if (item.getMediaType() == mMediaType
+ || item.getMediaType() == MediaObject.MEDIA_TYPE_DRM_IMAGE) {
if (index < 0 || index >= total) return;
Path path = item.getPath();
buf[index] = path;
diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java
index 8fb418dd7..faca5d7d8 100644
--- a/src/com/android/gallery3d/data/ImageCacheRequest.java
+++ b/src/com/android/gallery3d/data/ImageCacheRequest.java
@@ -16,11 +16,10 @@
package com.android.gallery3d.data;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.RightsStatus;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.text.TextUtils;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.common.BitmapUtils;
@@ -40,16 +39,22 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
private long mTimeModified;
public ImageCacheRequest(GalleryApp application,
- Path path, long timeModified, int type, int targetSize, String filePath, String mimetype) {
+ Path path, long timeModified, int type, int targetSize) {
mApplication = application;
mPath = path;
mType = type;
mTargetSize = targetSize;
- mFilePath = filePath;
- mMimeType = mimetype;
mTimeModified = timeModified;
}
+ public ImageCacheRequest(GalleryApp application,
+ Path path, long timeModified, int type, int targetSize, String filepath, String mimeType) {
+ this(application, path, timeModified, type,
+ targetSize);
+ mFilePath = filepath;
+ mMimeType = mimeType;
+ }
+
private String debugTag() {
return mPath + "," + mTimeModified + "," +
((mType == MediaItem.TYPE_THUMBNAIL) ? "THUMB" :
@@ -58,28 +63,16 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
@Override
public Bitmap run(JobContext jc) {
- ImageCacheService cacheService = mApplication.getImageCacheService();
-
- if (mFilePath != null && mFilePath.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- mFilePath = mFilePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int statusDisplay = drmClient.checkRightsStatus(mFilePath, Action.DISPLAY);
- int statusPlay = drmClient.checkRightsStatus(mFilePath, Action.PLAY);
- 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 (!TextUtils.isEmpty(mFilePath) && !TextUtils.isEmpty(mMimeType)
+ && !mMimeType.startsWith("video/")) {
+ if (DrmHelper.isDrmFile(mFilePath)
+ && mType != MediaItem.TYPE_MICROTHUMBNAIL) {
+ return onDecodeOriginal(jc, mType);
}
- if (drmClient != null) drmClient.release();
}
+ ImageCacheService cacheService = mApplication.getImageCacheService();
+
BytesBuffer buffer = MediaItem.getBytesBufferPool().get();
try {
boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer);
@@ -103,6 +96,7 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
} finally {
MediaItem.getBytesBufferPool().recycle(buffer);
}
+
Bitmap bitmap = onDecodeOriginal(jc, mType);
if (jc.isCancelled()) return null;
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index 96ab3e3a1..1b0384548 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -20,8 +20,7 @@ import android.annotation.TargetApi;
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.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
@@ -182,9 +181,16 @@ public class LocalImage extends LocalMediaItem {
private String mLocalFilePath;
LocalImageRequest(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;
+ }
+
+ LocalImageRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath, String mimeType) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type),localFilePath, mimeType);
mLocalFilePath = localFilePath;
}
@@ -192,6 +198,12 @@ public class LocalImage extends LocalMediaItem {
public Bitmap onDecodeOriginal(JobContext jc, final int type) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+
+ if (DrmHelper.isDrmFile(mLocalFilePath)) {
+ return DecodeUtils.ensureGLCompatibleBitmap(DrmHelper
+ .getBitmap(mLocalFilePath, options));
+ }
+
int targetSize = MediaItem.getTargetSize(type);
// try to decode from JPEG EXIF
@@ -232,38 +244,41 @@ public class LocalImage extends LocalMediaItem {
@Override
public BitmapRegionDecoder run(JobContext jc) {
+ if (DrmHelper.isDrmFile(mLocalFilePath)) {
+ return DrmHelper.createBitmapRegionDecoder(mLocalFilePath,
+ false);
+ }
+
return DecodeUtils.createBitmapRegionDecoder(jc, mLocalFilePath, false);
}
}
@Override
public int getSupportedOperations() {
- int operation = SUPPORT_DELETE | SUPPORT_SETAS | SUPPORT_INFO;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- filePath = filePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- operation |= SUPPORT_DRM_INFO;
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- ContentValues values = drmClient.getMetadata(filePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "getSupportedOperations:drmType returned= "
- + Integer.toString(drmType) + " for path= " + filePath);
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
+ int operation = SUPPORT_DELETE | SUPPORT_INFO;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ if (DrmHelper.isDrmFLBlocking(mApplication.getAndroidContext(),
+ getFilePath())) {
+ operation |= SUPPORT_SETAS;
+ }
+ operation |= SUPPORT_DRM_INFO | SUPPORT_FULL_IMAGE;
+ if (DrmHelper.isShareableDrmFile(getFilePath())) {
operation |= SUPPORT_SHARE;
}
- if (drmClient != null) drmClient.release();
} else {
- operation |= SUPPORT_SHARE | SUPPORT_EDIT | SUPPORT_CROP | SUPPORT_PRINT;
- }
- if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
- operation |= SUPPORT_FULL_IMAGE;
- }
+ operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP
+ | SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO;
+ if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
+ operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
+ }
- if (BitmapUtils.isRotationSupported(mimeType)) {
- operation |= SUPPORT_ROTATE;
- }
+ if (BitmapUtils.isRotationSupported(mimeType)) {
+ operation |= SUPPORT_ROTATE;
+ }
- if (GalleryUtils.isValidLocation(latitude, longitude)) {
- operation |= SUPPORT_SHOW_ON_MAP;
+ if (GalleryUtils.isValidLocation(latitude, longitude)) {
+ operation |= SUPPORT_SHOW_ON_MAP;
+ }
}
return operation;
}
@@ -329,6 +344,10 @@ public class LocalImage extends LocalMediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_IMAGE;
+ }
+
return MEDIA_TYPE_IMAGE;
}
@@ -363,14 +382,4 @@ public class LocalImage extends LocalMediaItem {
public String getFilePath() {
return filePath;
}
-
- @Override
- public void setConsumeRights(boolean flag) {
- consumeRights = flag;
- }
-
- @Override
- public boolean getConsumeRights() {
- return consumeRights;
- }
}
diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java
index 12b3c7acd..7fafe97ae 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<Bitmap> 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,17 @@ 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;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO
+ | 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 operation;
}
- return supported;
+ return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO
+ | SUPPORT_TRIM | SUPPORT_MUTE;
}
@Override
@@ -232,6 +229,10 @@ public class LocalVideo extends LocalMediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_VIDEO;
+ }
+
return MEDIA_TYPE_VIDEO;
}
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 68a58ea70..6e3867647 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -69,7 +69,7 @@ public abstract class MediaObject {
public static final int CACHE_STATUS_CACHED_FULL = 3;
private static long sVersionSerial = 0;
- protected boolean consumeRights = false;
+
protected long mDataVersion;
protected final Path mPath;
@@ -148,14 +148,6 @@ public abstract class MediaObject {
throw new UnsupportedOperationException();
}
- public void setConsumeRights(boolean flag) {
- throw new UnsupportedOperationException();
- }
-
- public boolean getConsumeRights() {
- throw new UnsupportedOperationException();
- }
-
public static synchronized long nextVersionNumber() {
return ++MediaObject.sVersionSerial;
}
diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java
index b9a12e7b7..13176e4aa 100644
--- a/src/com/android/gallery3d/data/UriImage.java
+++ b/src/com/android/gallery3d/data/UriImage.java
@@ -17,17 +17,13 @@
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.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.graphics.BitmapRegionDecoder;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
-import android.provider.MediaStore.Video.VideoColumns;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.app.PanoramaMetadataSupport;
@@ -63,12 +59,14 @@ public class UriImage extends MediaItem {
private PanoramaMetadataSupport mPanoramaMetadata = new PanoramaMetadataSupport(this);
private GalleryApp mApplication;
+ private String mFilePath;
public UriImage(GalleryApp application, Path path, Uri uri, String contentType) {
super(path, nextVersionNumber());
mUri = uri;
mApplication = Utils.checkNotNull(application);
mContentType = contentType;
+ mFilePath = DrmHelper.getFilePath(mApplication.getAndroidContext(), uri);
}
@Override
@@ -176,6 +174,14 @@ public class UriImage extends MediaItem {
private class RegionDecoderJob implements Job<BitmapRegionDecoder> {
@Override
public BitmapRegionDecoder run(JobContext jc) {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ BitmapRegionDecoder decoder = DrmHelper
+ .createBitmapRegionDecoder(getFilePath(), false);
+ mWidth = decoder.getWidth();
+ mHeight = decoder.getHeight();
+ return decoder;
+ }
+
if (!prepareInputFile(jc)) return null;
BitmapRegionDecoder decoder = DecodeUtils.createBitmapRegionDecoder(
jc, mFileDescriptor.getFileDescriptor(), false);
@@ -194,6 +200,10 @@ public class UriImage extends MediaItem {
@Override
public Bitmap run(JobContext jc) {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return DecodeUtils.ensureGLCompatibleBitmap(DrmHelper.getBitmap(getFilePath()));
+ }
+
if (!prepareInputFile(jc)) return null;
int targetSize = MediaItem.getTargetSize(mType);
Options options = new Options();
@@ -216,45 +226,18 @@ public class UriImage extends MediaItem {
@Override
public int getSupportedOperations() {
- int supported = SUPPORT_SETAS;
- String filePath = null;
- String scheme = mUri.getScheme();
- if ("file".equals(scheme)) {
- filePath = mUri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mApplication.getContentResolver().query(mUri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filePath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + mUri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- supported |= SUPPORT_DRM_INFO;
- filePath = filePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- ContentValues values = drmClient.getMetadata(filePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "getSupportedOperations:drmType returned= "
- + Integer.toString(drmType) + " for path= " + filePath);
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
- if (isSharable()) supported |= SUPPORT_SHARE;
+ int supported = 0;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ supported |= SUPPORT_DRM_INFO | SUPPORT_FULL_IMAGE;
+ if (DrmHelper.isShareableDrmFile(getFilePath())) {
+ supported |= SUPPORT_SHARE;
}
- if (drmClient != null) drmClient.release();
} else {
- supported |= SUPPORT_EDIT | SUPPORT_PRINT;
+ supported = SUPPORT_PRINT | SUPPORT_SETAS;
if (isSharable()) supported |= SUPPORT_SHARE;
- }
-
- if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_FULL_IMAGE;
+ if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
+ supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
+ }
}
return supported;
}
@@ -279,6 +262,10 @@ public class UriImage extends MediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_IMAGE;
+ }
+
return MEDIA_TYPE_IMAGE;
}
@@ -337,12 +324,7 @@ public class UriImage extends MediaItem {
}
@Override
- public void setConsumeRights(boolean flag) {
- consumeRights = flag;
- }
-
- @Override
- public boolean getConsumeRights() {
- return consumeRights;
+ public String getFilePath() {
+ return mFilePath;
}
}
diff --git a/src/com/android/gallery3d/data/UriSource.java b/src/com/android/gallery3d/data/UriSource.java
index f66bacd7b..b4bb16072 100644
--- a/src/com/android/gallery3d/data/UriSource.java
+++ b/src/com/android/gallery3d/data/UriSource.java
@@ -17,7 +17,9 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
+import android.drm.DrmHelper;
import android.net.Uri;
+import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import com.android.gallery3d.app.GalleryApp;
@@ -73,6 +75,19 @@ class UriSource extends MediaSource {
@Override
public Path findPathByUri(Uri uri, String type) {
String mimeType = getMimeType(uri);
+ if (DrmHelper.isDrmMimeType(mimeType)) {
+ String path = DrmHelper.getFilePath(
+ mApplication.getAndroidContext(), uri);
+ if (!TextUtils.isEmpty(path)) {
+ try {
+ return Path.fromString("/uri/"
+ + URLEncoder.encode(path, CHARSET_UTF_8) + "/"
+ + URLEncoder.encode(type, CHARSET_UTF_8));
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e);
+ }
+ }
+ }
// Try to find a most specific type but it has to be started with "image/"
if ((type == null) || (IMAGE_TYPE_ANY.equals(type)