Merge "UsbService: Fix JNI local reference leaks in the USB host support code" into honeycomb-mr1
diff --git a/services/jni/com_android_server_UsbService.cpp b/services/jni/com_android_server_UsbService.cpp
index 816f76f..6aeede2 100644
--- a/services/jni/com_android_server_UsbService.cpp
+++ b/services/jni/com_android_server_UsbService.cpp
@@ -117,9 +117,14 @@
jintArray endpointArray = env->NewIntArray(length);
env->SetIntArrayRegion(endpointArray, 0, length, endpointValues.array());
+ jstring deviceName = env->NewStringUTF(devname);
env->CallVoidMethod(thiz, method_usbDeviceAdded,
- env->NewStringUTF(devname), vendorId, productId, deviceClass,
+ deviceName, vendorId, productId, deviceClass,
deviceSubClass, protocol, interfaceArray, endpointArray);
+
+ env->DeleteLocalRef(interfaceArray);
+ env->DeleteLocalRef(endpointArray);
+ env->DeleteLocalRef(deviceName);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return 0;
@@ -129,7 +134,9 @@
JNIEnv* env = AndroidRuntime::getJNIEnv();
jobject thiz = (jobject)client_data;
+ jstring deviceName = env->NewStringUTF(devname);
env->CallVoidMethod(thiz, method_usbDeviceRemoved, env->NewStringUTF(devname));
+ env->DeleteLocalRef(deviceName);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return 0;
}