implement Google Cloud Messaging using DBus activatable GActions

This needs https://gitlab.com/android_translation_layer/gcm_service running in the
background.
For D-Bus activation, a D-Bus service file needs to be manually
installed under ~/.local/share/dbus-1/services.

Tested with FCM-Toolbox app.
This commit is contained in:
Julian Winkler
2025-07-28 23:01:58 +02:00
parent 9de9158699
commit f7a29d8731
10 changed files with 152 additions and 5 deletions

View File

@@ -175,3 +175,18 @@ JNIEXPORT void JNICALL Java_android_content_Context_nativeRegisterUnifiedPush(JN
(*env)->ReleaseStringUTFChars(env, token_jstr, token);
(*env)->ReleaseStringUTFChars(env, application_jstr, application);
}
JNIEXPORT void JNICALL Java_android_content_Context_nativeStartExternalService(JNIEnv *env, jclass this, jstring package_jstr, jobject intent)
{
GVariant *variant = intent_serialize(env, intent);
const char *package = (*env)->GetStringUTFChars(env, package_jstr, NULL);
char *object_path = g_strdup_printf("/%s", package);
g_strdelimit(object_path, ".", '/');
GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
GActionGroup *action_group = G_ACTION_GROUP(g_dbus_action_group_get(connection, package, object_path));
g_action_group_activate_action(action_group, "startService", variant);
g_object_unref(action_group);
g_object_unref(connection);
g_free(object_path);
(*env)->ReleaseStringUTFChars(env, package_jstr, package);
}