mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 09:41:15 +00:00
Actually read back RetroArch config.
onDestroy() is never called for some unknown reason, probably exit() in NDK. Even so, finish() from UI thread via JNI doesn't work either <_<.
This commit is contained in:
parent
67917bd1d8
commit
9a8147fe93
@ -132,7 +132,7 @@ public final class UserPreferences
|
|||||||
readbackBool(config, edit, "video_allow_rotate");
|
readbackBool(config, edit, "video_allow_rotate");
|
||||||
readbackBool(config, edit, "video_font_enable");
|
readbackBool(config, edit, "video_font_enable");
|
||||||
readbackBool(config, edit, "video_vsync");
|
readbackBool(config, edit, "video_vsync");
|
||||||
//readbackDouble(config, edit, "video_refresh_rate");
|
readbackString(config, edit, "video_refresh_rate");
|
||||||
|
|
||||||
// Path settings
|
// Path settings
|
||||||
readbackString(config, edit, "rgui_browser_directory");
|
readbackString(config, edit, "rgui_browser_directory");
|
||||||
|
@ -6,13 +6,7 @@ import com.retroarch.browser.preferences.util.UserPreferences;
|
|||||||
* Class which provides common methods for RetroActivity related classes.
|
* Class which provides common methods for RetroActivity related classes.
|
||||||
*/
|
*/
|
||||||
public class RetroActivityCommon extends RetroActivityLocation
|
public class RetroActivityCommon extends RetroActivityLocation
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void onDestroy()
|
|
||||||
{
|
|
||||||
UserPreferences.readbackConfigFile(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLowMemory()
|
public void onLowMemory()
|
||||||
{
|
{
|
||||||
@ -22,4 +16,12 @@ public class RetroActivityCommon extends RetroActivityLocation
|
|||||||
public void onTrimMemory(int level)
|
public void onTrimMemory(int level)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exiting cleanly from NDK seems to be nearly impossible.
|
||||||
|
// Have to use exit(0) to avoid weird things happening, even with runOnUiThread() approaches.
|
||||||
|
// Use a separate JNI function to explicitly trigger the readback.
|
||||||
|
public void onRetroArchExit()
|
||||||
|
{
|
||||||
|
UserPreferences.readbackConfigFile(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void engine_handle_cmd(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void android_app_write_cmd (void *data, int8_t cmd)
|
static inline void android_app_write_cmd(void *data, int8_t cmd)
|
||||||
{
|
{
|
||||||
struct android_app *android_app = (struct android_app*)data;
|
struct android_app *android_app = (struct android_app*)data;
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ static inline void android_app_write_cmd (void *data, int8_t cmd)
|
|||||||
RARCH_ERR("Failure writing android_app cmd: %s\n", strerror(errno));
|
RARCH_ERR("Failure writing android_app cmd: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_input (void *data, AInputQueue* inputQueue)
|
static void android_app_set_input(void *data, AInputQueue* inputQueue)
|
||||||
{
|
{
|
||||||
struct android_app *android_app = (struct android_app*)data;
|
struct android_app *android_app = (struct android_app*)data;
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ static void android_app_set_input (void *data, AInputQueue* inputQueue)
|
|||||||
slock_unlock(android_app->mutex);
|
slock_unlock(android_app->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_window (void *data, ANativeWindow* window)
|
static void android_app_set_window(void *data, ANativeWindow* window)
|
||||||
{
|
{
|
||||||
struct android_app *android_app = (struct android_app*)data;
|
struct android_app *android_app = (struct android_app*)data;
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ static void android_app_set_window (void *data, ANativeWindow* window)
|
|||||||
slock_unlock(android_app->mutex);
|
slock_unlock(android_app->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_app_set_activity_state (void *data, int8_t cmd)
|
static void android_app_set_activity_state(void *data, int8_t cmd)
|
||||||
{
|
{
|
||||||
struct android_app *android_app = (struct android_app*)data;
|
struct android_app *android_app = (struct android_app*)data;
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ static void android_app_set_activity_state (void *data, int8_t cmd)
|
|||||||
|
|
||||||
static void onDestroy(ANativeActivity* activity)
|
static void onDestroy(ANativeActivity* activity)
|
||||||
{
|
{
|
||||||
struct android_app* android_app = (struct android_app*)activity->instance;
|
struct android_app *android_app = (struct android_app*)activity->instance;
|
||||||
|
|
||||||
if (!android_app)
|
if (!android_app)
|
||||||
return;
|
return;
|
||||||
@ -256,7 +256,7 @@ static void onStop(ANativeActivity* activity)
|
|||||||
android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP);
|
android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onConfigurationChanged (ANativeActivity *activity)
|
static void onConfigurationChanged(ANativeActivity *activity)
|
||||||
{
|
{
|
||||||
struct android_app* android_app = (struct android_app*)activity->instance;
|
struct android_app* android_app = (struct android_app*)activity->instance;
|
||||||
|
|
||||||
@ -317,7 +317,8 @@ JNIEnv *jni_thread_getenv(void)
|
|||||||
static void jni_thread_destruct(void *value)
|
static void jni_thread_destruct(void *value)
|
||||||
{
|
{
|
||||||
JNIEnv *env = (JNIEnv*)value;
|
JNIEnv *env = (JNIEnv*)value;
|
||||||
struct android_app* android_app = (struct android_app*)g_android;
|
struct android_app *android_app = (struct android_app*)g_android;
|
||||||
|
RARCH_LOG("jni_thread_destruct()\n");
|
||||||
|
|
||||||
if (!env)
|
if (!env)
|
||||||
return;
|
return;
|
||||||
@ -371,8 +372,8 @@ void ANativeActivity_onCreate(ANativeActivity* activity,
|
|||||||
memset(android_app, 0, sizeof(struct android_app));
|
memset(android_app, 0, sizeof(struct android_app));
|
||||||
android_app->activity = activity;
|
android_app->activity = activity;
|
||||||
|
|
||||||
android_app->mutex = (slock_t*)slock_new();
|
android_app->mutex = slock_new();
|
||||||
android_app->cond = (scond_t*)scond_new();
|
android_app->cond = scond_new();
|
||||||
|
|
||||||
if (pipe(msgpipe))
|
if (pipe(msgpipe))
|
||||||
{
|
{
|
||||||
@ -382,7 +383,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity,
|
|||||||
android_app->msgread = msgpipe[0];
|
android_app->msgread = msgpipe[0];
|
||||||
android_app->msgwrite = msgpipe[1];
|
android_app->msgwrite = msgpipe[1];
|
||||||
|
|
||||||
android_app->thread = (sthread_t*)sthread_create(android_app_entry, android_app);
|
android_app->thread = sthread_create(android_app_entry, android_app);
|
||||||
|
|
||||||
// Wait for thread to start.
|
// Wait for thread to start.
|
||||||
slock_lock(android_app->mutex);
|
slock_lock(android_app->mutex);
|
||||||
@ -393,7 +394,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity,
|
|||||||
activity->instance = android_app;
|
activity->instance = android_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool android_run_events (void *data)
|
static bool android_run_events(void *data)
|
||||||
{
|
{
|
||||||
int id = ALooper_pollOnce(-1, NULL, NULL, NULL);
|
int id = ALooper_pollOnce(-1, NULL, NULL, NULL);
|
||||||
|
|
||||||
@ -742,6 +743,7 @@ static void frontend_android_init(void *data)
|
|||||||
|
|
||||||
GET_OBJECT_CLASS(env, class, android_app->activity->clazz);
|
GET_OBJECT_CLASS(env, class, android_app->activity->clazz);
|
||||||
GET_METHOD_ID(env, android_app->getIntent, class, "getIntent", "()Landroid/content/Intent;");
|
GET_METHOD_ID(env, android_app->getIntent, class, "getIntent", "()Landroid/content/Intent;");
|
||||||
|
GET_METHOD_ID(env, android_app->onRetroArchExit, class, "onRetroArchExit", "()V");
|
||||||
CALL_OBJ_METHOD(env, obj, android_app->activity->clazz, android_app->getIntent);
|
CALL_OBJ_METHOD(env, obj, android_app->activity->clazz, android_app->getIntent);
|
||||||
#if 0
|
#if 0
|
||||||
GET_METHOD_ID(env, android_app->hasPendingIntent, class, "hasPendingIntent", "()Z");
|
GET_METHOD_ID(env, android_app->hasPendingIntent, class, "hasPendingIntent", "()Z");
|
||||||
@ -762,7 +764,7 @@ static void frontend_android_init(void *data)
|
|||||||
|
|
||||||
static void frontend_android_deinit(void *data)
|
static void frontend_android_deinit(void *data)
|
||||||
{
|
{
|
||||||
struct android_app* android_app = (struct android_app*)data;
|
struct android_app *android_app = (struct android_app*)data;
|
||||||
|
|
||||||
if (!android_app)
|
if (!android_app)
|
||||||
return;
|
return;
|
||||||
@ -770,6 +772,10 @@ static void frontend_android_deinit(void *data)
|
|||||||
RARCH_LOG("Deinitializing RetroArch ...\n");
|
RARCH_LOG("Deinitializing RetroArch ...\n");
|
||||||
android_app->activityState = APP_CMD_DEAD;
|
android_app->activityState = APP_CMD_DEAD;
|
||||||
|
|
||||||
|
JNIEnv *env = jni_thread_getenv();
|
||||||
|
if (env && android_app->onRetroArchExit)
|
||||||
|
CALL_VOID_METHOD(env, android_app->activity->clazz, android_app->onRetroArchExit);
|
||||||
|
|
||||||
if (android_app->inputQueue)
|
if (android_app->inputQueue)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Detaching Android input queue looper ...\n");
|
RARCH_LOG("Detaching Android input queue looper ...\n");
|
||||||
@ -780,13 +786,10 @@ static void frontend_android_deinit(void *data)
|
|||||||
static void frontend_android_shutdown(bool unused)
|
static void frontend_android_shutdown(bool unused)
|
||||||
{
|
{
|
||||||
(void)unused;
|
(void)unused;
|
||||||
// exit() here is nasty.
|
// Cleaner approaches don't work sadly.
|
||||||
// pthread_exit(NULL) or return NULL; causes hanging ...
|
|
||||||
// Should probably call ANativeActivity_finish(), but it's bugged, it will hang our app.
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int frontend_android_get_rating(void)
|
static int frontend_android_get_rating(void)
|
||||||
{
|
{
|
||||||
char device_model[PROP_VALUE_MAX];
|
char device_model[PROP_VALUE_MAX];
|
||||||
|
@ -49,6 +49,7 @@ struct android_app
|
|||||||
sthread_t *thread;
|
sthread_t *thread;
|
||||||
char current_ime[PATH_MAX];
|
char current_ime[PATH_MAX];
|
||||||
jmethodID getIntent;
|
jmethodID getIntent;
|
||||||
|
jmethodID onRetroArchExit;
|
||||||
jmethodID getStringExtra;
|
jmethodID getStringExtra;
|
||||||
jmethodID clearPendingIntent;
|
jmethodID clearPendingIntent;
|
||||||
jmethodID hasPendingIntent;
|
jmethodID hasPendingIntent;
|
||||||
|
Loading…
Reference in New Issue
Block a user