implement some APIs needed for OctoDroid

This commit is contained in:
Julian Winkler
2024-03-29 23:56:28 +01:00
parent 0352a307b9
commit 2f4cd3917f
36 changed files with 329 additions and 25 deletions

View File

@@ -113,6 +113,8 @@ void activity_close_all(void)
g_list_free(activities);
}
static jobject activity_not_created = NULL;
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
{
/* -- run the activity's onCreate -- */
@@ -120,6 +122,12 @@ void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
if((*env)->ExceptionCheck(env))
(*env)->ExceptionDescribe(env);
if ((*env)->IsSameObject(env, activity_object, activity_not_created)) { // finish() was called before the activity was created
_UNREF(activity_not_created);
activity_not_created = NULL;
return;
}
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
else
@@ -146,9 +154,12 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobje
}
}
activity_update_current(env);
activity_close(env, this);
if (removed_activity)
if (removed_activity) {
activity_close(env, removed_activity);
_UNREF(removed_activity);
} else {
activity_not_created = _REF(this);
}
if (activity_backlog == NULL && window)
gtk_window_close(GTK_WINDOW(_PTR(window)));
}