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 cb2754f90..b8c0a082e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -35,6 +35,7 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; import android.media.session.MediaController; import android.media.session.MediaSession; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; @@ -383,6 +384,12 @@ public class NotificationListener extends NotificationListenerService { notificationSpec.type = AppNotificationType.getInstance().get(source); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + notificationSpec.channelId = notification.getChannelId(); + } + + notificationSpec.category = notification.category; + //FIXME: some quirks lookup table would be the minor evil here if (source.startsWith("com.fsck.k9")) { if (NotificationCompat.isGroupSummary(notification)) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java index b88bd98ed..198b0033f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java @@ -180,7 +180,9 @@ public class GBDeviceService implements DeviceService { .putExtra(EXTRA_NOTIFICATION_SOURCEAPPID, notificationSpec.sourceAppId) .putExtra(EXTRA_NOTIFICATION_ICONID, notificationSpec.iconId) .putExtra(NOTIFICATION_PICTURE_PATH, notificationSpec.picturePath) - .putExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, notificationSpec.dndSuppressed); + .putExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, notificationSpec.dndSuppressed) + .putExtra(EXTRA_NOTIFICATION_CHANNEL_ID, notificationSpec.channelId) + .putExtra(EXTRA_NOTIFICATION_CATEGORY, notificationSpec.category); invokeService(intent); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java index 1379eee48..9dc6b5aba 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceService.java @@ -101,6 +101,8 @@ public interface DeviceService extends EventHandler { String EXTRA_NOTIFICATION_ICONID = "notification_iconid"; String NOTIFICATION_PICTURE_PATH = "notification_picture_path"; String EXTRA_NOTIFICATION_DNDSUPPRESSED = "notification_dndsuppressed"; + String EXTRA_NOTIFICATION_CHANNEL_ID = "notification_channel_id"; + String EXTRA_NOTIFICATION_CATEGORY = "notification_category"; String EXTRA_FIND_START = "find_start"; String EXTRA_VIBRATION_INTENSITY = "vibration_intensity"; String EXTRA_CALL_COMMAND = "call_command"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/NotificationSpec.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/NotificationSpec.java index 778d4c7f6..30061ff3d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/NotificationSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/NotificationSpec.java @@ -34,6 +34,8 @@ public class NotificationSpec { public String body; public NotificationType type; public String sourceName; + public String channelId; + public String category; public String[] cannedReplies; /** * Wearable actions that were attached to the incoming notifications and will be passed to the gadget (includes the "reply" action) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index f30b2c2e4..a63f94be7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -864,6 +864,8 @@ public class DeviceCommunicationService extends Service implements SharedPrefere notificationSpec.iconId = intentCopy.getIntExtra(EXTRA_NOTIFICATION_ICONID, 0); notificationSpec.picturePath = intent.getStringExtra(NOTIFICATION_PICTURE_PATH); notificationSpec.dndSuppressed = intentCopy.getIntExtra(EXTRA_NOTIFICATION_DNDSUPPRESSED, 0); + notificationSpec.channelId = intentCopy.getStringExtra(EXTRA_NOTIFICATION_CHANNEL_ID); + notificationSpec.category = intentCopy.getStringExtra(EXTRA_NOTIFICATION_CATEGORY); if (notificationSpec.type == NotificationType.GENERIC_SMS && notificationSpec.phoneNumber != null) { GBApplication.getIDSenderLookup().add(notificationSpec.getId(), notificationSpec.phoneNumber);