You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
NotificationManager: implement cancel() for MPRIS notifications
This commit is contained in:
@@ -145,6 +145,7 @@ void remove_ongoing_notifications()
|
||||
}
|
||||
|
||||
static MediaPlayer2 *mpris = NULL;
|
||||
static int dbus_name_id = 0;
|
||||
extern MediaPlayer2Player *mpris_player;
|
||||
extern GtkWindow *window;
|
||||
|
||||
@@ -169,8 +170,9 @@ JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeShowMPRIS(JNIE
|
||||
if (!mpris) {
|
||||
mpris = media_player2_skeleton_new();
|
||||
g_signal_connect(mpris, "handle-raise", G_CALLBACK(on_media_player_handle_raise), NULL);
|
||||
|
||||
g_bus_own_name(G_BUS_TYPE_SESSION, MPRIS_BUS_NAME_PREFIX "ATL", G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
}
|
||||
if (!dbus_name_id) {
|
||||
dbus_name_id = g_bus_own_name(G_BUS_TYPE_SESSION, MPRIS_BUS_NAME_PREFIX "ATL", G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_bus_acquired, NULL, NULL, mpris, NULL);
|
||||
}
|
||||
media_player2_set_can_raise(mpris, TRUE);
|
||||
@@ -185,3 +187,12 @@ JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeShowMPRIS(JNIE
|
||||
(*env)->ReleaseStringUTFChars(env, identity_jstr, identity);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeCancelMPRIS(JNIEnv *env, jobject this)
|
||||
{
|
||||
if (dbus_name_id) {
|
||||
g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(mpris));
|
||||
g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(mpris_player));
|
||||
g_clear_handle_id (&dbus_name_id, g_bus_unown_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,14 @@ JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeShowMPRIS
|
||||
JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeCancel
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
/*
|
||||
* Class: android_app_NotificationManager
|
||||
* Method: nativeCancelMPRIS
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeCancelMPRIS
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user