AArch64: Use long for pointers in media classes

For storing pointers, long is used in media 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: Idc4ca0124d03df7f9cef412488abafd020e5e774
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/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 1c43cc5..b22668b 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -136,7 +136,7 @@
 {
     Mutex::Autolock l(sLock);
     AudioRecord* const ar =
-            (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
+            (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
     return sp<AudioRecord>(ar);
 }
 
@@ -144,19 +144,19 @@
 {
     Mutex::Autolock l(sLock);
     sp<AudioRecord> old =
-            (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
+            (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
     if (ar.get()) {
         ar->incStrong((void*)setAudioRecord);
     }
     if (old != 0) {
         old->decStrong((void*)setAudioRecord);
     }
-    env->SetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (int)ar.get());
+    env->SetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (jlong)ar.get());
     return old;
 }
 
 // ----------------------------------------------------------------------------
-static int
+static jint
 android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
         jint source, jint sampleRateInHertz, jint channelMask,
                 // Java channel masks map directly to the native definition
@@ -168,7 +168,7 @@
 
     if (!audio_is_input_channel(channelMask)) {
         ALOGE("Error creating AudioRecord: channel mask %#x is not valid.", channelMask);
-        return AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
+        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
     }
     uint32_t nbChannels = popcount(channelMask);
 
@@ -176,7 +176,7 @@
     if ((audioFormat != ENCODING_PCM_16BIT)
         && (audioFormat != ENCODING_PCM_8BIT)) {
         ALOGE("Error creating AudioRecord: unsupported audio format.");
-        return AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
+        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
     }
 
     int bytesPerSample = audioFormat == ENCODING_PCM_16BIT ? 2 : 1;
@@ -185,31 +185,31 @@
 
     if (buffSizeInBytes == 0) {
          ALOGE("Error creating AudioRecord: frameCount is 0.");
-        return AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
+        return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
     }
     int frameSize = nbChannels * bytesPerSample;
     size_t frameCount = buffSizeInBytes / frameSize;
 
     if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) {
         ALOGE("Error creating AudioRecord: unknown source.");
-        return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
+        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
     }
 
     jclass clazz = env->GetObjectClass(thiz);
     if (clazz == NULL) {
         ALOGE("Can't find %s when setting up callback.", kClassPathName);
-        return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
+        return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
     }
 
     if (jSession == NULL) {
         ALOGE("Error creating AudioRecord: invalid session ID pointer");
-        return AUDIORECORD_ERROR;
+        return (jint) AUDIORECORD_ERROR;
     }
 
     jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
     if (nSession == NULL) {
         ALOGE("Error creating AudioRecord: Error retrieving session id pointer");
-        return AUDIORECORD_ERROR;
+        return (jint) AUDIORECORD_ERROR;
     }
     int sessionId = nSession[0];
     env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -262,33 +262,33 @@
 
     // save our newly created callback information in the "nativeCallbackCookie" field
     // of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize()
-    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, (int)lpCallbackData);
+    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, (jlong)lpCallbackData);
 
-    return AUDIORECORD_SUCCESS;
+    return (jint) AUDIORECORD_SUCCESS;
 
     // failure:
 native_init_failure:
     env->DeleteGlobalRef(lpCallbackData->audioRecord_class);
     env->DeleteGlobalRef(lpCallbackData->audioRecord_ref);
     delete lpCallbackData;
-    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
+    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
 
-    return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
+    return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
 }
 
 
 
 // ----------------------------------------------------------------------------
-static int
+static jint
 android_media_AudioRecord_start(JNIEnv *env, jobject thiz, jint event, jint triggerSession)
 {
     sp<AudioRecord> lpRecorder = getAudioRecord(env, thiz);
     if (lpRecorder == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return AUDIORECORD_ERROR;
+        return (jint) AUDIORECORD_ERROR;
     }
 
-    return android_media_translateRecorderErrorCode(
+    return (jint) android_media_translateRecorderErrorCode(
             lpRecorder->start((AudioSystem::sync_event_t)event, triggerSession));
 }
 
@@ -319,12 +319,12 @@
     ALOGV("About to delete lpRecorder: %x\n", (int)lpRecorder.get());
     lpRecorder->stop();
 
-    audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetIntField(
+    audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetLongField(
         thiz, javaAudioRecordFields.nativeCallbackCookie);
 
     // reset the native resources in the Java object so any attempt to access
     // them after a call to release fails.
-    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
+    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
 
     // delete the callback information
     if (lpCookie) {
@@ -585,7 +585,7 @@
     //    mNativeRecorderInJavaObj
     javaAudioRecordFields.nativeRecorderInJavaObj =
         env->GetFieldID(audioRecordClass,
-                        JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "I");
+                        JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J");
     if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL) {
         ALOGE("Can't find AudioRecord.%s", JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME);
         return -1;
@@ -593,7 +593,7 @@
     //     mNativeCallbackCookie
     javaAudioRecordFields.nativeCallbackCookie = env->GetFieldID(
             audioRecordClass,
-            JAVA_NATIVECALLBACKINFO_FIELD_NAME, "I");
+            JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J");
     if (javaAudioRecordFields.nativeCallbackCookie == NULL) {
         ALOGE("Can't find AudioRecord.%s", JAVA_NATIVECALLBACKINFO_FIELD_NAME);
         return -1;
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 7d99464..a19d111 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -52,10 +52,10 @@
     return kAudioStatusError;
 }
 
-static int
+static jint
 android_media_AudioSystem_muteMicrophone(JNIEnv *env, jobject thiz, jboolean on)
 {
-    return check_AudioSystem_Command(AudioSystem::muteMicrophone(on));
+    return (jint) check_AudioSystem_Command(AudioSystem::muteMicrophone(on));
 }
 
 static jboolean
@@ -91,7 +91,7 @@
     return state;
 }
 
-static int
+static jint
 android_media_AudioSystem_setParameters(JNIEnv *env, jobject thiz, jstring keyValuePairs)
 {
     const jchar* c_keyValuePairs = env->GetStringCritical(keyValuePairs, 0);
@@ -101,7 +101,7 @@
         env->ReleaseStringCritical(keyValuePairs, c_keyValuePairs);
     }
     int status = check_AudioSystem_Command(AudioSystem::setParameters(0, c_keyValuePairs8));
-    return status;
+    return (jint) status;
 }
 
 static jstring
@@ -131,7 +131,7 @@
                               check_AudioSystem_Command(err));
 }
 
-static int
+static jint
 android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address)
 {
     const char *c_address = env->GetStringUTFChars(device_address, NULL);
@@ -139,60 +139,60 @@
                                           static_cast <audio_policy_dev_state_t>(state),
                                           c_address));
     env->ReleaseStringUTFChars(device_address, c_address);
-    return status;
+    return (jint) status;
 }
 
-static int
+static jint
 android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jstring device_address)
 {
     const char *c_address = env->GetStringUTFChars(device_address, NULL);
     int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <audio_devices_t>(device),
                                           c_address));
     env->ReleaseStringUTFChars(device_address, c_address);
-    return state;
+    return (jint) state;
 }
 
-static int
+static jint
 android_media_AudioSystem_setPhoneState(JNIEnv *env, jobject thiz, jint state)
 {
-    return check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state));
+    return (jint) check_AudioSystem_Command(AudioSystem::setPhoneState((audio_mode_t) state));
 }
 
-static int
+static jint
 android_media_AudioSystem_setForceUse(JNIEnv *env, jobject thiz, jint usage, jint config)
 {
-    return check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage),
+    return (jint) check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage),
                                                            static_cast <audio_policy_forced_cfg_t>(config)));
 }
 
-static int
+static jint
 android_media_AudioSystem_getForceUse(JNIEnv *env, jobject thiz, jint usage)
 {
-    return static_cast <int>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage)));
+    return static_cast <jint>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage)));
 }
 
-static int
+static jint
 android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint stream, jint indexMin, jint indexMax)
 {
-    return check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream),
+    return (jint) check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream),
                                                                    indexMin,
                                                                    indexMax));
 }
 
-static int
+static jint
 android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env,
                                                jobject thiz,
                                                jint stream,
                                                jint index,
                                                jint device)
 {
-    return check_AudioSystem_Command(
+    return (jint) check_AudioSystem_Command(
             AudioSystem::setStreamVolumeIndex(static_cast <audio_stream_type_t>(stream),
                                               index,
                                               (audio_devices_t)device));
 }
 
-static int
+static jint
 android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env,
                                                jobject thiz,
                                                jint stream,
@@ -205,13 +205,13 @@
             != NO_ERROR) {
         index = -1;
     }
-    return index;
+    return (jint) index;
 }
 
-static int
+static jint
 android_media_AudioSystem_setMasterVolume(JNIEnv *env, jobject thiz, jfloat value)
 {
-    return check_AudioSystem_Command(AudioSystem::setMasterVolume(value));
+    return (jint) check_AudioSystem_Command(AudioSystem::setMasterVolume(value));
 }
 
 static jfloat
@@ -224,10 +224,10 @@
     return value;
 }
 
-static int
+static jint
 android_media_AudioSystem_setMasterMute(JNIEnv *env, jobject thiz, jboolean mute)
 {
-    return check_AudioSystem_Command(AudioSystem::setMasterMute(mute));
+    return (jint) check_AudioSystem_Command(AudioSystem::setMasterMute(mute));
 }
 
 static jfloat
@@ -275,10 +275,10 @@
     return (jint) AudioSystem::setLowRamDevice((bool) isLowRamDevice);
 }
 
-static int
+static jint
 android_media_AudioSystem_checkAudioFlinger(JNIEnv *env, jobject clazz)
 {
-    return check_AudioSystem_Command(AudioSystem::checkAudioFlinger());
+    return (jint) check_AudioSystem_Command(AudioSystem::checkAudioFlinger());
 }
 
 // ----------------------------------------------------------------------------
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 225bf06..dc8d9d8 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -174,7 +174,7 @@
 {
     Mutex::Autolock l(sLock);
     AudioTrack* const at =
-            (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
+            (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
     return sp<AudioTrack>(at);
 }
 
@@ -182,19 +182,19 @@
 {
     Mutex::Autolock l(sLock);
     sp<AudioTrack> old =
-            (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
+            (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
     if (at.get()) {
         at->incStrong((void*)setAudioTrack);
     }
     if (old != 0) {
         old->decStrong((void*)setAudioTrack);
     }
-    env->SetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (int)at.get());
+    env->SetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (jlong)at.get());
     return old;
 }
 
 // ----------------------------------------------------------------------------
-static int
+static jint
 android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_this,
         jint streamType, jint sampleRateInHertz, jint javaChannelMask,
         jint audioFormat, jint buffSizeInBytes, jint memoryMode, jintArray jSession)
@@ -206,11 +206,11 @@
 
     if (AudioSystem::getOutputFrameCount(&afFrameCount, (audio_stream_type_t) streamType) != NO_ERROR) {
         ALOGE("Error creating AudioTrack: Could not get AudioSystem frame count.");
-        return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
+        return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
     }
     if (AudioSystem::getOutputSamplingRate(&afSampleRate, (audio_stream_type_t) streamType) != NO_ERROR) {
         ALOGE("Error creating AudioTrack: Could not get AudioSystem sampling rate.");
-        return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
+        return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
     }
 
     // Java channel masks don't map directly to the native definition, but it's a simple shift
@@ -219,7 +219,7 @@
 
     if (!audio_is_output_channel(nativeChannelMask)) {
         ALOGE("Error creating AudioTrack: invalid channel mask %#x.", javaChannelMask);
-        return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
+        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
     }
 
     int nbChannels = popcount(nativeChannelMask);
@@ -239,7 +239,7 @@
         break;
     default:
         ALOGE("Error creating AudioTrack: unknown stream type.");
-        return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
+        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
     }
 
     // check the format.
@@ -247,7 +247,7 @@
     if ((audioFormat != ENCODING_PCM_16BIT) && (audioFormat != ENCODING_PCM_8BIT)) {
 
         ALOGE("Error creating AudioTrack: unsupported audio format.");
-        return AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
+        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
     }
 
     // for the moment 8bitPCM in MODE_STATIC is not supported natively in the AudioTrack C++ class
@@ -272,18 +272,18 @@
     jclass clazz = env->GetObjectClass(thiz);
     if (clazz == NULL) {
         ALOGE("Can't find %s when setting up callback.", kClassPathName);
-        return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
+        return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
     }
 
     if (jSession == NULL) {
         ALOGE("Error creating AudioTrack: invalid session ID pointer");
-        return AUDIOTRACK_ERROR;
+        return (jint) AUDIOTRACK_ERROR;
     }
 
     jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
     if (nSession == NULL) {
         ALOGE("Error creating AudioTrack: Error retrieving session id pointer");
-        return AUDIOTRACK_ERROR;
+        return (jint) AUDIOTRACK_ERROR;
     }
     int sessionId = nSession[0];
     env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -370,10 +370,10 @@
     setAudioTrack(env, thiz, lpTrack);
 
     // save the JNI resources so we can free them later
-    //ALOGV("storing lpJniStorage: %x\n", (int)lpJniStorage);
-    env->SetIntField(thiz, javaAudioTrackFields.jniData, (int)lpJniStorage);
+    //ALOGV("storing lpJniStorage: %x\n", (long)lpJniStorage);
+    env->SetLongField(thiz, javaAudioTrackFields.jniData, (jlong)lpJniStorage);
 
-    return AUDIOTRACK_SUCCESS;
+    return (jint) AUDIOTRACK_SUCCESS;
 
     // failures:
 native_init_failure:
@@ -383,9 +383,9 @@
     env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_class);
     env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_ref);
     delete lpJniStorage;
-    env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
+    env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);
 
-    return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
+    return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
 }
 
 
@@ -474,11 +474,11 @@
     lpTrack->stop();
 
     // delete the JNI data
-    AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetIntField(
+    AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetLongField(
         thiz, javaAudioTrackFields.jniData);
     // reset the native resources in the Java object so any attempt to access
     // them after a call to release fails.
-    env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
+    env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);
 
     if (pJniStorage) {
         Mutex::Autolock l(sLock);
@@ -955,7 +955,7 @@
     //      nativeTrackInJavaObj
     javaAudioTrackFields.nativeTrackInJavaObj = env->GetFieldID(
             audioTrackClass,
-            JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "I");
+            JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J");
     if (javaAudioTrackFields.nativeTrackInJavaObj == NULL) {
         ALOGE("Can't find AudioTrack.%s", JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME);
         return -1;
@@ -963,7 +963,7 @@
     //      jniData;
     javaAudioTrackFields.jniData = env->GetFieldID(
             audioTrackClass,
-            JAVA_JNIDATA_FIELD_NAME, "I");
+            JAVA_JNIDATA_FIELD_NAME, "J");
     if (javaAudioTrackFields.jniData == NULL) {
         ALOGE("Can't find AudioTrack.%s", JAVA_JNIDATA_FIELD_NAME);
         return -1;
diff --git a/core/jni/android_media_JetPlayer.cpp b/core/jni/android_media_JetPlayer.cpp
index 5795aba..69f5711 100644
--- a/core/jni/android_media_JetPlayer.cpp
+++ b/core/jni/android_media_JetPlayer.cpp
@@ -87,12 +87,12 @@
     if (result==EAS_SUCCESS) {
         // save our newly created C++ JetPlayer in the "nativePlayerInJavaObj" field
         // of the Java object (in mNativePlayerInJavaObj)
-        env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (int)lpJet);
+        env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, (jlong)lpJet);
         return JNI_TRUE;
     } else {
         ALOGE("android_media_JetPlayer_setup(): initialization failed with EAS error code %d", (int)result);
         delete lpJet;
-        env->SetIntField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0);
+        env->SetLongField(weak_this, javaJetPlayerFields.nativePlayerInJavaObj, 0);
         return JNI_FALSE;
     }
 }
@@ -103,7 +103,7 @@
 android_media_JetPlayer_finalize(JNIEnv *env, jobject thiz)
 {
     ALOGV("android_media_JetPlayer_finalize(): entering.");
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet != NULL) {
         lpJet->release();
@@ -119,7 +119,7 @@
 android_media_JetPlayer_release(JNIEnv *env, jobject thiz)
 {
     android_media_JetPlayer_finalize(env, thiz);
-    env->SetIntField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0);
+    env->SetLongField(thiz, javaJetPlayerFields.nativePlayerInJavaObj, 0);
     ALOGV("android_media_JetPlayer_release() done");
 }
 
@@ -128,7 +128,7 @@
 static jboolean
 android_media_JetPlayer_loadFromFile(JNIEnv *env, jobject thiz, jstring path)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -165,7 +165,7 @@
 android_media_JetPlayer_loadFromFileD(JNIEnv *env, jobject thiz,
     jobject fileDescriptor, jlong offset, jlong length)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -195,7 +195,7 @@
 static jboolean
 android_media_JetPlayer_closeFile(JNIEnv *env, jobject thiz)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -217,7 +217,7 @@
 static jboolean
 android_media_JetPlayer_play(JNIEnv *env, jobject thiz)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -241,7 +241,7 @@
 static jboolean
 android_media_JetPlayer_pause(JNIEnv *env, jobject thiz)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -271,7 +271,7 @@
         jint segmentNum, jint libNum, jint repeatCount, jint transpose, jint muteFlags,
         jbyte userID)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -298,7 +298,7 @@
         jint segmentNum, jint libNum, jint repeatCount, jint transpose, jbooleanArray muteArray,
         jbyte userID)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -344,7 +344,7 @@
 android_media_JetPlayer_setMuteFlags(JNIEnv *env, jobject thiz,
          jint muteFlags /*unsigned?*/, jboolean bSync)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -369,7 +369,7 @@
 android_media_JetPlayer_setMuteArray(JNIEnv *env, jobject thiz,
         jbooleanArray muteArray, jboolean bSync)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -415,7 +415,7 @@
 android_media_JetPlayer_setMuteFlag(JNIEnv *env, jobject thiz,
          jint trackId, jboolean muteFlag, jboolean bSync)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -441,7 +441,7 @@
 static jboolean
 android_media_JetPlayer_triggerClip(JNIEnv *env, jobject thiz, jint clipId)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -466,7 +466,7 @@
 static jboolean
 android_media_JetPlayer_clearQueue(JNIEnv *env, jobject thiz)
 {
-    JetPlayer *lpJet = (JetPlayer *)env->GetIntField(
+    JetPlayer *lpJet = (JetPlayer *)env->GetLongField(
         thiz, javaJetPlayerFields.nativePlayerInJavaObj);
     if (lpJet == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException",
@@ -533,7 +533,7 @@
     // Get the mNativePlayerInJavaObj variable field
     javaJetPlayerFields.nativePlayerInJavaObj = env->GetFieldID(
             jetPlayerClass,
-            JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "I");
+            JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME, "J");
     if (javaJetPlayerFields.nativePlayerInJavaObj == NULL) {
         ALOGE("Can't find JetPlayer.%s", JAVA_NATIVEJETPLAYERINJAVAOBJ_FIELD_NAME);
         return -1;
diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp
index 463be5e..1cd3fbb 100644
--- a/core/jni/android_media_RemoteDisplay.cpp
+++ b/core/jni/android_media_RemoteDisplay.cpp
@@ -134,7 +134,7 @@
 
 // ----------------------------------------------------------------------------
 
-static jint nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) {
+static jlong nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr) {
     ScopedUtfChars iface(env, ifaceStr);
 
     sp<IServiceManager> sm = defaultServiceManager();
@@ -155,20 +155,20 @@
     }
 
     NativeRemoteDisplay* wrapper = new NativeRemoteDisplay(display, client);
-    return reinterpret_cast<jint>(wrapper);
+    return reinterpret_cast<jlong>(wrapper);
 }
 
-static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
     NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
     wrapper->pause();
 }
 
-static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
     NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
     wrapper->resume();
 }
 
-static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jint ptr) {
+static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jlong ptr) {
     NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr);
     delete wrapper;
 }
@@ -176,13 +176,13 @@
 // ----------------------------------------------------------------------------
 
 static JNINativeMethod gMethods[] = {
-    {"nativeListen", "(Ljava/lang/String;)I",
+    {"nativeListen", "(Ljava/lang/String;)J",
             (void*)nativeListen },
-    {"nativeDispose", "(I)V",
+    {"nativeDispose", "(J)V",
             (void*)nativeDispose },
-    {"nativePause", "(I)V",
+    {"nativePause", "(J)V",
             (void*)nativePause },
-    {"nativeResume", "(I)V",
+    {"nativeResume", "(J)V",
             (void*)nativeResume },
 };
 
diff --git a/core/jni/android_media_ToneGenerator.cpp b/core/jni/android_media_ToneGenerator.cpp
index 76e42bc..ca00709 100644
--- a/core/jni/android_media_ToneGenerator.cpp
+++ b/core/jni/android_media_ToneGenerator.cpp
@@ -39,9 +39,9 @@
 static fields_t fields;
 
 static jboolean android_media_ToneGenerator_startTone(JNIEnv *env, jobject thiz, jint toneType, jint durationMs) {
-    ALOGV("android_media_ToneGenerator_startTone: %x", (int)thiz);
+    ALOGV("android_media_ToneGenerator_startTone: %p", thiz);
 
-    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
             fields.context);
     if (lpToneGen == NULL) {
         jniThrowRuntimeException(env, "Method called after release()");
@@ -52,12 +52,12 @@
 }
 
 static void android_media_ToneGenerator_stopTone(JNIEnv *env, jobject thiz) {
-    ALOGV("android_media_ToneGenerator_stopTone: %x", (int)thiz);
+    ALOGV("android_media_ToneGenerator_stopTone: %p", thiz);
 
-    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
             fields.context);
 
-    ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen);
+    ALOGV("ToneGenerator lpToneGen: %p", lpToneGen);
     if (lpToneGen == NULL) {
         jniThrowRuntimeException(env, "Method called after release()");
         return;
@@ -66,7 +66,7 @@
 }
 
 static jint android_media_ToneGenerator_getAudioSessionId(JNIEnv *env, jobject thiz) {
-    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
             fields.context);
     if (lpToneGen == NULL) {
         jniThrowRuntimeException(env, "Method called after release()");
@@ -76,11 +76,11 @@
 }
 
 static void android_media_ToneGenerator_release(JNIEnv *env, jobject thiz) {
-    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
             fields.context);
-    ALOGV("android_media_ToneGenerator_release lpToneGen: %x", (int)lpToneGen);
+    ALOGV("android_media_ToneGenerator_release lpToneGen: %p", lpToneGen);
 
-    env->SetIntField(thiz, fields.context, 0);
+    env->SetLongField(thiz, fields.context, 0);
 
     delete lpToneGen;
 }
@@ -89,11 +89,11 @@
         jint streamType, jint volume) {
     ToneGenerator *lpToneGen = new ToneGenerator((audio_stream_type_t) streamType, AudioSystem::linearToLog(volume), true);
 
-    env->SetIntField(thiz, fields.context, 0);
+    env->SetLongField(thiz, fields.context, 0);
 
-    ALOGV("android_media_ToneGenerator_native_setup jobject: %x", (int)thiz);
+    ALOGV("android_media_ToneGenerator_native_setup jobject: %p", thiz);
 
-    ALOGV("ToneGenerator lpToneGen: %x", (unsigned int)lpToneGen);
+    ALOGV("ToneGenerator lpToneGen: %p", lpToneGen);
 
     if (!lpToneGen->isInited()) {
         ALOGE("ToneGenerator init failed");
@@ -103,16 +103,16 @@
     }
 
     // Stow our new C++ ToneGenerator in an opaque field in the Java object.
-    env->SetIntField(thiz, fields.context, (int)lpToneGen);
+    env->SetLongField(thiz, fields.context, (jlong)lpToneGen);
 
-    ALOGV("ToneGenerator fields.context: %x", env->GetIntField(thiz, fields.context));
+    ALOGV("ToneGenerator fields.context: %p", (void*) env->GetLongField(thiz, fields.context));
 }
 
 static void android_media_ToneGenerator_native_finalize(JNIEnv *env,
         jobject thiz) {
-    ALOGV("android_media_ToneGenerator_native_finalize jobject: %x", (int)thiz);
+    ALOGV("android_media_ToneGenerator_native_finalize jobject: %p", thiz);
 
-    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetIntField(thiz,
+    ToneGenerator *lpToneGen = (ToneGenerator *)env->GetLongField(thiz,
             fields.context);
 
     if (lpToneGen != NULL) {
@@ -142,12 +142,12 @@
         return -1;
     }
 
-    fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.context == NULL) {
         ALOGE("Can't find ToneGenerator.mNativeContext");
         return -1;
     }
-    ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %x", (unsigned int)fields.context);
+    ALOGV("register_android_media_ToneGenerator ToneGenerator fields.context: %p", fields.context);
 
     return AndroidRuntime::registerNativeMethods(env,
             "android/media/ToneGenerator", gMethods, NELEM(gMethods));
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index f49ef2e..461b52f 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -107,13 +107,13 @@
      * Accessed by native methods: provides access to C++ AudioRecord object
      */
     @SuppressWarnings("unused")
-    private int mNativeRecorderInJavaObj;
+    private long mNativeRecorderInJavaObj;
 
     /**
      * Accessed by native methods: provides access to the callback data.
      */
     @SuppressWarnings("unused")
-    private int mNativeCallbackCookie;
+    private long mNativeCallbackCookie;
 
 
     //---------------------------------------------------------
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 78a37c5..01a6fc2 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -221,13 +221,13 @@
      * Accessed by native methods: provides access to C++ AudioTrack object.
      */
     @SuppressWarnings("unused")
-    private int mNativeTrackInJavaObj;
+    private long mNativeTrackInJavaObj;
     /**
      * Accessed by native methods: provides access to the JNI data (i.e. resources used by
      * the native AudioTrack object, but not stored in it).
      */
     @SuppressWarnings("unused")
-    private int mJniData;
+    private long mJniData;
 
 
     //--------------------------------------------------------------------------
diff --git a/media/java/android/media/FaceDetector.java b/media/java/android/media/FaceDetector.java
index cf900ce..61991e3 100644
--- a/media/java/android/media/FaceDetector.java
+++ b/media/java/android/media/FaceDetector.java
@@ -191,9 +191,9 @@
     native private void fft_get_face(Face face, int i);
     native private void fft_destroy();
 
-    private int     mFD;
-    private int     mSDK;
-    private int     mDCR;
+    private long    mFD;
+    private long    mSDK;
+    private long    mDCR;
     private int     mWidth;
     private int     mHeight;
     private int     mMaxFaces;    
diff --git a/media/java/android/media/JetPlayer.java b/media/java/android/media/JetPlayer.java
index 06cda34..bd91fc5 100644
--- a/media/java/android/media/JetPlayer.java
+++ b/media/java/android/media/JetPlayer.java
@@ -127,7 +127,7 @@
      * Accessed by native methods: provides access to C++ JetPlayer object 
      */
     @SuppressWarnings("unused")
-    private int mNativePlayerInJavaObj;
+    private long mNativePlayerInJavaObj;
 
     
     //--------------------------------------------
diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java
index 5175830..ddf88df 100644
--- a/media/java/android/media/MediaCodec.java
+++ b/media/java/android/media/MediaCodec.java
@@ -644,5 +644,5 @@
         native_init();
     }
 
-    private int mNativeContext;
+    private long mNativeContext;
 }
diff --git a/media/java/android/media/MediaCrypto.java b/media/java/android/media/MediaCrypto.java
index 40a1326..c7c3fc2 100644
--- a/media/java/android/media/MediaCrypto.java
+++ b/media/java/android/media/MediaCrypto.java
@@ -88,5 +88,5 @@
         native_init();
     }
 
-    private int mNativeContext;
+    private long mNativeContext;
 }
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java
index e558c07..c3e5035 100644
--- a/media/java/android/media/MediaExtractor.java
+++ b/media/java/android/media/MediaExtractor.java
@@ -352,5 +352,5 @@
         native_init();
     }
 
-    private int mNativeContext;
+    private long mNativeContext;
 }
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java
index 9014453..db27d09 100644
--- a/media/java/android/media/MediaMetadataRetriever.java
+++ b/media/java/android/media/MediaMetadataRetriever.java
@@ -42,7 +42,7 @@
 
     // The field below is accessed by native methods
     @SuppressWarnings("unused")
-    private int mNativeContext;
+    private long mNativeContext;
  
     private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF;
 
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 706258a..b34cea8 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -572,8 +572,8 @@
     // macro invocation in IMediaPlayer.cpp
     private final static String IMEDIA_PLAYER = "android.media.IMediaPlayer";
 
-    private int mNativeContext; // accessed by native methods
-    private int mNativeSurfaceTexture;  // accessed by native methods
+    private long mNativeContext; // accessed by native methods
+    private long mNativeSurfaceTexture;  // accessed by native methods
     private int mListenerContext; // accessed by native methods
     private SurfaceHolder mSurfaceHolder;
     private EventHandler mEventHandler;
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 8dcbd6b..5a9d577 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -81,7 +81,7 @@
 
     // The two fields below are accessed by native methods
     @SuppressWarnings("unused")
-    private int mNativeContext;
+    private long mNativeContext;
 
     @SuppressWarnings("unused")
     private Surface mSurface;
diff --git a/media/java/android/media/MediaScanner.java b/media/java/android/media/MediaScanner.java
index de3041e..53835e2 100644
--- a/media/java/android/media/MediaScanner.java
+++ b/media/java/android/media/MediaScanner.java
@@ -301,7 +301,7 @@
         // 148 and up don't seem to have been defined yet.
     };
 
-    private int mNativeContext;
+    private long mNativeContext;
     private Context mContext;
     private String mPackageName;
     private IContentProvider mMediaProvider;
diff --git a/media/java/android/media/RemoteDisplay.java b/media/java/android/media/RemoteDisplay.java
index 7afce1a..4e937a5 100644
--- a/media/java/android/media/RemoteDisplay.java
+++ b/media/java/android/media/RemoteDisplay.java
@@ -38,12 +38,12 @@
     private final Listener mListener;
     private final Handler mHandler;
 
-    private int mPtr;
+    private long mPtr;
 
-    private native int nativeListen(String iface);
-    private native void nativeDispose(int ptr);
-    private native void nativePause(int ptr);
-    private native void nativeResume(int ptr);
+    private native long nativeListen(String iface);
+    private native void nativeDispose(long ptr);
+    private native void nativePause(long ptr);
+    private native void nativeResume(long ptr);
 
     private RemoteDisplay(Listener listener, Handler handler) {
         mListener = listener;
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 06af5de..fbfc574 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -443,7 +443,7 @@
         private final static String TAG = "SoundPool";
         private final static boolean DEBUG = false;
 
-        private int mNativeContext; // accessed by native methods
+        private long mNativeContext; // accessed by native methods
 
         private EventHandler mEventHandler;
         private SoundPool.OnLoadCompleteListener mOnLoadCompleteListener;
diff --git a/media/java/android/media/ToneGenerator.java b/media/java/android/media/ToneGenerator.java
index 5592105..713f147 100644
--- a/media/java/android/media/ToneGenerator.java
+++ b/media/java/android/media/ToneGenerator.java
@@ -887,5 +887,5 @@
     protected void finalize() { native_finalize(); }
 
     @SuppressWarnings("unused")
-    private int mNativeContext; // accessed by native methods
+    private long mNativeContext; // accessed by native methods
 }
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index b8d437c..221ea57 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -328,20 +328,20 @@
 
 static sp<JMediaCodec> setMediaCodec(
         JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) {
-    sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+    sp<JMediaCodec> old = (JMediaCodec *)env->GetLongField(thiz, gFields.context);
     if (codec != NULL) {
         codec->incStrong(thiz);
     }
     if (old != NULL) {
         old->decStrong(thiz);
     }
-    env->SetIntField(thiz, gFields.context, (int)codec.get());
+    env->SetLongField(thiz, gFields.context, (jlong)codec.get());
 
     return old;
 }
 
 static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) {
-    return (JMediaCodec *)env->GetIntField(thiz, gFields.context);
+    return (JMediaCodec *)env->GetLongField(thiz, gFields.context);
 }
 
 static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) {
@@ -710,7 +710,7 @@
     status_t err = codec->dequeueInputBuffer(&index, timeoutUs);
 
     if (err == OK) {
-        return index;
+        return (jint) index;
     }
 
     return throwExceptionAsNecessary(env, err);
@@ -732,7 +732,7 @@
             env, bufferInfo, &index, timeoutUs);
 
     if (err == OK) {
-        return index;
+        return (jint) index;
     }
 
     return throwExceptionAsNecessary(env, err);
@@ -885,7 +885,7 @@
             env, env->FindClass("android/media/MediaCodec"));
     CHECK(clazz.get() != NULL);
 
-    gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "I");
+    gFields.context = env->GetFieldID(clazz.get(), "mNativeContext", "J");
     CHECK(gFields.context != NULL);
 
     clazz.reset(env->FindClass("android/media/MediaCodec$CryptoInfo"));
diff --git a/media/jni/android_media_MediaCrypto.cpp b/media/jni/android_media_MediaCrypto.cpp
index d0f56ea..a6f8dcd 100644
--- a/media/jni/android_media_MediaCrypto.cpp
+++ b/media/jni/android_media_MediaCrypto.cpp
@@ -38,7 +38,7 @@
 static fields_t gFields;
 
 static sp<JCrypto> getCrypto(JNIEnv *env, jobject thiz) {
-    return (JCrypto *)env->GetIntField(thiz, gFields.context);
+    return (JCrypto *)env->GetLongField(thiz, gFields.context);
 }
 
 JCrypto::JCrypto(
@@ -146,14 +146,14 @@
 
 static sp<JCrypto> setCrypto(
         JNIEnv *env, jobject thiz, const sp<JCrypto> &crypto) {
-    sp<JCrypto> old = (JCrypto *)env->GetIntField(thiz, gFields.context);
+    sp<JCrypto> old = (JCrypto *)env->GetLongField(thiz, gFields.context);
     if (crypto != NULL) {
         crypto->incStrong(thiz);
     }
     if (old != NULL) {
         old->decStrong(thiz);
     }
-    env->SetIntField(thiz, gFields.context, (int)crypto.get());
+    env->SetLongField(thiz, gFields.context, (jlong)crypto.get());
 
     return old;
 }
@@ -166,7 +166,7 @@
     jclass clazz = env->FindClass("android/media/MediaCrypto");
     CHECK(clazz != NULL);
 
-    gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     CHECK(gFields.context != NULL);
 }
 
@@ -232,7 +232,7 @@
                 env,
                 "java/lang/IllegalArgumentException",
                 NULL);
-        return false;
+        return JNI_FALSE;
     }
 
     jboolean isCopy;
@@ -243,27 +243,27 @@
     env->ReleaseByteArrayElements(uuidObj, uuid, 0);
     uuid = NULL;
 
-    return result;
+    return result ? JNI_TRUE : JNI_FALSE;
 }
 
 static jboolean android_media_MediaCrypto_requiresSecureDecoderComponent(
         JNIEnv *env, jobject thiz, jstring mimeObj) {
     if (mimeObj == NULL) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return JNI_FALSE;
     }
 
     sp<JCrypto> crypto = getCrypto(env, thiz);
 
     if (crypto == NULL) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return JNI_FALSE;
     }
 
     const char *mime = env->GetStringUTFChars(mimeObj, NULL);
 
     if (mime == NULL) {
-        return false;
+        return JNI_FALSE;
     }
 
     bool result = crypto->requiresSecureDecoderComponent(mime);
@@ -271,7 +271,7 @@
     env->ReleaseStringUTFChars(mimeObj, mime);
     mime = NULL;
 
-    return result;
+    return result ? JNI_TRUE : JNI_FALSE;
 }
 
 static JNINativeMethod gMethods[] = {
diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp
index 1ac45d4..705de88 100644
--- a/media/jni/android_media_MediaExtractor.cpp
+++ b/media/jni/android_media_MediaExtractor.cpp
@@ -88,7 +88,7 @@
         env->GetByteArrayRegion(byteArrayObj, 0, size, (jbyte*) buffer);
         env->DeleteLocalRef(byteArrayObj);
         if (env->ExceptionCheck()) {
-            ALOGW("Exception occurred while reading %d at %lld", size, offset);
+            ALOGW("Exception occurred while reading %zu at %lld", size, offset);
             LOGW_EX(env);
             env->ExceptionClear();
             return -1;
@@ -198,7 +198,7 @@
 
     void *dst = env->GetDirectBufferAddress(byteBuf);
 
-    jlong dstSize;
+    size_t dstSize;
     jbyteArray byteArray = NULL;
 
     if (dst == NULL) {
@@ -219,9 +219,9 @@
         jboolean isCopy;
         dst = env->GetByteArrayElements(byteArray, &isCopy);
 
-        dstSize = env->GetArrayLength(byteArray);
+        dstSize = (size_t) env->GetArrayLength(byteArray);
     } else {
-        dstSize = env->GetDirectBufferCapacity(byteBuf);
+        dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf);
     }
 
     if (dstSize < offset) {
@@ -299,7 +299,7 @@
 static sp<JMediaExtractor> setMediaExtractor(
         JNIEnv *env, jobject thiz, const sp<JMediaExtractor> &extractor) {
     sp<JMediaExtractor> old =
-        (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+        (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
 
     if (extractor != NULL) {
         extractor->incStrong(thiz);
@@ -307,13 +307,13 @@
     if (old != NULL) {
         old->decStrong(thiz);
     }
-    env->SetIntField(thiz, gFields.context, (int)extractor.get());
+    env->SetLongField(thiz, gFields.context, (jlong)extractor.get());
 
     return old;
 }
 
 static sp<JMediaExtractor> getMediaExtractor(JNIEnv *env, jobject thiz) {
-    return (JMediaExtractor *)env->GetIntField(thiz, gFields.context);
+    return (JMediaExtractor *)env->GetLongField(thiz, gFields.context);
 }
 
 static void android_media_MediaExtractor_release(JNIEnv *env, jobject thiz) {
@@ -329,7 +329,7 @@
         return -1;
     }
 
-    return extractor->countTracks();
+    return (jint) extractor->countTracks();
 }
 
 static jobject android_media_MediaExtractor_getTrackFormatNative(
@@ -430,19 +430,19 @@
 
     if (extractor == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return false;
+        return JNI_FALSE;
     }
 
     status_t err = extractor->advance();
 
     if (err == ERROR_END_OF_STREAM) {
-        return false;
+        return JNI_FALSE;
     } else if (err != OK) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return JNI_FALSE;
     }
 
-    return true;
+    return JNI_TRUE;
 }
 
 static jint android_media_MediaExtractor_readSampleData(
@@ -461,10 +461,10 @@
         return -1;
     } else if (err != OK) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return -1;
     }
 
-    return sampleSize;
+    return (jint) sampleSize;
 }
 
 static jint android_media_MediaExtractor_getSampleTrackIndex(
@@ -483,10 +483,10 @@
         return -1;
     } else if (err != OK) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return -1;
     }
 
-    return trackIndex;
+    return (jint) trackIndex;
 }
 
 static jlong android_media_MediaExtractor_getSampleTime(
@@ -505,10 +505,10 @@
         return -1ll;
     } else if (err != OK) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return -1ll;
     }
 
-    return sampleTimeUs;
+    return (jlong) sampleTimeUs;
 }
 
 static jint android_media_MediaExtractor_getSampleFlags(
@@ -517,20 +517,20 @@
 
     if (extractor == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return -1ll;
+        return -1;
     }
 
     uint32_t sampleFlags;
     status_t err = extractor->getSampleFlags(&sampleFlags);
 
     if (err == ERROR_END_OF_STREAM) {
-        return -1ll;
+        return -1;
     } else if (err != OK) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
-        return false;
+        return -1;
     }
 
-    return sampleFlags;
+    return (jint) sampleFlags;
 }
 
 static jboolean android_media_MediaExtractor_getSampleCryptoInfo(
@@ -539,27 +539,27 @@
 
     if (extractor == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return -1ll;
+        return JNI_FALSE;
     }
 
     sp<MetaData> meta;
     status_t err = extractor->getSampleMeta(&meta);
 
     if (err != OK) {
-        return false;
+        return JNI_FALSE;
     }
 
     uint32_t type;
     const void *data;
     size_t size;
     if (!meta->findData(kKeyEncryptedSizes, &type, &data, &size)) {
-        return false;
+        return JNI_FALSE;
     }
 
     size_t numSubSamples = size / sizeof(size_t);
 
     if (numSubSamples == 0) {
-        return false;
+        return JNI_FALSE;
     }
 
     jintArray numBytesOfEncryptedDataObj = env->NewIntArray(numSubSamples);
@@ -576,7 +576,7 @@
     if (meta->findData(kKeyPlainSizes, &type, &data, &size)) {
         if (size != encSize) {
             // The two must be of the same length.
-            return false;
+            return JNI_FALSE;
         }
 
         numBytesOfPlainDataObj = env->NewIntArray(numSubSamples);
@@ -593,7 +593,7 @@
     if (meta->findData(kKeyCryptoKey, &type, &data, &size)) {
         if (size != 16) {
             // Keys must be 16 bytes in length.
-            return false;
+            return JNI_FALSE;
         }
 
         keyObj = env->NewByteArray(size);
@@ -608,7 +608,7 @@
     if (meta->findData(kKeyCryptoIV, &type, &data, &size)) {
         if (size != 16) {
             // IVs must be 16 bytes in length.
-            return false;
+            return JNI_FALSE;
         }
 
         ivObj = env->NewByteArray(size);
@@ -634,14 +634,14 @@
             ivObj,
             mode);
 
-    return true;
+    return JNI_TRUE;
 }
 
 static void android_media_MediaExtractor_native_init(JNIEnv *env) {
     jclass clazz = env->FindClass("android/media/MediaExtractor");
     CHECK(clazz != NULL);
 
-    gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    gFields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     CHECK(gFields.context != NULL);
 
     clazz = env->FindClass("android/media/MediaCodec$CryptoInfo");
@@ -770,7 +770,7 @@
         return -1ll;
     }
 
-    return cachedDurationUs;
+    return (jlong) cachedDurationUs;
 }
 
 static jboolean android_media_MediaExtractor_hasCacheReachedEOS(
@@ -779,16 +779,16 @@
 
     if (extractor == NULL) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return true;
+        return JNI_TRUE;
     }
 
     int64_t cachedDurationUs;
     bool eos;
     if (!extractor->getCachedDuration(&cachedDurationUs, &eos)) {
-        return true;
+        return JNI_TRUE;
     }
 
-    return eos;
+    return eos ? JNI_TRUE : JNI_FALSE;
 }
 
 static void android_media_MediaExtractor_native_finalize(
diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp
index 297dadf..fe69819 100644
--- a/media/jni/android_media_MediaMetadataRetriever.cpp
+++ b/media/jni/android_media_MediaMetadataRetriever.cpp
@@ -67,15 +67,15 @@
 static MediaMetadataRetriever* getRetriever(JNIEnv* env, jobject thiz)
 {
     // No lock is needed, since it is called internally by other methods that are protected
-    MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
+    MediaMetadataRetriever* retriever = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
     return retriever;
 }
 
-static void setRetriever(JNIEnv* env, jobject thiz, int retriever)
+static void setRetriever(JNIEnv* env, jobject thiz, MediaMetadataRetriever* retriever)
 {
     // No lock is needed, since it is called internally by other methods that are protected
-    MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetIntField(thiz, fields.context);
-    env->SetIntField(thiz, fields.context, retriever);
+    MediaMetadataRetriever *old = (MediaMetadataRetriever*) env->GetLongField(thiz, fields.context);
+    env->SetLongField(thiz, fields.context, (jlong) retriever);
 }
 
 static void
@@ -146,10 +146,10 @@
     int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
     if (offset < 0 || length < 0 || fd < 0) {
         if (offset < 0) {
-            ALOGE("negative offset (%lld)", offset);
+            ALOGE("negative offset (%lld)", (long long)offset);
         }
         if (length < 0) {
-            ALOGE("negative length (%lld)", length);
+            ALOGE("negative length (%lld)", (long long)length);
         }
         if (fd < 0) {
             ALOGE("invalid file descriptor");
@@ -359,7 +359,7 @@
     Mutex::Autolock lock(sLock);
     MediaMetadataRetriever* retriever = getRetriever(env, thiz);
     delete retriever;
-    setRetriever(env, thiz, 0);
+    setRetriever(env, thiz, (MediaMetadataRetriever*) 0);
 }
 
 static void android_media_MediaMetadataRetriever_native_finalize(JNIEnv *env, jobject thiz)
@@ -379,7 +379,7 @@
         return;
     }
 
-    fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.context == NULL) {
         return;
     }
@@ -435,7 +435,7 @@
         jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
         return;
     }
-    setRetriever(env, thiz, (int)retriever);
+    setRetriever(env, thiz, retriever);
 }
 
 // JNI mapping between Java methods and native methods
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index 5e3fb1a..9d0d5a6 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -133,21 +133,21 @@
 static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
 {
     Mutex::Autolock l(sLock);
-    MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+    MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context);
     return sp<MediaPlayer>(p);
 }
 
 static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
 {
     Mutex::Autolock l(sLock);
-    sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context);
+    sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context);
     if (player.get()) {
         player->incStrong((void*)setMediaPlayer);
     }
     if (old != 0) {
         old->decStrong((void*)setMediaPlayer);
     }
-    env->SetIntField(thiz, fields.context, (int)player.get());
+    env->SetLongField(thiz, fields.context, (jlong)player.get());
     return old;
 }
 
@@ -244,7 +244,7 @@
 
 static sp<IGraphicBufferProducer>
 getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
-    IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetIntField(thiz, fields.surface_texture);
+    IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture);
     return sp<IGraphicBufferProducer>(p);
 }
 
@@ -293,7 +293,7 @@
         }
     }
 
-    env->SetIntField(thiz, fields.surface_texture, (int)new_st.get());
+    env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get());
 
     // This will fail if the media player has not been initialized yet. This
     // can be the case if setDisplay() on MediaPlayer.java has been called
@@ -384,7 +384,7 @@
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
     if (mp == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return false;
+        return JNI_FALSE;
     }
     const jboolean is_playing = mp->isPlaying();
 
@@ -393,7 +393,7 @@
 }
 
 static void
-android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec)
+android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec)
 {
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
     if (mp == NULL ) {
@@ -404,7 +404,7 @@
     process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
 }
 
-static int
+static jint
 android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
 {
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -418,10 +418,10 @@
         w = 0;
     }
     ALOGV("getVideoWidth: %d", w);
-    return w;
+    return (jint) w;
 }
 
-static int
+static jint
 android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
 {
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -435,11 +435,11 @@
         h = 0;
     }
     ALOGV("getVideoHeight: %d", h);
-    return h;
+    return (jint) h;
 }
 
 
-static int
+static jint
 android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
 {
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -450,10 +450,10 @@
     int msec;
     process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
     ALOGV("getCurrentPosition: %d (msec)", msec);
-    return msec;
+    return (jint) msec;
 }
 
-static int
+static jint
 android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
 {
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -464,7 +464,7 @@
     int msec;
     process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
     ALOGV("getDuration: %d (msec)", msec);
-    return msec;
+    return (jint) msec;
 }
 
 static void
@@ -480,7 +480,7 @@
 }
 
 static void
-android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype)
+android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype)
 {
     ALOGV("setAudioStreamType: %d", streamtype);
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
@@ -510,21 +510,21 @@
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
     if (mp == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return false;
+        return JNI_FALSE;
     }
-    return mp->isLooping();
+    return mp->isLooping() ? JNI_TRUE : JNI_FALSE;
 }
 
 static void
-android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume)
+android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
 {
-    ALOGV("setVolume: left %f  right %f", leftVolume, rightVolume);
+    ALOGV("setVolume: left %f  right %f", (float) leftVolume, (float) rightVolume);
     sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
     if (mp == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
         return;
     }
-    process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL );
+    process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
 }
 
 // Sends the request and reply parcels to the media player via the
@@ -544,7 +544,7 @@
 
     // Don't use process_media_player_call which use the async loop to
     // report errors, instead returns the status.
-    return media_player->invoke(*request, reply);
+    return (jint) media_player->invoke(*request, reply);
 }
 
 // Sends the new filter to the client.
@@ -564,7 +564,7 @@
         return UNKNOWN_ERROR;
     }
 
-    return media_player->setMetadataFilter(*filter);
+    return (jint) media_player->setMetadataFilter(*filter);
 }
 
 static jboolean
@@ -574,14 +574,14 @@
     sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
     if (media_player == NULL ) {
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
-        return false;
+        return JNI_FALSE;
     }
 
     Parcel *metadata = parcelForJavaObject(env, reply);
 
     if (metadata == NULL ) {
         jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
-        return false;
+        return JNI_FALSE;
     }
 
     metadata->freeData();
@@ -589,7 +589,11 @@
     // metadata. Note however that the parcel actually starts with the
     // return code so you should not rewind the parcel using
     // setDataPosition(0).
-    return media_player->getMetadata(update_only, apply_filter, metadata) == OK;
+    if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) {
+        return JNI_TRUE;
+    } else {
+        return JNI_FALSE;
+    }
 }
 
 // This function gets some field IDs, which in turn causes class initialization.
@@ -605,7 +609,7 @@
         return;
     }
 
-    fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.context == NULL) {
         return;
     }
@@ -616,7 +620,7 @@
         return;
     }
 
-    fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I");
+    fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
     if (fields.surface_texture == NULL) {
         return;
     }
@@ -696,7 +700,7 @@
         return 0;
     }
 
-    return mp->getAudioSessionId();
+    return (jint) mp->getAudioSessionId();
 }
 
 static void
@@ -733,7 +737,7 @@
 
     Parcel *reply = parcelForJavaObject(env, java_reply);
 
-    return service->pullBatteryData(reply);
+    return (jint) service->pullBatteryData(reply);
 }
 
 static jint
@@ -772,7 +776,7 @@
         jniThrowException(env, "java/lang/IllegalStateException", NULL);
     }
 
-    return ret;
+    return (jint) ret;
 }
 
 static void
diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp
index 3fbb8ba..48a9132 100644
--- a/media/jni/android_media_MediaProfiles.cpp
+++ b/media/jni/android_media_MediaProfiles.cpp
@@ -48,7 +48,7 @@
 android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz)
 {
     ALOGV("native_get_num_file_formats");
-    return sProfiles->getOutputFileFormats().size();
+    return (jint) sProfiles->getOutputFileFormats().size();
 }
 
 static jint
@@ -119,7 +119,7 @@
 android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz)
 {
     ALOGV("native_get_num_audio_encoders");
-    return sProfiles->getAudioEncoders().size();
+    return (jint) sProfiles->getAudioEncoders().size();
 }
 
 static jobject
@@ -223,18 +223,18 @@
 {
     ALOGV("native_has_camcorder_profile: %d %d", id, quality);
     if (!isCamcorderQualityKnown(quality)) {
-        return false;
+        return JNI_FALSE;
     }
 
     camcorder_quality q = static_cast<camcorder_quality>(quality);
-    return sProfiles->hasCamcorderProfile(id, q);
+    return sProfiles->hasCamcorderProfile(id, q) ? JNI_TRUE : JNI_FALSE;
 }
 
 static jint
 android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz)
 {
     ALOGV("native_get_num_video_decoders");
-    return sProfiles->getVideoDecoders().size();
+    return (jint) sProfiles->getVideoDecoders().size();
 }
 
 static jint
@@ -255,7 +255,7 @@
 android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz)
 {
     ALOGV("native_get_num_audio_decoders");
-    return sProfiles->getAudioDecoders().size();
+    return (jint) sProfiles->getAudioDecoders().size();
 }
 
 static jint
@@ -276,7 +276,7 @@
 android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId)
 {
     ALOGV("native_get_num_image_encoding_quality_levels");
-    return sProfiles->getImageEncodingQualityLevels(cameraId).size();
+    return (jint) sProfiles->getImageEncodingQualityLevels(cameraId).size();
 }
 
 static jint
@@ -284,7 +284,7 @@
 {
     ALOGV("native_get_image_encoding_quality_level");
     Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId);
-    if (index < 0 || index >= levels.size()) {
+    if (index < 0 || index >= (jint) levels.size()) {
         jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary");
         return -1;
     }
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index 9888591..0cfd2ff 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -128,21 +128,21 @@
 static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz)
 {
     Mutex::Autolock l(sLock);
-    MediaRecorder* const p = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+    MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context);
     return sp<MediaRecorder>(p);
 }
 
 static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder)
 {
     Mutex::Autolock l(sLock);
-    sp<MediaRecorder> old = (MediaRecorder*)env->GetIntField(thiz, fields.context);
+    sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context);
     if (recorder.get()) {
         recorder->incStrong(thiz);
     }
     if (old != 0) {
         old->decStrong(thiz);
     }
-    env->SetIntField(thiz, fields.context, (int)recorder.get());
+    env->SetLongField(thiz, fields.context, (jlong)recorder.get());
     return old;
 }
 
@@ -334,14 +334,14 @@
     process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed.");
 }
 
-static int
+static jint
 android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz)
 {
     ALOGV("getMaxAmplitude");
     sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
     int result = 0;
     process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed.");
-    return result;
+    return (jint) result;
 }
 
 static void
@@ -392,7 +392,7 @@
         return;
     }
 
-    fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.context == NULL) {
         return;
     }
diff --git a/media/jni/android_media_MediaScanner.cpp b/media/jni/android_media_MediaScanner.cpp
index 4e3d14e..84028b7 100644
--- a/media/jni/android_media_MediaScanner.cpp
+++ b/media/jni/android_media_MediaScanner.cpp
@@ -226,12 +226,12 @@
 
 static MediaScanner *getNativeScanner_l(JNIEnv* env, jobject thiz)
 {
-    return (MediaScanner *) env->GetIntField(thiz, fields.context);
+    return (MediaScanner *) env->GetLongField(thiz, fields.context);
 }
 
 static void setNativeScanner_l(JNIEnv* env, jobject thiz, MediaScanner *s)
 {
-    env->SetIntField(thiz, fields.context, (int)s);
+    env->SetLongField(thiz, fields.context, (jlong)s);
 }
 
 static void
@@ -381,7 +381,7 @@
         return;
     }
 
-    fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.context == NULL) {
         return;
     }
@@ -398,7 +398,7 @@
         return;
     }
 
-    env->SetIntField(thiz, fields.context, (int)mp);
+    env->SetLongField(thiz, fields.context, (jlong)mp);
 }
 
 static void
diff --git a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
index 2604850..9cc55ab 100644
--- a/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
+++ b/media/jni/soundpool/android_media_SoundPool_SoundPoolImpl.cpp
@@ -34,11 +34,11 @@
 } fields;
 
 static inline SoundPool* MusterSoundPool(JNIEnv *env, jobject thiz) {
-    return (SoundPool*)env->GetIntField(thiz, fields.mNativeContext);
+    return (SoundPool*)env->GetLongField(thiz, fields.mNativeContext);
 }
 
 // ----------------------------------------------------------------------------
-static int
+static jint
 android_media_SoundPool_SoundPoolImpl_load_URL(JNIEnv *env, jobject thiz, jstring path, jint priority)
 {
     ALOGV("android_media_SoundPool_SoundPoolImpl_load_URL");
@@ -50,29 +50,29 @@
     const char* s = env->GetStringUTFChars(path, NULL);
     int id = ap->load(s, priority);
     env->ReleaseStringUTFChars(path, s);
-    return id;
+    return (jint) id;
 }
 
-static int
+static jint
 android_media_SoundPool_SoundPoolImpl_load_FD(JNIEnv *env, jobject thiz, jobject fileDescriptor,
         jlong offset, jlong length, jint priority)
 {
     ALOGV("android_media_SoundPool_SoundPoolImpl_load_FD");
     SoundPool *ap = MusterSoundPool(env, thiz);
     if (ap == NULL) return 0;
-    return ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
+    return (jint) ap->load(jniGetFDFromFileDescriptor(env, fileDescriptor),
             int64_t(offset), int64_t(length), int(priority));
 }
 
-static bool
+static jboolean
 android_media_SoundPool_SoundPoolImpl_unload(JNIEnv *env, jobject thiz, jint sampleID) {
     ALOGV("android_media_SoundPool_SoundPoolImpl_unload\n");
     SoundPool *ap = MusterSoundPool(env, thiz);
-    if (ap == NULL) return 0;
-    return ap->unload(sampleID);
+    if (ap == NULL) return JNI_FALSE;
+    return ap->unload(sampleID) ? JNI_TRUE : JNI_FALSE;
 }
 
-static int
+static jint
 android_media_SoundPool_SoundPoolImpl_play(JNIEnv *env, jobject thiz, jint sampleID,
         jfloat leftVolume, jfloat rightVolume, jint priority, jint loop,
         jfloat rate)
@@ -80,7 +80,7 @@
     ALOGV("android_media_SoundPool_SoundPoolImpl_play\n");
     SoundPool *ap = MusterSoundPool(env, thiz);
     if (ap == NULL) return 0;
-    return ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
+    return (jint) ap->play(sampleID, leftVolume, rightVolume, priority, loop, rate);
 }
 
 static void
@@ -130,22 +130,22 @@
 
 static void
 android_media_SoundPool_SoundPoolImpl_setVolume(JNIEnv *env, jobject thiz, jint channelID,
-        float leftVolume, float rightVolume)
+        jfloat leftVolume, jfloat rightVolume)
 {
     ALOGV("android_media_SoundPool_SoundPoolImpl_setVolume");
     SoundPool *ap = MusterSoundPool(env, thiz);
     if (ap == NULL) return;
-    ap->setVolume(channelID, leftVolume, rightVolume);
+    ap->setVolume(channelID, (float) leftVolume, (float) rightVolume);
 }
 
 static void
 android_media_SoundPool_SoundPoolImpl_setPriority(JNIEnv *env, jobject thiz, jint channelID,
-        int priority)
+        jint priority)
 {
     ALOGV("android_media_SoundPool_SoundPoolImpl_setPriority");
     SoundPool *ap = MusterSoundPool(env, thiz);
     if (ap == NULL) return;
-    ap->setPriority(channelID, priority);
+    ap->setPriority(channelID, (int) priority);
 }
 
 static void
@@ -160,12 +160,12 @@
 
 static void
 android_media_SoundPool_SoundPoolImpl_setRate(JNIEnv *env, jobject thiz, jint channelID,
-        float rate)
+       jfloat rate)
 {
     ALOGV("android_media_SoundPool_SoundPoolImpl_setRate");
     SoundPool *ap = MusterSoundPool(env, thiz);
     if (ap == NULL) return;
-    ap->setRate(channelID, rate);
+    ap->setRate(channelID, (float) rate);
 }
 
 static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, void* user)
@@ -185,7 +185,7 @@
     }
 
     // save pointer to SoundPool C++ object in opaque field in Java object
-    env->SetIntField(thiz, fields.mNativeContext, (int)ap);
+    env->SetLongField(thiz, fields.mNativeContext, (jlong) ap);
 
     // set callback with weak reference
     jobject globalWeakRef = env->NewGlobalRef(weakRef);
@@ -208,7 +208,7 @@
 
         // clear callback and native context
         ap->setCallback(NULL, NULL);
-        env->SetIntField(thiz, fields.mNativeContext, 0);
+        env->SetLongField(thiz, fields.mNativeContext, 0);
         delete ap;
     }
 }
@@ -299,7 +299,7 @@
         goto bail;
     }
 
-    fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "I");
+    fields.mNativeContext = env->GetFieldID(clazz, "mNativeContext", "J");
     if (fields.mNativeContext == NULL) {
         ALOGE("Can't find SoundPoolImpl.mNativeContext");
         goto bail;
diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp
index 9abf191..6da7b7c 100644
--- a/media/mca/filterfw/jni/jni_gl_environment.cpp
+++ b/media/mca/filterfw/jni/jni_gl_environment.cpp
@@ -119,12 +119,12 @@
         return NULL;
     }
 
-    jfieldID context = env->GetFieldID(clazz, "mNativeContext", "I");
+    jfieldID context = env->GetFieldID(clazz, "mNativeContext", "J");
     if (context == NULL) {
         return NULL;
     }
 
-    MediaRecorder* const p = (MediaRecorder*)env->GetIntField(jmediarecorder, context);
+    MediaRecorder* const p = (MediaRecorder*)env->GetLongField(jmediarecorder, context);
     env->DeleteLocalRef(clazz);
     return sp<MediaRecorder>(p);
 }