summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-08-22 14:50:27 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-22 14:50:27 -0700
commitd78fc5b94d1bb3dab509ca55d09052821c51412b (patch)
tree8899b553fbd42c74fef5a0f51a08b70ec1017294 /drm
parentb9b56954ec5a242f7c4945942539106539f98ffb (diff)
parent0889fdae87abd9ec78a6c1d00c2771acfa4e4d34 (diff)
downloadframeworks_base-d78fc5b94d1bb3dab509ca55d09052821c51412b.zip
frameworks_base-d78fc5b94d1bb3dab509ca55d09052821c51412b.tar.gz
frameworks_base-d78fc5b94d1bb3dab509ca55d09052821c51412b.tar.bz2
Merge "Let getOriginalMimeType() take a fd passed from drm java applications" into jb-mr1-dev
Diffstat (limited to 'drm')
-rwxr-xr-xdrm/java/android/drm/DrmManagerClient.java28
-rw-r--r--drm/jni/android_drm_DrmManagerClient.cpp16
2 files changed, 37 insertions, 7 deletions
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index 4b51994..2907f10 100755
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -29,6 +29,9 @@ import android.os.Message;
import android.provider.MediaStore;
import android.util.Log;
+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;
@@ -582,7 +585,28 @@ public class DrmManagerClient {
if (null == path || path.equals("")) {
throw new IllegalArgumentException("Given path should be non null");
}
- return _getOriginalMimeType(mUniqueId, path);
+
+ String mime = null;
+
+ FileInputStream is = null;
+ try {
+ FileDescriptor fd = null;
+ File file = new File(path);
+ if (file.exists()) {
+ is = new FileInputStream(file);
+ fd = is.getFD();
+ }
+ mime = _getOriginalMimeType(mUniqueId, path, fd);
+ } catch (IOException ioe) {
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch(IOException e) {}
+ }
+ }
+
+ return mime;
}
/**
@@ -848,7 +872,7 @@ public class DrmManagerClient {
private native int _getDrmObjectType(int uniqueId, String path, String mimeType);
- private native String _getOriginalMimeType(int uniqueId, String path);
+ private native String _getOriginalMimeType(int uniqueId, String path, FileDescriptor fd);
private native int _checkRightsStatus(int uniqueId, String path, int action);
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp
index fb685a2..baddf62 100644
--- a/drm/jni/android_drm_DrmManagerClient.cpp
+++ b/drm/jni/android_drm_DrmManagerClient.cpp
@@ -587,22 +587,28 @@ static jint android_drm_DrmManagerClient_getDrmObjectType(
}
static jstring android_drm_DrmManagerClient_getOriginalMimeType(
- JNIEnv* env, jobject thiz, jint uniqueId, jstring path) {
+ JNIEnv* env, jobject thiz, jint uniqueId, jstring path, jobject fileDescriptor) {
ALOGV("getOriginalMimeType Enter");
+
+ int fd = (fileDescriptor == NULL)
+ ? -1
+ : jniGetFDFromFileDescriptor(env, fileDescriptor);
+
String8 mimeType
= getDrmManagerClientImpl(env, thiz)
- ->getOriginalMimeType(uniqueId, Utility::getStringValue(env, path));
+ ->getOriginalMimeType(uniqueId,
+ Utility::getStringValue(env, path), fd);
ALOGV("getOriginalMimeType Exit");
return env->NewStringUTF(mimeType.string());
}
static jint android_drm_DrmManagerClient_checkRightsStatus(
JNIEnv* env, jobject thiz, jint uniqueId, jstring path, int action) {
- ALOGV("getOriginalMimeType Enter");
+ ALOGV("checkRightsStatus Enter");
int rightsStatus
= getDrmManagerClientImpl(env, thiz)
->checkRightsStatus(uniqueId, Utility::getStringValue(env, path), action);
- ALOGV("getOriginalMimeType Exit");
+ ALOGV("checkRightsStatus Exit");
return rightsStatus;
}
@@ -730,7 +736,7 @@ static JNINativeMethod nativeMethods[] = {
{"_getDrmObjectType", "(ILjava/lang/String;Ljava/lang/String;)I",
(void*)android_drm_DrmManagerClient_getDrmObjectType},
- {"_getOriginalMimeType", "(ILjava/lang/String;)Ljava/lang/String;",
+ {"_getOriginalMimeType", "(ILjava/lang/String;Ljava/io/FileDescriptor;)Ljava/lang/String;",
(void*)android_drm_DrmManagerClient_getOriginalMimeType},
{"_checkRightsStatus", "(ILjava/lang/String;I)I",