Fixed apps not working most of the time. Ultimately, storing a pointer to the database using JS_NewInt64 was lossy and a bad idea. Also, remove use of JNI since we're only starting tildefriends as its own process now.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4215 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-03-11 13:57:17 +00:00
parent 2a3b1a1e33
commit 10bfa65a4e
9 changed files with 19 additions and 98 deletions

View File

@ -1584,44 +1584,11 @@ static void _tf_task_trace_to_parent(tf_trace_t* trace, const char* buffer, size
tf_packetstream_send(tf_taskstub_get_stream(task->_parent), kTaskTrace, buffer, size);
}
#if defined(__ANDROID__)
static void _tf_task_extract_file(tf_task_t* task, const char* name, int mode)
{
size_t size = 0;
char path_in_zip[256];
snprintf(path_in_zip, sizeof(path_in_zip), "lib/arm64-v8a/%s", name);
const char* exe_source = _task_loadFile(task, path_in_zip, &size);
if (exe_source)
{
FILE* exe_target = fopen(name, "wb");
if (exe_target)
{
fwrite(exe_source, size, 1, exe_target);
fchmod(fileno(exe_target), mode);
fclose(exe_target);
}
else
{
tf_printf("failed to open %s for write", name);
}
tf_free((void*)exe_source);
}
else
{
tf_printf("failed to read %s source", path_in_zip);
}
}
#endif
void tf_task_activate(tf_task_t* task)
{
assert(!task->_activated);
task->_activated = true;
#if defined(__ANDROID__)
_tf_task_extract_file(task, "tildefriends", 0755);
#endif
JSContext* context = task->_context;
JSValue global = JS_GetGlobalObject(context);
JSValue e = JS_NewObject(context);
@ -1679,7 +1646,7 @@ void tf_task_activate(tf_task_t* task)
JS_SetPropertyStr(context, global, "Socket", tf_socket_register(context));
JS_SetPropertyStr(context, global, "TlsContext", tf_tls_context_register(context));
tf_file_register(context);
tf_database_register(context, task->_db);
tf_database_register(context);
task->_ssb = tf_ssb_create(&task->_loop, task->_context, task->_db_path);
tf_ssb_set_trace(task->_ssb, task->_trace);