AArch64: Use long for pointers in MTP classes
For storing pointers, long is used in MTP 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: I67805547251722e7b77611d47d0bb632a64d3e6d
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp
index 5252a3a..9d7f1c2 100644
--- a/media/jni/android_mtp_MtpServer.cpp
+++ b/media/jni/android_mtp_MtpServer.cpp
@@ -53,7 +53,7 @@
extern MtpDatabase* getMtpDatabase(JNIEnv *env, jobject database);
static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) {
- return (MtpServer*)env->GetIntField(thiz, field_MtpServer_nativeContext);
+ return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext);
}
static void
@@ -63,7 +63,7 @@
if (fd >= 0) {
MtpServer* server = new MtpServer(fd, getMtpDatabase(env, javaDatabase),
usePtp, AID_MEDIA_RW, 0664, 0775);
- env->SetIntField(thiz, field_MtpServer_nativeContext, (int)server);
+ env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server);
} else {
ALOGE("could not open MTP driver, errno: %d", errno);
}
@@ -87,7 +87,7 @@
MtpServer* server = getMtpServer(env, thiz);
if (server) {
delete server;
- env->SetIntField(thiz, field_MtpServer_nativeContext, 0);
+ env->SetLongField(thiz, field_MtpServer_nativeContext, 0);
} else {
ALOGE("server is null in cleanup");
}
@@ -226,7 +226,7 @@
ALOGE("Can't find android/mtp/MtpServer");
return -1;
}
- field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "I");
+ field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "J");
if (field_MtpServer_nativeContext == NULL) {
ALOGE("Can't find MtpServer.mNativeContext");
return -1;