summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/gallery3d/data')
-rw-r--r--src/com/android/gallery3d/data/DecodeUtils.java22
-rw-r--r--src/com/android/gallery3d/data/ImageCacheRequest.java29
-rw-r--r--src/com/android/gallery3d/data/LocalImage.java38
-rw-r--r--src/com/android/gallery3d/data/LocalVideo.java31
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java13
-rw-r--r--src/com/android/gallery3d/data/UriImage.java56
6 files changed, 23 insertions, 166 deletions
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java
index 12405184c..825c4bbea 100644
--- a/src/com/android/gallery3d/data/DecodeUtils.java
+++ b/src/com/android/gallery3d/data/DecodeUtils.java
@@ -87,7 +87,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,
@@ -95,7 +95,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;
}
@@ -120,7 +120,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;
@@ -148,7 +148,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
@@ -174,7 +174,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;
@@ -184,16 +184,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/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java
index 8fb418dd7..6cbc5c5ea 100644
--- a/src/com/android/gallery3d/data/ImageCacheRequest.java
+++ b/src/com/android/gallery3d/data/ImageCacheRequest.java
@@ -16,9 +16,6 @@
package com.android.gallery3d.data;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.RightsStatus;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -35,18 +32,14 @@ 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, 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;
}
@@ -60,26 +53,6 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
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 (drmClient != null) drmClient.release();
- }
-
BytesBuffer buffer = MediaItem.getBytesBufferPool().get();
try {
boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer);
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index 96ab3e3a1..2b01c1e22 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -20,8 +20,6 @@ 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.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
@@ -175,16 +173,16 @@ public class LocalImage extends LocalMediaItem {
@Override
public Job<Bitmap> requestImage(int type) {
return new LocalImageRequest(mApplication, mPath, dateModifiedInSec,
- type, filePath, mimeType);
+ type, filePath);
}
public static class LocalImageRequest extends ImageCacheRequest {
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;
}
@@ -238,24 +236,10 @@ public class LocalImage extends LocalMediaItem {
@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) {
- operation |= SUPPORT_SHARE;
- }
- if (drmClient != null) drmClient.release();
- } else {
- operation |= SUPPORT_SHARE | SUPPORT_EDIT | SUPPORT_CROP | SUPPORT_PRINT;
- }
+ int operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP
+ | SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO;
if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
- operation |= SUPPORT_FULL_IMAGE;
+ operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
}
if (BitmapUtils.isRotationSupported(mimeType)) {
@@ -363,14 +347,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..4b8774ca4 100644
--- a/src/com/android/gallery3d/data/LocalVideo.java
+++ b/src/com/android/gallery3d/data/LocalVideo.java
@@ -17,10 +17,7 @@
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.graphics.Bitmap;
import android.graphics.BitmapRegionDecoder;
import android.net.Uri;
@@ -155,18 +152,17 @@ 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);
}
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;
}
@@ -186,24 +182,7 @@ 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 (drmClient != null) drmClient.release();
- } else {
- Log.e("LocalVideo", "yy:share added for path= " + filePath);
- supported |= SUPPORT_SHARE;
- }
-
- return supported;
+ return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO | SUPPORT_TRIM | SUPPORT_MUTE;
}
@Override
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 68a58ea70..530ee306e 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -42,15 +42,12 @@ public abstract class MediaObject {
public static final int SUPPORT_CAMERA_SHORTCUT = 1 << 15;
public static final int SUPPORT_MUTE = 1 << 16;
public static final int SUPPORT_PRINT = 1 << 17;
- public static final int SUPPORT_DRM_INFO = 1 << 18;
public static final int SUPPORT_ALL = 0xffffffff;
// These are the bits returned from getMediaType():
public static final int MEDIA_TYPE_UNKNOWN = 1;
public static final int MEDIA_TYPE_IMAGE = 2;
public static final int MEDIA_TYPE_VIDEO = 4;
- public static final int MEDIA_TYPE_DRM_VIDEO = 5;
- public static final int MEDIA_TYPE_DRM_IMAGE = 6;
public static final int MEDIA_TYPE_ALL = MEDIA_TYPE_IMAGE | MEDIA_TYPE_VIDEO;
public static final String MEDIA_TYPE_IMAGE_STRING = "image";
@@ -69,7 +66,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 +145,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..b3fe1de03 100644
--- a/src/com/android/gallery3d/data/UriImage.java
+++ b/src/com/android/gallery3d/data/UriImage.java
@@ -17,17 +17,12 @@
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.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;
@@ -216,45 +211,10 @@ 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;
- }
- if (drmClient != null) drmClient.release();
- } else {
- supported |= SUPPORT_EDIT | SUPPORT_PRINT;
- if (isSharable()) supported |= SUPPORT_SHARE;
- }
-
+ int supported = SUPPORT_PRINT | SUPPORT_SETAS;
+ if (isSharable()) supported |= SUPPORT_SHARE;
if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_FULL_IMAGE;
+ supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
}
return supported;
}
@@ -335,14 +295,4 @@ public class UriImage extends MediaItem {
public int getRotation() {
return mRotation;
}
-
- @Override
- public void setConsumeRights(boolean flag) {
- consumeRights = flag;
- }
-
- @Override
- public boolean getConsumeRights() {
- return consumeRights;
- }
}