forked from cory/tildefriends
		
	Special treatment to make TXT record lookup work on android.
This commit is contained in:
		| @@ -168,7 +168,8 @@ $(ANDROID_TARGETS): CFLAGS += \ | |||||||
| 	-fdebug-compilation-dir . \ | 	-fdebug-compilation-dir . \ | ||||||
| 	-fomit-frame-pointer \ | 	-fomit-frame-pointer \ | ||||||
| 	-fno-asynchronous-unwind-tables \ | 	-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 | $(ANDROID_TARGETS): LDFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC | ||||||
| $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og | $(DEBUG_TARGETS): CFLAGS += -DDEBUG -Og | ||||||
| $(RELEASE_TARGETS): CFLAGS += \ | $(RELEASE_TARGETS): CFLAGS += \ | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ | |||||||
| 	package="com.unprompted.tildefriends" | 	package="com.unprompted.tildefriends" | ||||||
| 	android:versionCode="26" | 	android:versionCode="26" | ||||||
| 	android:versionName="0.0.22-wip"> | 	android:versionName="0.0.22-wip"> | ||||||
|  | 	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | ||||||
| 	<uses-permission android:name="android.permission.INTERNET"/> | 	<uses-permission android:name="android.permission.INTERNET"/> | ||||||
| 	<application | 	<application | ||||||
| 		android:label="Tilde Friends" | 		android:label="Tilde Friends" | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ import android.content.ComponentName; | |||||||
| import android.content.DialogInterface; | import android.content.DialogInterface; | ||||||
| import android.content.Intent; | import android.content.Intent; | ||||||
| import android.content.ServiceConnection; | import android.content.ServiceConnection; | ||||||
|  | import android.net.ConnectivityManager; | ||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| import android.os.Environment; | import android.os.Environment; | ||||||
| @@ -68,7 +69,7 @@ public class TildeFriendsActivity extends Activity { | |||||||
| 		Log.w("tildefriends", "system.loadLibrary() completed."); | 		Log.w("tildefriends", "system.loadLibrary() completed."); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public static native int tf_server_main(String files_dir, String apk_path, String out_port_file_path); | 	public static native int tf_server_main(String files_dir, String apk_path, String out_port_file_path, ConnectivityManager connectivity_manager); | ||||||
| 	public static native int tf_sandbox_main(int pipe_fd); | 	public static native int tf_sandbox_main(int pipe_fd); | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| @@ -150,7 +151,11 @@ public class TildeFriendsActivity extends Activity { | |||||||
| 			@Override | 			@Override | ||||||
| 			public void run() { | 			public void run() { | ||||||
| 				Log.w("tildefriends", "Calling tf_server_main."); | 				Log.w("tildefriends", "Calling tf_server_main."); | ||||||
| 				int result = tf_server_main(getFilesDir().toString(), getPackageResourcePath().toString(), port_file_path); | 				int result = tf_server_main( | ||||||
|  | 					getFilesDir().toString(), | ||||||
|  | 					getPackageResourcePath().toString(), | ||||||
|  | 					port_file_path, | ||||||
|  | 					(ConnectivityManager)getApplicationContext().getSystemService(CONNECTIVITY_SERVICE)); | ||||||
| 				Log.w("tildefriends", "tf_server_main returned " + result + "."); | 				Log.w("tildefriends", "tf_server_main returned " + result + "."); | ||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ | |||||||
| #include "tests.h" | #include "tests.h" | ||||||
| #include "util.js.h" | #include "util.js.h" | ||||||
|  |  | ||||||
|  | #include "ares.h" | ||||||
| #include "backtrace.h" | #include "backtrace.h" | ||||||
| #include "sqlite3.h" | #include "sqlite3.h" | ||||||
| #include "unzip.h" | #include "unzip.h" | ||||||
| @@ -750,7 +751,7 @@ static void _tf_service_stop() | |||||||
| 	(*s_jni_env)->CallStaticVoidMethod(s_jni_env, c, stop_sandbox); | 	(*s_jni_env)->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; | 	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 }); | 	_startup(0, (char*[]) { NULL }); | ||||||
| 	tf_printf("That was startup.\n"); | 	tf_printf("That was startup.\n"); | ||||||
|  |  | ||||||
|  | 	ares_library_init_android(connectivity_manager); | ||||||
|  |  | ||||||
| 	const char* files = (*env)->GetStringUTFChars(env, files_dir, NULL); | 	const char* files = (*env)->GetStringUTFChars(env, files_dir, NULL); | ||||||
| 	const char* apk = (*env)->GetStringUTFChars(env, apk_path, NULL); | 	const char* apk = (*env)->GetStringUTFChars(env, apk_path, NULL); | ||||||
| 	const char* out_port_file = (*env)->GetStringUTFChars(env, out_port_file_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"); | 	tf_printf("Registering method.\n"); | ||||||
| 	static const JNINativeMethod methods[] = { | 	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 }, | 		{ "tf_sandbox_main", "(I)I", _tf_sandbox_main }, | ||||||
| 	}; | 	}; | ||||||
| 	int result = (*env)->RegisterNatives(env, c, methods, (int)_countof(methods)); | 	int result = (*env)->RegisterNatives(env, c, methods, (int)_countof(methods)); | ||||||
| @@ -855,6 +858,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) | |||||||
| 		return result; | 		return result; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	ares_library_init_jvm(vm); | ||||||
|  |  | ||||||
| 	tf_printf("Done.\n"); | 	tf_printf("Done.\n"); | ||||||
| 	return JNI_VERSION_1_6; | 	return JNI_VERSION_1_6; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -78,7 +78,7 @@ enum | |||||||
| 	k_debug_close_message_count = 256, | 	k_debug_close_message_count = 256, | ||||||
| 	k_debug_close_connection_count = 32, | 	k_debug_close_connection_count = 32, | ||||||
| 	k_seed_expire_seconds = 10 * 60, | 	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, | 	k_udp_discovery_expires_seconds = 10, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user