/soc/2012/michael/android: 922e5e810a4d: sslops: added Android 4...

Michael Zangl michael at soc.pidgin.im
Sun Jul 29 08:20:08 EDT 2012


Changeset: 922e5e810a4dab1a7d1e324478f762ec7914ae69
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-29 14:08 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/922e5e810a4d

Description:

sslops: added Android 4 check and the deletion of unneded local references.

diffstat:

 android/workspace/im.pidgin.libpurple/native/SslOps.c |  12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diffs (30 lines):

diff --git a/android/workspace/im.pidgin.libpurple/native/SslOps.c b/android/workspace/im.pidgin.libpurple/native/SslOps.c
--- a/android/workspace/im.pidgin.libpurple/native/SslOps.c
+++ b/android/workspace/im.pidgin.libpurple/native/SslOps.c
@@ -52,8 +52,12 @@ fd_to_socket(JNIEnv *env, int unix_fd)
 	g_return_val_if_fail(fdField != NULL, NULL);
 	(*env)->SetIntField(env, fd, fdField, unix_fd);
 
-	// Android 4: socketImplClass = (*env)->FindClass(env, "android/net/LocalSocketImpl");
 	socketImplClass = (*env)->FindClass(env, "org/apache/harmony/luni/net/PlainSocketImpl");
+	if ((*env)->ExceptionOccurred(env)) {
+		/* class not found on Android 4 */
+		(*env)->ExceptionClear(env);
+		socketImplClass = (*env)->FindClass(env, "android/net/LocalSocketImpl");
+	}
 	socketImplConstructorMid = getMethodIDCachedReferenced(env, socketImplClass,
 			&socketImplConstructor);
 	g_return_val_if_fail(socketImplConstructorMid != NULL, NULL);
@@ -74,6 +78,12 @@ fd_to_socket(JNIEnv *env, int unix_fd)
 	g_return_val_if_fail(boundField != NULL, NULL);
 	(*env)->SetBooleanField(env, socket, boundField, JNI_TRUE);
 
+	(*env)->DeleteLocalRef(env, fd);
+	(*env)->DeleteLocalRef(env, fdClass);
+	(*env)->DeleteLocalRef(env, socketImpl);
+	(*env)->DeleteLocalRef(env, socketImplClass);
+	(*env)->DeleteLocalRef(env, socketClass);
+
 	return socket;
 }
 



More information about the Commits mailing list