Lines Matching full:env
50 static jclass jni_get_class(JNIEnv *env, const char *path) in jni_get_class() argument
54 if (env == NULL || path == NULL || *path == '\0') { in jni_get_class()
58 cls = (*env)->FindClass(env, path); in jni_get_class()
59 if ((*env)->ExceptionOccurred(env)) { in jni_get_class()
60 (*env)->ExceptionClear(env); in jni_get_class()
66 static jmethodID jni_get_method_id(JNIEnv *env, jclass cls, in jni_get_method_id() argument
71 if (env == NULL || cls == NULL || func_name == NULL || *func_name == '\0' || in jni_get_method_id()
76 mid = (*env)->GetMethodID(env, cls, func_name, signature); in jni_get_method_id()
77 if ((*env)->ExceptionOccurred(env)) { in jni_get_method_id()
78 (*env)->ExceptionClear(env); in jni_get_method_id()
85 static int jvm_attach(JNIEnv **env) in jvm_attach() argument
99 return (*android_jvm)->AttachCurrentThread(android_jvm, env, &args); in jvm_attach()
109 JNIEnv *env = NULL; in ares_library_init_android() local
119 res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); in ares_library_init_android()
121 env = NULL; in ares_library_init_android()
122 res = jvm_attach(&env); in ares_library_init_android()
125 if (res != JNI_OK || env == NULL) { in ares_library_init_android()
130 (*env)->NewGlobalRef(env, connectivity_manager); in ares_library_init_android()
140 obj_cls = jni_get_class(env, "android/net/ConnectivityManager"); in ares_library_init_android()
147 env, obj_cls, "getActiveNetwork", "()Landroid/net/Network;"); in ares_library_init_android()
154 jni_get_method_id(env, obj_cls, "getLinkProperties", in ares_library_init_android()
161 (*env)->DeleteLocalRef(env, obj_cls); in ares_library_init_android()
162 obj_cls = jni_get_class(env, "android/net/LinkProperties"); in ares_library_init_android()
169 jni_get_method_id(env, obj_cls, "getDnsServers", "()Ljava/util/List;"); in ares_library_init_android()
176 jni_get_method_id(env, obj_cls, "getDomains", "()Ljava/lang/String;"); in ares_library_init_android()
181 (*env)->DeleteLocalRef(env, obj_cls); in ares_library_init_android()
182 obj_cls = jni_get_class(env, "java/util/List"); in ares_library_init_android()
187 android_list_size_mid = jni_get_method_id(env, obj_cls, "size", "()I"); in ares_library_init_android()
193 jni_get_method_id(env, obj_cls, "get", "(I)Ljava/lang/Object;"); in ares_library_init_android()
198 (*env)->DeleteLocalRef(env, obj_cls); in ares_library_init_android()
199 obj_cls = jni_get_class(env, "java/net/InetAddress"); in ares_library_init_android()
205 jni_get_method_id(env, obj_cls, "getHostAddress", "()Ljava/lang/String;"); in ares_library_init_android()
210 (*env)->DeleteLocalRef(env, obj_cls); in ares_library_init_android()
215 (*env)->DeleteLocalRef(env, obj_cls); in ares_library_init_android()
244 JNIEnv *env = NULL; in ares_library_cleanup_android() local
252 res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); in ares_library_cleanup_android()
254 env = NULL; in ares_library_cleanup_android()
255 res = jvm_attach(&env); in ares_library_cleanup_android()
258 if (res != JNI_OK || env == NULL) { in ares_library_cleanup_android()
270 (*env)->DeleteGlobalRef(env, android_connectivity_manager); in ares_library_cleanup_android()
280 JNIEnv *env = NULL; in ares_get_android_server_list() local
304 res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); in ares_get_android_server_list()
306 env = NULL; in ares_get_android_server_list()
307 res = jvm_attach(&env); in ares_get_android_server_list()
310 if (res != JNI_OK || env == NULL) { in ares_get_android_server_list()
335 active_network = (*env)->CallObjectMethod(env, android_connectivity_manager, in ares_get_android_server_list()
342 (*env)->CallObjectMethod(env, android_connectivity_manager, in ares_get_android_server_list()
349 (*env)->CallObjectMethod(env, link_properties, android_lp_dns_servers_mid); in ares_get_android_server_list()
354 nserv = (*env)->CallIntMethod(env, server_list, android_list_size_mid); in ares_get_android_server_list()
367 (*env)->CallObjectMethod(env, server_list, android_list_get_mid, (jint)i); in ares_get_android_server_list()
373 str = (*env)->CallObjectMethod(env, server, android_ia_host_addr_mid); in ares_get_android_server_list()
374 ch_server_address = (*env)->GetStringUTFChars(env, str, 0); in ares_get_android_server_list()
376 (*env)->ReleaseStringUTFChars(env, str, ch_server_address); in ares_get_android_server_list()
377 (*env)->DeleteLocalRef(env, str); in ares_get_android_server_list()
378 (*env)->DeleteLocalRef(env, server); in ares_get_android_server_list()
382 if ((*env)->ExceptionOccurred(env)) { in ares_get_android_server_list()
383 (*env)->ExceptionClear(env); in ares_get_android_server_list()
387 (*env)->DeleteLocalRef(env, server_list); in ares_get_android_server_list()
390 (*env)->DeleteLocalRef(env, link_properties); in ares_get_android_server_list()
393 (*env)->DeleteLocalRef(env, active_network); in ares_get_android_server_list()
404 JNIEnv *env = NULL; in ares_get_android_search_domains_list() local
422 res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); in ares_get_android_search_domains_list()
424 env = NULL; in ares_get_android_search_domains_list()
425 res = jvm_attach(&env); in ares_get_android_search_domains_list()
428 if (res != JNI_OK || env == NULL) { in ares_get_android_search_domains_list()
450 active_network = (*env)->CallObjectMethod(env, android_connectivity_manager, in ares_get_android_search_domains_list()
457 (*env)->CallObjectMethod(env, android_connectivity_manager, in ares_get_android_search_domains_list()
465 (*env)->CallObjectMethod(env, link_properties, android_lp_domains_mid); in ares_get_android_search_domains_list()
471 domain = (*env)->GetStringUTFChars(env, domains, 0); in ares_get_android_search_domains_list()
473 (*env)->ReleaseStringUTFChars(env, domains, domain); in ares_get_android_search_domains_list()
474 (*env)->DeleteLocalRef(env, domains); in ares_get_android_search_domains_list()
477 if ((*env)->ExceptionOccurred(env)) { in ares_get_android_search_domains_list()
478 (*env)->ExceptionClear(env); in ares_get_android_search_domains_list()
482 (*env)->DeleteLocalRef(env, link_properties); in ares_get_android_search_domains_list()
485 (*env)->DeleteLocalRef(env, active_network); in ares_get_android_search_domains_list()