Merge "Let getOriginalMimeType() take a fd passed from drm java applications" into jb-mr1-dev
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user