From 33d603877acf76d5d59484532025af20f4b068a5 Mon Sep 17 00:00:00 2001 From: Ashok Bhat Date: Fri, 17 Jan 2014 12:05:52 +0000 Subject: AArch64: Use long for pointers in DRM classes For storing pointers, long is used in DRM classes, as native pointers can be 64-bit. In addition, some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes) Change-Id: I101b0ea19ed93651c6ad1a9fa55e14e8be117469 Signed-off-by: Ashok Bhat Signed-off-by: Marcus Oakland --- drm/jni/android_drm_DrmManagerClient.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'drm/jni') diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index baddf62..de8531b 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -182,25 +182,27 @@ static sp setDrmManagerClientImpl( JNIEnv* env, jobject thiz, const sp& client) { Mutex::Autolock l(sLock); jclass clazz = env->FindClass("android/drm/DrmManagerClient"); - jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I"); + jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J"); - sp old = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId); + jlong oldHandle = env->GetLongField(thiz, fieldId); + sp old = reinterpret_cast(oldHandle); if (client.get()) { client->incStrong(thiz); } if (old != 0) { old->decStrong(thiz); } - env->SetIntField(thiz, fieldId, (int)client.get()); + env->SetLongField(thiz, fieldId, reinterpret_cast(client.get())); return old; } static sp getDrmManagerClientImpl(JNIEnv* env, jobject thiz) { Mutex::Autolock l(sLock); jclass clazz = env->FindClass("android/drm/DrmManagerClient"); - jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "I"); + jfieldID fieldId = env->GetFieldID(clazz, "mNativeContext", "J"); - DrmManagerClientImpl* const client = (DrmManagerClientImpl*)env->GetIntField(thiz, fieldId); + jlong clientHandle = env->GetLongField(thiz, fieldId); + DrmManagerClientImpl* const client = reinterpret_cast(clientHandle); return sp(client); } @@ -214,7 +216,7 @@ static jint android_drm_DrmManagerClient_initialize( setDrmManagerClientImpl(env, thiz, drmManager); ALOGV("initialize - Exit"); - return uniqueId; + return static_cast(uniqueId); } static void android_drm_DrmManagerClient_setListeners( @@ -406,7 +408,7 @@ static jint android_drm_DrmManagerClient_saveRights( delete[] mData; mData = NULL; ALOGV("saveRights - Exit"); - return result; + return static_cast(result); } static jboolean android_drm_DrmManagerClient_canHandle( @@ -583,7 +585,7 @@ static jint android_drm_DrmManagerClient_getDrmObjectType( ->getDrmObjectType(uniqueId, Utility::getStringValue(env, path), Utility::getStringValue(env, mimeType)); ALOGV("getDrmObjectType Exit"); - return drmObjectType; + return static_cast(drmObjectType); } static jstring android_drm_DrmManagerClient_getOriginalMimeType( @@ -609,20 +611,21 @@ static jint android_drm_DrmManagerClient_checkRightsStatus( = getDrmManagerClientImpl(env, thiz) ->checkRightsStatus(uniqueId, Utility::getStringValue(env, path), action); ALOGV("checkRightsStatus Exit"); - return rightsStatus; + return static_cast(rightsStatus); } static jint android_drm_DrmManagerClient_removeRights( JNIEnv* env, jobject thiz, jint uniqueId, jstring path) { ALOGV("removeRights"); - return getDrmManagerClientImpl(env, thiz) - ->removeRights(uniqueId, Utility::getStringValue(env, path)); + return static_cast(getDrmManagerClientImpl(env, thiz) + ->removeRights(uniqueId, Utility::getStringValue(env, path))); } static jint android_drm_DrmManagerClient_removeAllRights( JNIEnv* env, jobject thiz, jint uniqueId) { ALOGV("removeAllRights"); - return getDrmManagerClientImpl(env, thiz)->removeAllRights(uniqueId); + return static_cast(getDrmManagerClientImpl(env, thiz) + ->removeAllRights(uniqueId)); } static jint android_drm_DrmManagerClient_openConvertSession( @@ -632,7 +635,7 @@ static jint android_drm_DrmManagerClient_openConvertSession( = getDrmManagerClientImpl(env, thiz) ->openConvertSession(uniqueId, Utility::getStringValue(env, mimeType)); ALOGV("openConvertSession Exit"); - return convertId; + return static_cast(convertId); } static jobject GetConvertedStatus(JNIEnv* env, DrmConvertedStatus* pDrmConvertedStatus) { @@ -686,7 +689,7 @@ static jobject android_drm_DrmManagerClient_convertData( } static jobject android_drm_DrmManagerClient_closeConvertSession( - JNIEnv* env, jobject thiz, int uniqueId, jint convertId) { + JNIEnv* env, jobject thiz, jint uniqueId, jint convertId) { ALOGV("closeConvertSession Enter"); -- cgit v1.1