From 2212b244e6ab02c31e84d29f1d0b4097523a41b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Fri, 6 Sep 2024 23:02:26 +0100 Subject: [PATCH] Garmin: Fix NPE on call with privacy mode on --- .../service/devices/garmin/NotificationsHandler.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/NotificationsHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/NotificationsHandler.java index 655e73976..a01079f22 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/NotificationsHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/NotificationsHandler.java @@ -76,8 +76,9 @@ public class NotificationsHandler implements MessageHandler { public NotificationUpdateMessage onSetCallState(CallSpec callSpec) { if (!enabled) return null; + final int id = StringUtils.firstNonBlank(callSpec.number, "Gadgetbridge Call").hashCode(); if (callSpec.command == CallSpec.CALL_INCOMING) { - NotificationSpec callNotificationSpec = new NotificationSpec(callSpec.number.hashCode()); + NotificationSpec callNotificationSpec = new NotificationSpec(id); callNotificationSpec.phoneNumber = callSpec.number; callNotificationSpec.sourceAppId = callSpec.sourceAppId; callNotificationSpec.title = StringUtils.isEmpty(callSpec.name) ? callSpec.number : callSpec.name; @@ -91,10 +92,8 @@ public class NotificationsHandler implements MessageHandler { return onNotification(callNotificationSpec); } else { - if (callSpec.number != null) // this happens in debug screen - return onDeleteNotification(callSpec.number.hashCode()); + return onDeleteNotification(id); } - return null; } public NotificationUpdateMessage onNotification(NotificationSpec notificationSpec) {