Now we're running enough code to respond (incorrectly) to http requests.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4207 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-03-09 00:32:42 +00:00
parent 63dcab30c3
commit bf72782c9f
4 changed files with 24 additions and 22 deletions

View File

@ -423,8 +423,8 @@ out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/libtildefrie
@cp out/androiddebug/libtildefriends.so out/apk/lib/arm64-v8a/
@cp deps/openssl/android/arm64-v8a/usr/local/lib/libssl.so out/apk/lib/arm64-v8a/
@cp deps/openssl/android/arm64-v8a/usr/local/lib/libcrypto.so out/apk/lib/arm64-v8a/
$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/
zip -u $@ -r $(PACKAGE_DIRS)
@$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/
@zip -u $@ -q -r $(PACKAGE_DIRS)
out/TildeFriends.apk: out/TildeFriends.unsigned.apk
@echo [apksigner] $(notdir $@)

View File

@ -14,12 +14,10 @@ public class MainActivity extends Activity {
Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString()));
Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
Log.w("tildefriends", String.format("getPackageCodePath() is %s", getPackageCodePath().toString()));
setFilesPath(getFilesDir().toString());
text.setText(getMessage());
setFilesPath(getFilesDir().toString(), getPackageResourcePath().toString());
}
public native String getMessage();
public native void setFilesPath(String path);
public native void setFilesPath(String files_path, String apk_path);
static {
System.loadLibrary("tildefriends");

View File

@ -4,19 +4,20 @@
#include <jni.h>
#include <unistd.h>
void tf_android();
void tf_android(const char* apk_path);
JNIEXPORT jstring JNICALL Java_com_unprompted_tildefriends_MainActivity_getMessage(JNIEnv* env, jobject obj)
{
tf_android();
return (*env)->NewStringUTF(env, "Hello!");
}
JNIEXPORT void JNICALL Java_com_unprompted_tildefriends_MainActivity_setFilesPath( JNIEnv* env, jobject obj, jstring path)
JNIEXPORT void JNICALL Java_com_unprompted_tildefriends_MainActivity_setFilesPath(JNIEnv* env, jobject obj, jstring files_path, jstring apk_path)
{
tf_printf("setFilesPath called.\n");
const char* file_path = (*env)->GetStringUTFChars(obj, path, NULL);
int result = chdir(file_path);
tf_printf("chdir %s => %d\n", file_path, result);
const char* path_string = (*env)->GetStringUTFChars(env, files_path, NULL);
tf_printf("files_path = %s\n", path_string);
int result = chdir(path_string);
tf_printf("chdir %s => %d\n", path_string, result);
(*env)->ReleaseStringUTFChars(env, files_path, path_string);
const char* apk_path_string = (*env)->GetStringUTFChars(env, apk_path, NULL);
tf_printf("apk = %s\n", apk_path_string);
tf_android(apk_path_string);
(*env)->ReleaseStringUTFChars(env, apk_path, apk_path_string);
}
#endif

View File

@ -340,6 +340,7 @@ static int _tf_run_task(const tf_run_args_t* args, int index)
int result = -1;
tf_task_t* task = tf_task_create();
tf_task_set_trusted(task, true);
tf_printf("setting zip path to %s\n", args->zip);
tf_task_set_zip_path(task, args->zip);
tf_task_set_ssb_port(task, args->ssb_port ? args->ssb_port + index : 0);
tf_task_set_http_port(task, args->http_port ? args->http_port + index : 0);
@ -740,14 +741,16 @@ done:
static void _tf_android_thread(void* user_data)
{
char* args[] = { "tildefriends", "run" };
char* apk_path = user_data;
char* args[] = { "tildefriends", "run", "-z", apk_path };
main(_countof(args), args);
tf_free(apk_path);
}
void tf_android()
void tf_android(const char* apk_path)
{
uv_thread_t thread_id = 0;
tf_printf("TEST: Starting a thread.\n");
uv_thread_create(&thread_id, _tf_android_thread, NULL);
tf_printf("TEST: Post-thread start.\n");
tf_printf("Starting a thread.\n");
uv_thread_create(&thread_id, _tf_android_thread, tf_strdup(apk_path));
tf_printf("Post-thread start.\n");
}