summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorParamananda <parama@codeaurora.org>2015-03-24 17:51:29 +0530
committerRicardo Cerqueira <ricardo@cyngn.com>2015-09-15 21:31:49 +0100
commit01f5f347cf33813b51bd0865dc620d001c8d8735 (patch)
treef4176c8179058a09fe95700f03273c676e593103 /src/com/android
parent43044da1965c1b687695f3f4e1d44d3636496978 (diff)
downloadandroid_packages_apps_Gallery2-01f5f347cf33813b51bd0865dc620d001c8d8735.tar.gz
android_packages_apps_Gallery2-01f5f347cf33813b51bd0865dc620d001c8d8735.tar.bz2
android_packages_apps_Gallery2-01f5f347cf33813b51bd0865dc620d001c8d8735.zip
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
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java115
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java79
-rw-r--r--src/com/android/gallery3d/app/GalleryActivity.java82
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java47
-rwxr-xr-xsrc/com/android/gallery3d/app/PhotoDataAdapter.java6
-rwxr-xr-xsrc/com/android/gallery3d/app/PhotoPage.java201
-rw-r--r--src/com/android/gallery3d/app/SlideshowPage.java16
-rw-r--r--src/com/android/gallery3d/app/Wallpaper.java1
-rw-r--r--src/com/android/gallery3d/data/DecodeUtils.java22
-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.java75
-rw-r--r--src/com/android/gallery3d/data/LocalVideo.java45
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java10
-rw-r--r--src/com/android/gallery3d/data/UriImage.java80
-rw-r--r--src/com/android/gallery3d/data/UriSource.java15
-rw-r--r--src/com/android/gallery3d/filtershow/crop/CropActivity.java6
-rw-r--r--src/com/android/gallery3d/glrenderer/NinePatchTexture.java2
-rw-r--r--src/com/android/gallery3d/glrenderer/ResourceTexture.java13
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java14
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java4
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java13
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java31
-rwxr-xr-xsrc/com/android/gallery3d/ui/PhotoView.java28
24 files changed, 253 insertions, 699 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index d0056fcfd..629e88210 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -18,24 +18,14 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.Context;
-import android.content.ContentValues;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmRights;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
+import android.drm.DrmHelper;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
-import android.text.TextUtils;
import android.text.TextUtils;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
@@ -47,7 +37,6 @@ import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -74,20 +63,12 @@ import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.MediaSetUtils;
import java.util.Locale;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Random;
-
public class AlbumPage extends ActivityState implements GalleryActionBar.ClusterRunner,
SelectionManager.SelectionListener, MediaSet.SyncListener, GalleryActionBar.OnAlbumModeSelectedListener {
@SuppressWarnings("unused")
private static final String TAG = "AlbumPage";
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
public static final String KEY_MEDIA_PATH = "media-path";
public static final String KEY_PARENT_MEDIA_PATH = "parent-media-path";
public static final String KEY_SET_CENTER = "set-center";
@@ -121,8 +102,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private boolean mGetContent;
private boolean mShowClusterMenu;
- private boolean mIsWallpaper;
- private boolean mIsContactPhoto;
+
private ActionModeHandler mActionModeHandler;
private int mFocusIndex = 0;
private DetailsHelper mDetailsHelper;
@@ -331,6 +311,12 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (isLayoutRtl && item == null) {
return; // Item not ready yet, ignore the click
}
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(
+ mActivity.getAndroidContext(), item.getContentUri()))) {
+ Toast.makeText(mActivity, R.string.no_permission_for_drm,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
onGetContent(item);
} else if (mLaunchedFromPhotoPage) {
if (isLayoutRtl && item == null) {
@@ -343,65 +329,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
onBackPressed();
} else {
- Context context = (Context) mActivity;
- Uri uri = item.getContentUri();
- Log.d(TAG, "pickPhoto:uri=" + item.getContentUri());
- String path = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- path = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- Log.d(TAG, "pickPhoto:path = " + path);
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(context);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int status = -1;
- Log.d(TAG, "pickPhoto:item type = " + Integer.toString(item.getMediaType()));
-
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- status = drmClient.checkRightsStatus(path, Action.DISPLAY);
- } else {
- status = drmClient.checkRightsStatus(path, Action.PLAY);
- }
- Log.d(TAG, "pickPhoto:status fron drmClient.checkRightsStatus is "
- + Integer.toString(status));
-
- ContentValues values = drmClient.getMetadata(path);
- if (RightsStatus.RIGHTS_VALID!= status) {
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "pickPhoto:address = " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- context.sendBroadcast(intent);
- return;
- }
-
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onSingleTapUp:drm-type = " + Integer.toString(drmType));
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- item.setConsumeRights(true);
- }
- Toast.makeText(context, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
-
// Get into the PhotoPage.
// mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
Bundle data = new Bundle();
@@ -435,7 +362,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
Activity activity = mActivity;
if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
-
Intent intent = new Intent(CropActivity.CROP_ACTION, uri)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtras(getData());
@@ -444,29 +370,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
activity.startActivity(intent);
activity.finish();
- } else if (mIsWallpaper != true && mIsContactPhoto != true) {
- String path = null;
- if (item instanceof LocalMediaItem) {
- path = ((LocalMediaItem)item).filePath;
- }
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper((Context) mActivity);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(path);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onGetContent:DRM-TYPE = " + Integer.toString(drmType));
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
- activity.setResult(Activity.RESULT_OK, new Intent(null, item.getContentUri()));
- } else {
- Toast.makeText((Context) mActivity, R.string.no_permission_for_drm,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- } else {
- activity.setResult(Activity.RESULT_OK,
- new Intent(null, item.getContentUri()));
- }
- activity.finish();
} else {
Intent intent = new Intent(null, item.getContentUri())
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -509,8 +412,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
initializeViews();
initializeData(data);
mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
- mIsWallpaper = data.getBoolean("com.android.gallery3d.IsWallpaper", false);
- mIsContactPhoto = data.getBoolean("isContactPhoto", false);
mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 5e100498c..c09b91f6e 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -21,21 +21,12 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.Context;
-import android.content.ContentValues;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmRights;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
import android.graphics.Rect;
import android.net.Uri;
-import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.provider.MediaStore.Video.VideoColumns;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuInflater;
@@ -72,13 +63,8 @@ import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.HelpUtils;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import java.util.Random;
public class AlbumSetPage extends ActivityState implements
SelectionManager.SelectionListener, GalleryActionBar.ClusterRunner,
@@ -88,8 +74,6 @@ public class AlbumSetPage extends ActivityState implements
private static final int MSG_PICK_ALBUM = 1;
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
public static final String KEY_MEDIA_PATH = "media-path";
public static final String KEY_SET_TITLE = "set-title";
public static final String KEY_SET_SUBTITLE = "set-subtitle";
@@ -258,69 +242,6 @@ public class AlbumSetPage extends ActivityState implements
if (!mIsActive) return;
MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
- if (targetSet.getTotalMediaItemCount() == 1) {
- MediaItem item = null;
- item = targetSet.getCoverMediaItem();
- Uri uri = item.getContentUri();
- Context context = (Context) mActivity;
-
- Log.d(TAG, "pickAlbum:uri=" + item.getContentUri());
- String path = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- path = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- Log.d(TAG, "pickAlbum:path = " + path);
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(context);
- int status = -1;
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- Log.d(TAG, "pickAlbum:item type = " + Integer.toString(item.getMediaType()));
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- status = drmClient.checkRightsStatus(path, Action.DISPLAY);
- } else {
- status = drmClient.checkRightsStatus(path, Action.PLAY);
- }
- Log.d(TAG, "pickAlbum:status fron drmClient.checkRightsStatus is "
- + Integer.toString(status));
-
- ContentValues values = drmClient.getMetadata(path);
-
- if (RightsStatus.RIGHTS_VALID != status) {
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "pickAlbum:address = " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- context.sendBroadcast(intent);
- return;
- }
-
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "pickAlbum:drm-type = " + Integer.toString(drmType));
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- item.setConsumeRights(true);
- }
- Toast.makeText(context, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
- }
if (targetSet == null) return; // Content is dirty, we shall reload soon
if (targetSet.getTotalMediaItemCount() == 0) {
showEmptyAlbumToast(Toast.LENGTH_SHORT);
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index d918e1457..1be5e73c8 100644
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -18,19 +18,11 @@ package com.android.gallery3d.app;
import android.app.Dialog;
import android.content.ContentResolver;
-import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClient;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
import android.net.Uri;
import android.os.Bundle;
-import android.provider.MediaStore.Video.VideoColumns;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.View;
@@ -42,14 +34,12 @@ import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.picasasource.PicasaSource;
import com.android.gallery3d.util.GalleryUtils;
public final class GalleryActivity extends AbstractGalleryActivity implements OnCancelListener {
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
public static final String EXTRA_SLIDESHOW = "slideshow";
public static final String EXTRA_DREAM = "dream";
public static final String EXTRA_CROP = "crop";
@@ -213,77 +203,7 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
startDefaultPage();
}
} else {
- Path itemPath = null;
- String imagePath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- imagePath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = this.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- imagePath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- String mime_Type = intent.getType();
- if (imagePath != null
- && (imagePath.endsWith(".dcf") || imagePath.endsWith(".dm"))
- && "*/*".equals(mime_Type)) {
- imagePath = imagePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- DrmManagerClient drmClient = new DrmManagerClient(this);
- mime_Type = drmClient.getOriginalMimeType(imagePath);
- if (drmClient != null) drmClient.release();
- }
-
- Log.d(TAG, "DRM mime_Type==" + mime_Type);
- itemPath = getDataManager().findPathByUri(uri, mime_Type);
- Log.d(TAG, "itemPath=" + itemPath);
- // If item path not correct, just finish starting the gallery
- if (itemPath == null) {
- finish();
- return;
- }
-
- Log.d(TAG,"imagePath=" + imagePath);
- if (intent.getBooleanExtra("WidgetClick", false) == true) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- int status = drmClient.checkRightsStatus(imagePath, Action.DISPLAY);
- if (RightsStatus.RIGHTS_VALID != status) {
- ContentValues values = drmClient.getMetadata(imagePath);
- String address = values.getAsString("Rights-Issuer");
- Intent buyIntent = new Intent(BUY_LICENSE);
- buyIntent.putExtra("DRM_FILE_PATH", address);
- sendBroadcast(buyIntent);
- Log.d(TAG, "startViewAction:WidgetClick, intent sent");
- }
- if (drmClient != null) drmClient.release();
- }
-
- if (imagePath != null
- && (imagePath.endsWith(".dcf") || imagePath.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- imagePath = imagePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(imagePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- MediaItem mediaItem = (MediaItem) getDataManager()
- .getMediaObject(itemPath);
- if (mediaItem.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- mediaItem.setConsumeRights(true);
- }
- Toast.makeText(this, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
-
+ Path itemPath = dm.findPathByUri(uri, contentType);
Path albumPath = dm.getDefaultSetOf(itemPath);
data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 0943195a7..f6fcaf87c 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -27,9 +27,6 @@ import android.bluetooth.BluetoothDevice;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -38,8 +35,7 @@ import android.content.res.Configuration;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.DrmDeliveryType;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
@@ -53,7 +49,6 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
import android.provider.OpenableColumns;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -245,6 +240,16 @@ public class MovieActivity extends Activity {
initEffects(mp.getAudioSessionId());
}
});
+
+ // DRM validation
+ Uri original = intent.getData();
+ String mimeType = intent.getType();
+ String filepath = DrmHelper.getFilePath(this, original);
+ if (DrmHelper.isDrmFile(filepath)) {
+ if (!DrmHelper.validateLicense(this, filepath, mimeType)) {
+ finish();
+ }
+ }
}
private void setActionBarLogoFromIntent(Intent intent) {
@@ -312,36 +317,6 @@ public class MovieActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- String path = null;
- String scheme = mUri.getScheme();
- if ("file".equals(scheme)) {
- path = mUri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = getContentResolver().query(mUri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + mUri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- Log.d(TAG, "onCreateOptionsMenu= " + path);
- if ((path != null) && ((path.endsWith(".dcf") || path.endsWith(".dm")))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- ContentValues values = drmClient.getMetadata(path);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onCreateOptionsMenu:DRM-TYPE = " + Integer.toString(drmType));
- if (drmType != DrmDeliveryType.SEPARATE_DELIVERY) {
- return true;
- }
- if (drmClient != null) drmClient.release();
- }
-
getMenuInflater().inflate(R.menu.movie, menu);
MenuItem shareMenu = menu.findItem(R.id.action_share);
ShareActionProvider provider = (ShareActionProvider) shareMenu.getActionProvider();
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index 4322d9b7a..5812bf82d 100755
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -522,9 +522,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
@Override
public boolean isVideo(int offset) {
MediaItem item = getItem(mCurrentIndex + offset);
- return (item == null)
- ? false
- : item.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO;
+ return (item == null) ? false
+ : item.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO
+ || item.getMediaType() == MediaItem.MEDIA_TYPE_DRM_VIDEO;
}
@Override
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 7bc9c9d4f..65c26278a 100755
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -20,18 +20,11 @@ import android.annotation.TargetApi;
import android.app.ActionBar.OnMenuVisibilityListener;
import android.app.Activity;
import android.content.ActivityNotFoundException;
-import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
+import android.drm.DrmHelper;
import android.graphics.Rect;
import android.media.MediaFile;
import android.net.Uri;
@@ -42,8 +35,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
@@ -54,7 +45,6 @@ import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.ComboAlbum;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.FilterDeleteSet;
@@ -87,11 +77,6 @@ import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.UsageStatistics;
import com.android.gallery3d.util.ViewGifImage;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
-
import java.util.ArrayList;
import java.util.Locale;
@@ -100,8 +85,6 @@ public abstract class PhotoPage extends ActivityState implements
PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener {
private static final String TAG = "PhotoPage";
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
private static final int MSG_HIDE_BARS = 1;
private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
private static final int MSG_UPDATE_ACTION_BAR = 5;
@@ -590,16 +573,6 @@ public abstract class PhotoPage extends ActivityState implements
PhotoPage.this);
}
}
- MediaItem item = mModel.getMediaItem(0);
- if (item != null
- && item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE
- && item.getConsumeRights() == true) {
- Log.d(TAG, "onDestroy,consume rights = true");
- item.setConsumeRights(false);
- Uri uri = item.getContentUri();
- Log.d(TAG, "onDestroy:uri=" + uri);
- consumeRights(uri);
- }
}
@Override
@@ -639,40 +612,6 @@ public abstract class PhotoPage extends ActivityState implements
});
}
- private void consumeRights(Uri uri) {
- Log.d(TAG, "consumeRights:uri=" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getContentResolver().query(uri,
- 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: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- Options options = new Options();
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(new File(filepath));
- FileDescriptor fd = fis.getFD();
- Log.d(TAG, "onLoadingFinished:calling decodeFileDescriptor with true");
- BitmapFactory.decodeFileDescriptor(fd, new Rect(), options, true);
- } catch(IOException e) {
- Log.w(TAG, "IOException");
- } finally {
- Utils.closeSilently(fis);
- }
- }
-
@Override
public void onPictureCenter(boolean isCamera) {
isCamera = isCamera || (mHasCameraScreennailOrPlaceholder && mAppBridge == null);
@@ -748,40 +687,6 @@ public abstract class PhotoPage extends ActivityState implements
private Intent createShareIntent(MediaObject mediaObject) {
int type = mediaObject.getMediaType();
- Uri uri = mediaObject.getContentUri();
- Log.d(TAG, "updateShareURI:uri:" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mApplication.getContentResolver().query(uri,
- 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: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- if (filepath != null && filepath.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mActivity.getAndroidContext());
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(filepath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "updateShareURI:drmType returned= " + Integer.toString(drmType)
- + " for path= " + filepath);
- if (drmType != DrmDeliveryType.SEPARATE_DELIVERY) {
- return null;
- }
- if (drmClient != null) drmClient.release();
- }
-
return new Intent(Intent.ACTION_SEND)
.setType(MenuExecutor.getMimeType(type))
.putExtra(Intent.EXTRA_STREAM, mediaObject.getContentUri())
@@ -899,6 +804,20 @@ public abstract class PhotoPage extends ActivityState implements
requestDeferredUpdate();
} else {
updateUIForCurrentPhoto();
+
+ // Manage DRM rights while image selection changed. this
+ // flow will comes for both image and video, but here
+ // we will consume rights for image files only.
+ // Do not consume rights of a GIF image and video here.
+ // ViewGifImage will take care of GIF rights consumption stub.
+ // MediaPlayer will handle the video rights consumption stub.
+ String mime = mCurrentPhoto.getMimeType();
+ if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
+ && !mime.startsWith("video/")) {
+ DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
+ mHandler, mCurrentPhoto.getFilePath(),
+ mCurrentPhoto.getMimeType());
+ }
}
}
@@ -1255,32 +1174,10 @@ public abstract class PhotoPage extends ActivityState implements
mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
return true;
case R.id.action_drm_info:
- Uri uri = manager.getContentUri(path);
- Log.d(TAG, "executeuri:" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getAndroidContext().getContentResolver().query(uri,
- 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: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
+ String filepath = current.getFilePath();
+ if (DrmHelper.isDrmFile(filepath)) {
+ DrmHelper.showDrmInfo(mActivity.getAndroidContext(), filepath);
}
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- Intent drmintent = new Intent("android.drmservice.intent.action.SHOW_PROPERTIES");
- drmintent.putExtra("DRM_FILE_PATH", filepath);
- drmintent.putExtra("DRM_TYPE", "OMAV1");
- Log.d(TAG,"-----filepath===" + path);
- mActivity.getAndroidContext().sendBroadcast(drmintent);
return true;
default :
return false;
@@ -1417,37 +1314,6 @@ public abstract class PhotoPage extends ActivityState implements
public void playVideo(Activity activity, Uri uri, String title) {
try {
- String scheme = uri.getScheme();
- Log.d(TAG, "playVideo:uri= " + uri);
- String path = null;
- if (scheme.equals("content")) {
- Cursor c = activity.getContentResolver().query(uri,
- new String[] { MediaStore.Images.ImageColumns.DATA }, null, null, null);
- if (c != null && c.getCount() > 0) {
- c.moveToFirst();
- path = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.DATA));
- Log.d(TAG, "playVideo:path= " + path);
- }
- if (c != null) c.close();
- } else {
- path = uri.getPath();
- }
- if (path.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(activity);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int status = drmClient.checkRightsStatus(path, Action.PLAY);
- if (RightsStatus.RIGHTS_VALID != status) {
- ContentValues values = drmClient.getMetadata(path);
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "playVideo, address= " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- activity.sendBroadcast(intent);
- return;
- }
- if (drmClient != null) drmClient.release();
- }
-
Intent intent = new Intent(Intent.ACTION_VIEW)
.setDataAndType(uri, "video/*")
.putExtra(Intent.EXTRA_TITLE, title)
@@ -1552,17 +1418,6 @@ public abstract class PhotoPage extends ActivityState implements
@Override
public void onCurrentImageUpdated() {
- if (mSetPathString == null) {
- MediaItem item = mModel.getMediaItem(0);
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE
- && item.getConsumeRights() == true) {
- Log.d(TAG, "onCurrentImageUpdated,consume rights = true");
- item.setConsumeRights(false);
- Uri uri = item.getContentUri();
- Log.d(TAG, "onCurrentImageUpdated:uri=" + uri);
- consumeRights(uri);
- }
- }
mActivity.getGLRoot().unfreeze();
}
@@ -1590,6 +1445,23 @@ public abstract class PhotoPage extends ActivityState implements
UsageStatistics.onContentViewChanged(
UsageStatistics.COMPONENT_CAMERA, "Unknown"); // TODO
}
+
+ // Manage DRM rights while image selection changed. this
+ // flow will comes for both image and video, but here
+ // we will consume rights for image files only.
+ // Do not consume rights of a GIF image and video here.
+ // ViewGifImage will take care of GIF rights consumption stub.
+ // MediaPlayer will handle the video rights consumption stub.
+ if ((mMediaSet != null && mMediaSet.getMediaItemCount() > 1)
+ || !(this instanceof SinglePhotoPage)) {
+ String mime = mCurrentPhoto.getMimeType();
+ if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
+ && !mime.startsWith("video/")) {
+ DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
+ mHandler, mCurrentPhoto.getFilePath(),
+ mCurrentPhoto.getMimeType());
+ }
+ }
}
}
@@ -1784,6 +1656,9 @@ public abstract class PhotoPage extends ActivityState implements
private static void viewAnimateGif(Activity activity, Uri uri) {
Intent intent = new Intent(ViewGifImage.VIEW_GIF_ACTION, uri);
+ if (DrmHelper.isDrmFile(uri.toString())) {
+ intent.setDataAndType(uri, "image/gif");
+ }
activity.startActivity(intent);
}
}
diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java
index 174058dc8..2b15ab96e 100644
--- a/src/com/android/gallery3d/app/SlideshowPage.java
+++ b/src/com/android/gallery3d/app/SlideshowPage.java
@@ -16,8 +16,12 @@
package com.android.gallery3d.app;
+import java.util.ArrayList;
+import java.util.Random;
+
import android.app.Activity;
import android.content.Intent;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
@@ -38,9 +42,6 @@ import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
-import java.util.ArrayList;
-import java.util.Random;
-
public class SlideshowPage extends ActivityState {
private static final String TAG = "SlideshowPage";
@@ -338,6 +339,15 @@ public class SlideshowPage extends ActivityState {
mData = mMediaSet.getMediaItem(index, DATA_SIZE);
mDataStart = index;
dataEnd = index + mData.size();
+
+ // Consume license once in each element of the slide-show
+ // This is a non-blocking loop operation
+ for (int i = 0; i < mData.size(); i++) {
+ String path = mData.get(i).getFilePath();
+ if (DrmHelper.isDrmFile(path)) {
+ DrmHelper.consumeDrmRights(path, "image/*");
+ }
+ }
}
return (index < mDataStart || index >= dataEnd) ? null : mData.get(index - mDataStart);
diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java
index f9bbc1301..5c19d9016 100644
--- a/src/com/android/gallery3d/app/Wallpaper.java
+++ b/src/com/android/gallery3d/app/Wallpaper.java
@@ -97,7 +97,6 @@ public class Wallpaper extends Activity {
Intent request = new Intent(Intent.ACTION_GET_CONTENT)
.setClass(this, DialogPicker.class)
.setType(IMAGE_TYPE);
- request.putExtra("com.android.gallery3d.IsWallpaper", true);
startActivityForResult(request, STATE_PHOTO_PICKED);
return;
}
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/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..c4524854d 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,37 @@ 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())) {
+ 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_SHARE | SUPPORT_CROP | SUPPORT_PRINT | SUPPORT_SETAS;
- if (BitmapUtils.isRotationSupported(mimeType)) {
- operation |= SUPPORT_ROTATE;
- }
+ if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
+ operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
+ }
+
+ 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 +340,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 +378,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..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<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,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;
}
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..0cc1140c6 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;
- if (isSharable()) supported |= SUPPORT_SHARE;
- }
-
- if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_FULL_IMAGE;
+ if (isSharable())
+ supported |= SUPPORT_SHARE | SUPPORT_PRINT | SUPPORT_SETAS;
+ 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)
diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
index 21b283eed..94c859333 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
@@ -115,12 +115,6 @@ public class CropActivity extends Activity {
@Override
public void onClick(View view) {
startFinishOutput();
- if (mCropExtras != null && mCropExtras.getSetAsWallpaper()) {
- Intent intent = new Intent("android.drmservice.intent.action.SET_WALLPAPER");
- intent.putExtra("DRM_TYPE", "OMAV1");
- intent.putExtra("DRM_FILE_PATH", mSourceUri.toString());
- CropActivity.this.sendBroadcast(intent);
- }
}
});
}
diff --git a/src/com/android/gallery3d/glrenderer/NinePatchTexture.java b/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
index 2353f8b9b..d0ddc46c3 100644
--- a/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
+++ b/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
@@ -50,7 +50,7 @@ public class NinePatchTexture extends ResourceTexture {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options, false);
+ mContext.getResources(), mResId, options);
mBitmap = bitmap;
setSize(bitmap.getWidth(), bitmap.getHeight());
byte[] chunkData = bitmap.getNinePatchChunk();
diff --git a/src/com/android/gallery3d/glrenderer/ResourceTexture.java b/src/com/android/gallery3d/glrenderer/ResourceTexture.java
index d60a16c5a..eb8e8a517 100644
--- a/src/com/android/gallery3d/glrenderer/ResourceTexture.java
+++ b/src/com/android/gallery3d/glrenderer/ResourceTexture.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.glrenderer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.util.Log;
import junit.framework.Assert;
@@ -27,7 +26,6 @@ import junit.framework.Assert;
// By default ResourceTexture is not opaque.
public class ResourceTexture extends UploadedTexture {
- private static final String TAG = "ResourceTexture";
protected final Context mContext;
protected final int mResId;
@@ -42,15 +40,8 @@ public class ResourceTexture extends UploadedTexture {
protected Bitmap onGetBitmap() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap bitmap = null;
- try {
- bitmap = BitmapFactory.decodeResource(mContext.getResources(), mResId, options, false);
- } catch (OutOfMemoryError ex) {
- Log.e(TAG, "BitmapFactory decode resource out of memory");
- ex.printStackTrace();
- return null;
- }
- return bitmap;
+ return BitmapFactory.decodeResource(
+ mContext.getResources(), mResId, options);
}
@Override
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 641115138..8149df4b3 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -24,7 +24,6 @@ import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumSetDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataSourceType;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
@@ -81,7 +80,6 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
public Path setPath;
public String title;
public int totalCount;
- public int mediaType;
public int sourceType;
public int cacheFlag;
public int cacheStatus;
@@ -277,18 +275,6 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (getDataVersion(cover) != entry.coverDataVersion) {
entry.coverDataVersion = getDataVersion(cover);
entry.rotation = (cover == null) ? 0 : cover.getRotation();
-
- if (cover instanceof LocalMediaItem) {
- String filePath = ((LocalMediaItem) cover).filePath;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
- } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
- }
- }
- }
-
if (entry.coverLoader != null) {
entry.coverLoader.recycle();
entry.coverLoader = null;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index 37f9b4339..46daf1451 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -183,10 +183,6 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
((FadeInTexture) content).isAnimating()) {
renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
}
- if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
- || (entry.mediaType == MediaObject.MEDIA_TYPE_DRM_IMAGE)) {
- drawDrmOverlay(canvas, width, height, entry.mediaType);
- }
return renderRequestFlags;
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index a534c6add..fec7d1e92 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -24,7 +24,6 @@ import com.android.gallery3d.app.AlbumDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.glrenderer.Texture;
@@ -268,18 +267,6 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
entry.mediaType = (item == null)
? MediaItem.MEDIA_TYPE_UNKNOWN
: entry.item.getMediaType();
-
- if (item instanceof LocalMediaItem) {
- String filePath = ((LocalMediaItem)item).filePath;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
- } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
- }
- }
- }
-
entry.path = (item == null) ? null : item.getPath();
entry.rotation = (item == null) ? 0 : item.getRotation();
entry.contentLoader = new ThumbnailLoader(slotIndex, entry.item);
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 00a1459b0..9b2c3259c 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -24,11 +24,10 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
-import android.database.Cursor;
+import android.drm.DrmHelper;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
-import android.provider.MediaStore.Video.VideoColumns;
import android.support.v4.print.PrintHelper;
import android.view.Menu;
import android.view.MenuItem;
@@ -258,6 +257,14 @@ public class MenuExecutor {
Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_ATTACH_DATA)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra("mimeType", intent.getType());
+
+ // DRM files can be set as wallpaper only. Don't show other options
+ // to set as.
+ Uri uri = intent.getData();
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(mActivity, uri))) {
+ intent.setPackage("com.android.gallery3d");
+ }
+
Activity activity = mActivity;
activity.startActivity(Intent.createChooser(
intent, activity.getString(R.string.set_as)));
@@ -279,30 +286,14 @@ public class MenuExecutor {
DataManager manager = mActivity.getDataManager();
Path path = getSingleSelectedPath();
Uri uri = manager.getContentUri(path);
- Log.d(TAG, "onMenuClicked:" + uri);
String filepath = null;
String scheme = uri.getScheme();
if ("file".equals(scheme)) {
filepath = uri.getPath();
} else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getAndroidContext().getContentResolver().query(uri,
- 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: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
+ filepath = DrmHelper.getFilePath(mActivity, uri);
}
- Intent drmintent = new Intent("android.drmservice.intent.action.SHOW_PROPERTIES");
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- drmintent.putExtra("DRM_FILE_PATH", filepath);
- drmintent.putExtra("DRM_TYPE", "OMAV1");
- mActivity.getAndroidContext().sendBroadcast(drmintent);
+ DrmHelper.showDrmInfo(mActivity, filepath);
title = R.string.drm_license_info;
break;
default:
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index c55f84a21..1fff4ea3e 100755
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.ui;
import android.content.Context;
import android.content.res.Configuration;
+import android.drm.DrmHelper;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -204,6 +205,7 @@ public class PhotoView extends GLView {
private EdgeView mEdgeView;
private UndoBarView mUndoBar;
private Texture mVideoPlayIcon;
+ private Texture mDrmIcon;
private SynchronizedHandler mHandler;
@@ -307,6 +309,7 @@ public class PhotoView extends GLView {
}
});
mVideoPlayIcon = new ResourceTexture(mContext, R.drawable.ic_control_play);
+ mDrmIcon = new ResourceTexture(mContext, R.drawable.drm_image);
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; i++) {
if (i == 0) {
mPictures.put(i, new FullPicture());
@@ -741,6 +744,15 @@ public class PhotoView extends GLView {
drawLoadingFailMessage(canvas);
}
+ if (getFilmMode()) {
+ MediaItem item = mModel.getMediaItem(0);
+ if (item != null) {
+ if (DrmHelper.isDrmFile(item.getFilePath())) {
+ drawDrmIcon(canvas, s);
+ }
+ }
+ }
+
// Draw a debug indicator showing which picture has focus (index ==
// 0).
//canvas.fillRect(-10, -10, 20, 20, 0x80FF00FF);
@@ -858,9 +870,18 @@ public class PhotoView extends GLView {
if (mModel.isVideo(mIndex) || mModel.isGif(mIndex)) {
drawVideoPlayIcon(canvas, s);
}
+
if (mLoadingState == Model.LOADING_FAIL ) {
drawLoadingFailMessage(canvas);
}
+
+ MediaItem item = mModel.getMediaItem(mIndex);
+ if (item != null) {
+ if (DrmHelper.isDrmFile(item.getFilePath())) {
+ drawDrmIcon(canvas, s);
+ }
+ }
+
canvas.restore();
}
@@ -927,6 +948,13 @@ public class PhotoView extends GLView {
mVideoPlayIcon.draw(canvas, -s / 2, -s / 2, s, s);
}
+ // Draw the Drm lock icon (in the place where the spinner was)
+ private void drawDrmIcon(GLCanvas canvas, int side) {
+ int s = side / ICON_RATIO;
+ // Draw the Drm lock icon at the center
+ mDrmIcon.draw(canvas, -s / 2, -s / 2, s, s);
+ }
+
// Draw the "no thumbnail" message
private void drawLoadingFailMessage(GLCanvas canvas) {
StringTexture m = mNoThumbnailText;