summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/UriImage.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/data/UriImage.java')
-rw-r--r--src/com/android/gallery3d/data/UriImage.java56
1 files changed, 53 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java
index b3fe1de03..fba34a0b3 100644
--- a/src/com/android/gallery3d/data/UriImage.java
+++ b/src/com/android/gallery3d/data/UriImage.java
@@ -17,12 +17,17 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.drm.DrmManagerClient;
+import android.drm.DrmStore.DrmDeliveryType;
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;
@@ -211,10 +216,45 @@ public class UriImage extends MediaItem {
@Override
public int getSupportedOperations() {
- int supported = SUPPORT_PRINT | SUPPORT_SETAS;
- if (isSharable()) supported |= SUPPORT_SHARE;
+ 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");
+ DrmManagerClient drmClient = new DrmManagerClient(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;
+ }
+ if (drmClient != null) drmClient.release();
+ } else {
+ supported |= SUPPORT_EDIT | SUPPORT_PRINT;
+ if (isSharable()) supported |= SUPPORT_SHARE;
+ }
+
if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
+ supported |= SUPPORT_FULL_IMAGE;
}
return supported;
}
@@ -295,4 +335,14 @@ public class UriImage extends MediaItem {
public int getRotation() {
return mRotation;
}
+
+ @Override
+ public void setConsumeRights(boolean flag) {
+ consumeRights = flag;
+ }
+
+ @Override
+ public boolean getConsumeRights() {
+ return consumeRights;
+ }
}