diff options
author | James Dong <jdong@google.com> | 2012-03-02 18:36:53 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-03-05 18:52:32 -0800 |
commit | 9864b25bd8ac2c68f290817ac5fe73077e130b45 (patch) | |
tree | efb27679e7cf3dd865317f808ec440b15f5581df /drm | |
parent | c730aceb64233592c5a0d8b6a429d645443b3818 (diff) | |
download | frameworks_base-9864b25bd8ac2c68f290817ac5fe73077e130b45.zip frameworks_base-9864b25bd8ac2c68f290817ac5fe73077e130b45.tar.gz frameworks_base-9864b25bd8ac2c68f290817ac5fe73077e130b45.tar.bz2 |
There was copy and paste code in JNI to create a DrmConvertedStatus object.
o This patch removed duplicated code.
Change-Id: Ic3d3461fb8da6fab1b4d19d28b8d9d4abc8a53b1
Diffstat (limited to 'drm')
-rw-r--r-- | drm/jni/android_drm_DrmManagerClient.cpp | 65 |
1 files changed, 25 insertions, 40 deletions
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index 191648c..14ec4d6 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -620,17 +620,8 @@ static jint android_drm_DrmManagerClient_openConvertSession( return convertId; } -static jobject android_drm_DrmManagerClient_convertData( - JNIEnv* env, jobject thiz, jint uniqueId, jint convertId, jbyteArray inputData) { - ALOGV("convertData Enter"); - - int dataLength = 0; - char* mData = Utility::getByteArrayValue(env, inputData, &dataLength); - const DrmBuffer buffer(mData, dataLength); - - DrmConvertedStatus* pDrmConvertedStatus - = getDrmManagerClientImpl(env, thiz)->convertData(uniqueId, convertId, &buffer); - +static jobject GetConvertedStatus(JNIEnv* env, DrmConvertedStatus* pDrmConvertedStatus) { + ALOGV("GetConvertedStatus - Enter"); jclass localRef = env->FindClass("android/drm/DrmConvertedStatus"); jobject drmConvertedStatus = NULL; @@ -642,8 +633,8 @@ static jobject android_drm_DrmManagerClient_convertData( if (NULL != pDrmConvertedStatus->convertedData) { int length = pDrmConvertedStatus->convertedData->length; dataArray = env->NewByteArray(length); - env->SetByteArrayRegion(dataArray, 0, length, - (jbyte*) pDrmConvertedStatus->convertedData->data); + env->SetByteArrayRegion( + dataArray, 0, length, (jbyte*) pDrmConvertedStatus->convertedData->data); delete [] pDrmConvertedStatus->convertedData->data; delete pDrmConvertedStatus->convertedData; pDrmConvertedStatus->convertedData = NULL; @@ -654,48 +645,42 @@ static jobject android_drm_DrmManagerClient_convertData( statusCode, dataArray, pDrmConvertedStatus->offset); } - delete[] mData; mData = NULL; delete pDrmConvertedStatus; pDrmConvertedStatus = NULL; - ALOGV("convertData - Exit"); + ALOGV("GetConvertedStatus - Exit"); return drmConvertedStatus; } -static jobject android_drm_DrmManagerClient_closeConvertSession( - JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { +static jobject android_drm_DrmManagerClient_convertData( + JNIEnv* env, jobject thiz, jint uniqueId, jint convertId, jbyteArray inputData) { + ALOGV("convertData Enter"); - ALOGV("closeConvertSession Enter"); + int dataLength = 0; + char* mData = Utility::getByteArrayValue(env, inputData, &dataLength); + const DrmBuffer buffer(mData, dataLength); DrmConvertedStatus* pDrmConvertedStatus - = getDrmManagerClientImpl(env, thiz)->closeConvertSession(uniqueId, convertId); - - jclass localRef = env->FindClass("android/drm/DrmConvertedStatus"); + = getDrmManagerClientImpl(env, thiz)->convertData(uniqueId, convertId, &buffer); + jobject status = GetConvertedStatus(env, pDrmConvertedStatus); - jobject drmConvertedStatus = NULL; + delete[] mData; + mData = NULL; - if (NULL != localRef && NULL != pDrmConvertedStatus) { - int statusCode = pDrmConvertedStatus->statusCode; + ALOGV("convertData - Exit"); + return status; +} - jbyteArray dataArray = NULL; - if (NULL != pDrmConvertedStatus->convertedData) { - int length = pDrmConvertedStatus->convertedData->length; - dataArray = env->NewByteArray(length); - env->SetByteArrayRegion( - dataArray, 0, length, (jbyte*) pDrmConvertedStatus->convertedData->data); +static jobject android_drm_DrmManagerClient_closeConvertSession( + JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { - delete [] pDrmConvertedStatus->convertedData->data; - delete pDrmConvertedStatus->convertedData; pDrmConvertedStatus->convertedData = NULL; - } - jmethodID constructorId = env->GetMethodID(localRef, "<init>", "(I[BI)V"); - drmConvertedStatus - = env->NewObject(localRef, constructorId, - statusCode, dataArray, pDrmConvertedStatus->offset); - } + ALOGV("closeConvertSession Enter"); - delete pDrmConvertedStatus; pDrmConvertedStatus = NULL; + DrmConvertedStatus* pDrmConvertedStatus + = getDrmManagerClientImpl(env, thiz)->closeConvertSession(uniqueId, convertId); + jobject status = GetConvertedStatus(env, pDrmConvertedStatus); ALOGV("closeConvertSession - Exit"); - return drmConvertedStatus; + return status; } static JNINativeMethod nativeMethods[] = { |