From e38ff9960780ddae420593f7560f23fa68d9e675 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 21 Aug 2024 20:27:43 -0400 Subject: [PATCH] Special treatment to make TXT record lookup work on android. --- GNUmakefile | 3 ++- src/android/AndroidManifest.xml | 1 + .../unprompted/tildefriends/TildeFriendsActivity.java | 9 +++++++-- src/main.c | 9 +++++++-- src/ssb.c | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index a34c1b04..136bfbec 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -168,7 +168,8 @@ $(ANDROID_TARGETS): CFLAGS += \ -fdebug-compilation-dir . \ -fomit-frame-pointer \ -fno-asynchronous-unwind-tables \ - -funwind-tables + -funwind-tables \ + -Wno-unknown-warning-option $(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og $(RELEASE_TARGETS): CFLAGS += \ diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml index 0fbe5cbc..ab30b5cd 100644 --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.unprompted.tildefriends" android:versionCode="26" android:versionName="0.0.22-wip"> + CallStaticVoidMethod(s_jni_env, c, stop_sandbox); } -static jint _tf_server_main(JNIEnv* env, jobject this_object, jstring files_dir, jstring apk_path, jstring out_port_file_path) +static jint _tf_server_main(JNIEnv* env, jobject this_object, jstring files_dir, jstring apk_path, jstring out_port_file_path, jobject connectivity_manager) { s_jni_env = env; @@ -758,6 +759,8 @@ static jint _tf_server_main(JNIEnv* env, jobject this_object, jstring files_dir, _startup(0, (char*[]) { NULL }); tf_printf("That was startup.\n"); + ares_library_init_android(connectivity_manager); + const char* files = (*env)->GetStringUTFChars(env, files_dir, NULL); const char* apk = (*env)->GetStringUTFChars(env, apk_path, NULL); const char* out_port_file = (*env)->GetStringUTFChars(env, out_port_file_path, NULL); @@ -846,7 +849,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) tf_printf("Registering method.\n"); static const JNINativeMethod methods[] = { - { "tf_server_main", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I", _tf_server_main }, + { "tf_server_main", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/net/ConnectivityManager;)I", _tf_server_main }, { "tf_sandbox_main", "(I)I", _tf_sandbox_main }, }; int result = (*env)->RegisterNatives(env, c, methods, (int)_countof(methods)); @@ -855,6 +858,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) return result; } + ares_library_init_jvm(vm); + tf_printf("Done.\n"); return JNI_VERSION_1_6; } diff --git a/src/ssb.c b/src/ssb.c index 1c7cd8fd..1fc416b7 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -78,7 +78,7 @@ enum k_debug_close_message_count = 256, k_debug_close_connection_count = 32, k_seed_expire_seconds = 10 * 60, - k_seed_check_interval_seconds = 5 * 50, + k_seed_check_interval_seconds = 5 * 60, k_udp_discovery_expires_seconds = 10, };