From 23f0443e71a567fe53a77d49c236f4b742b08914 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Sat, 19 Jul 2025 22:37:07 +0300 Subject: [PATCH] NotificationListener: use either EXTRA_TEXT or EXTRA_TITLE for VoIP calls --- .../externalevents/NotificationListener.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index 6ce8a514a8..056ebf58be 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -144,6 +144,11 @@ public class NotificationListener extends NotificationListenerService { add("org.fossify.phone"); }}; + private static final Set NOTI_USE_TITLE_APPS = new HashSet() {{ + add("com.whatsapp"); + add("org.thoughtcrime.securesms"); + }}; + public static final ArrayList notificationStack = new ArrayList<>(); private static final ArrayList notificationsActive = new ArrayList<>(); @@ -671,6 +676,8 @@ public class NotificationListener extends NotificationListenerService { // figure out sender String number = null; + String notiTitle = null; + String notiText = null; String appName = NotificationUtils.getApplicationLabel(this, app); if (noti.extras.containsKey(Notification.EXTRA_PEOPLE)) { String[] people = noti.extras.getStringArray(Notification.EXTRA_PEOPLE); @@ -686,9 +693,16 @@ public class NotificationListener extends NotificationListenerService { } } } - } else if (noti.extras.containsKey(Notification.EXTRA_TITLE)) { - number = noti.extras.getString(Notification.EXTRA_TITLE); - } else { + if (noti.extras.containsKey(Notification.EXTRA_TEXT)) { + notiText = noti.extras.getString(Notification.EXTRA_TEXT); + } + if (noti.extras.containsKey(Notification.EXTRA_TITLE)) { + notiTitle = noti.extras.getString(Notification.EXTRA_TITLE); + } + if (number == null) { + number = NOTI_USE_TITLE_APPS.contains(app) ? notiTitle : notiText; + } + if (number == null) { number = appName != null ? appName : app; } activeCallPostTime = sbn.getPostTime();