aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/c-ares/ares_android.c
diff options
context:
space:
mode:
authordvshkurko <dvshkurko@yandex-team.ru>2022-02-10 16:45:52 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:52 +0300
commitc768a99151e47c3a4bb7b92c514d256abd301c4d (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/c-ares/ares_android.c
parent321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff)
downloadydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/c-ares/ares_android.c')
-rw-r--r--contrib/libs/c-ares/ares_android.c194
1 files changed, 97 insertions, 97 deletions
diff --git a/contrib/libs/c-ares/ares_android.c b/contrib/libs/c-ares/ares_android.c
index 750a855665..5b00b8065c 100644
--- a/contrib/libs/c-ares/ares_android.c
+++ b/contrib/libs/c-ares/ares_android.c
@@ -30,8 +30,8 @@ static jmethodID android_cm_active_net_mid = NULL;
static jmethodID android_cm_link_props_mid = NULL;
/* LinkProperties.getDnsServers */
static jmethodID android_lp_dns_servers_mid = NULL;
-/* LinkProperties.getDomains */
-static jmethodID android_lp_domains_mid = NULL;
+/* LinkProperties.getDomains */
+static jmethodID android_lp_domains_mid = NULL;
/* List.size */
static jmethodID android_list_size_mid = NULL;
/* List.get */
@@ -141,12 +141,12 @@ int ares_library_init_android(jobject connectivity_manager)
if (android_lp_dns_servers_mid == NULL)
goto cleanup;
- /* getDomains in API 21. */
- android_lp_domains_mid = jni_get_method_id(env, obj_cls, "getDomains",
- "()Ljava/lang/String;");
- if (android_lp_domains_mid == NULL)
- goto cleanup;
-
+ /* getDomains in API 21. */
+ android_lp_domains_mid = jni_get_method_id(env, obj_cls, "getDomains",
+ "()Ljava/lang/String;");
+ if (android_lp_domains_mid == NULL)
+ goto cleanup;
+
(*env)->DeleteLocalRef(env, obj_cls);
obj_cls = jni_get_class(env, "java/util/List");
if (obj_cls == NULL)
@@ -181,7 +181,7 @@ cleanup:
android_cm_active_net_mid = NULL;
android_cm_link_props_mid = NULL;
android_lp_dns_servers_mid = NULL;
- android_lp_domains_mid = NULL;
+ android_lp_domains_mid = NULL;
android_list_size_mid = NULL;
android_list_get_mid = NULL;
android_ia_host_addr_mid = NULL;
@@ -222,7 +222,7 @@ void ares_library_cleanup_android(void)
android_cm_active_net_mid = NULL;
android_cm_link_props_mid = NULL;
android_lp_dns_servers_mid = NULL;
- android_lp_domains_mid = NULL;
+ android_lp_domains_mid = NULL;
android_list_size_mid = NULL;
android_list_get_mid = NULL;
android_ia_host_addr_mid = NULL;
@@ -351,93 +351,93 @@ done:
(*android_jvm)->DetachCurrentThread(android_jvm);
return dns_list;
}
-
-char *ares_get_android_search_domains_list(void)
-{
- JNIEnv *env = NULL;
- jobject active_network = NULL;
- jobject link_properties = NULL;
- jstring domains = NULL;
- const char *domain;
- int res;
- char *domain_list = NULL;
- int need_detatch = 0;
-
- if (android_jvm == NULL || android_connectivity_manager == NULL)
- {
- return NULL;
- }
-
- if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL ||
- android_lp_domains_mid == NULL)
- {
- return NULL;
- }
-
- res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
- if (res == JNI_EDETACHED)
- {
- env = NULL;
- res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL);
- need_detatch = 1;
- }
- if (res != JNI_OK || env == NULL)
- goto done;
-
- /* JNI below is equivalent to this Java code.
- import android.content.Context;
- import android.net.ConnectivityManager;
- import android.net.LinkProperties;
-
- ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext()
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- Network an = cm.getActiveNetwork();
- LinkProperties lp = cm.getLinkProperties(an);
- String domains = lp.getDomains();
- for (String domain: domains.split(",")) {
- String d = domain;
- }
-
- Note: The JNI ConnectivityManager object and all method IDs were previously
- initialized in ares_library_init_android.
- */
-
- active_network = (*env)->CallObjectMethod(env, android_connectivity_manager,
- android_cm_active_net_mid);
- if (active_network == NULL)
- goto done;
-
- link_properties =
- (*env)->CallObjectMethod(env, android_connectivity_manager,
- android_cm_link_props_mid, active_network);
- if (link_properties == NULL)
- goto done;
-
- /* Get the domains. It is a common separated list of domains to search. */
- domains = (*env)->CallObjectMethod(env, link_properties,
- android_lp_domains_mid);
- if (domains == NULL)
- goto done;
-
- /* Split on , */
- domain = (*env)->GetStringUTFChars(env, domains, 0);
- domain_list = ares_strdup(domain);
- (*env)->ReleaseStringUTFChars(env, domains, domain);
- (*env)->DeleteLocalRef(env, domains);
-
-done:
- if ((*env)->ExceptionOccurred(env))
- (*env)->ExceptionClear(env);
-
- if (link_properties != NULL)
- (*env)->DeleteLocalRef(env, link_properties);
- if (active_network != NULL)
- (*env)->DeleteLocalRef(env, active_network);
-
- if (need_detatch)
- (*android_jvm)->DetachCurrentThread(android_jvm);
- return domain_list;
-}
+
+char *ares_get_android_search_domains_list(void)
+{
+ JNIEnv *env = NULL;
+ jobject active_network = NULL;
+ jobject link_properties = NULL;
+ jstring domains = NULL;
+ const char *domain;
+ int res;
+ char *domain_list = NULL;
+ int need_detatch = 0;
+
+ if (android_jvm == NULL || android_connectivity_manager == NULL)
+ {
+ return NULL;
+ }
+
+ if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL ||
+ android_lp_domains_mid == NULL)
+ {
+ return NULL;
+ }
+
+ res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
+ if (res == JNI_EDETACHED)
+ {
+ env = NULL;
+ res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL);
+ need_detatch = 1;
+ }
+ if (res != JNI_OK || env == NULL)
+ goto done;
+
+ /* JNI below is equivalent to this Java code.
+ import android.content.Context;
+ import android.net.ConnectivityManager;
+ import android.net.LinkProperties;
+
+ ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ Network an = cm.getActiveNetwork();
+ LinkProperties lp = cm.getLinkProperties(an);
+ String domains = lp.getDomains();
+ for (String domain: domains.split(",")) {
+ String d = domain;
+ }
+
+ Note: The JNI ConnectivityManager object and all method IDs were previously
+ initialized in ares_library_init_android.
+ */
+
+ active_network = (*env)->CallObjectMethod(env, android_connectivity_manager,
+ android_cm_active_net_mid);
+ if (active_network == NULL)
+ goto done;
+
+ link_properties =
+ (*env)->CallObjectMethod(env, android_connectivity_manager,
+ android_cm_link_props_mid, active_network);
+ if (link_properties == NULL)
+ goto done;
+
+ /* Get the domains. It is a common separated list of domains to search. */
+ domains = (*env)->CallObjectMethod(env, link_properties,
+ android_lp_domains_mid);
+ if (domains == NULL)
+ goto done;
+
+ /* Split on , */
+ domain = (*env)->GetStringUTFChars(env, domains, 0);
+ domain_list = ares_strdup(domain);
+ (*env)->ReleaseStringUTFChars(env, domains, domain);
+ (*env)->DeleteLocalRef(env, domains);
+
+done:
+ if ((*env)->ExceptionOccurred(env))
+ (*env)->ExceptionClear(env);
+
+ if (link_properties != NULL)
+ (*env)->DeleteLocalRef(env, link_properties);
+ if (active_network != NULL)
+ (*env)->DeleteLocalRef(env, active_network);
+
+ if (need_detatch)
+ (*android_jvm)->DetachCurrentThread(android_jvm);
+ return domain_list;
+}
#else
/* warning: ISO C forbids an empty translation unit */
typedef int dummy_make_iso_compilers_happy;