1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 20:10:15 +02:00

Xiaomi: Dismiss notification from phone when dismiss from watch

This commit is contained in:
José Rebelo 2023-10-28 14:56:55 +01:00
parent ff2a26756f
commit 3948f95505
2 changed files with 13 additions and 0 deletions

View File

@ -785,6 +785,9 @@ public class NotificationListener extends NotificationListenerService {
// Clean up removed notifications from internal list // Clean up removed notifications from internal list
notificationsActive.removeAll(notificationsToRemove); notificationsActive.removeAll(notificationsToRemove);
// TODO prevent this from being called multiple times for the same ID
// TODO prevent thins from being called form notifications removed from the device
// Send notification remove request to device // Send notification remove request to device
List<GBDevice> devices = GBApplication.app().getDeviceManager().getDevices(); List<GBDevice> devices = GBApplication.app().getDeviceManager().getDevices();
for (GBDevice device : devices) { for (GBDevice device : devices) {

View File

@ -34,6 +34,7 @@ import java.util.Locale;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
@ -73,8 +74,16 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
@Override @Override
public void handleCommand(final XiaomiProto.Command cmd) { public void handleCommand(final XiaomiProto.Command cmd) {
final GBDeviceEventCallControl deviceEvtCallControl = new GBDeviceEventCallControl(); final GBDeviceEventCallControl deviceEvtCallControl = new GBDeviceEventCallControl();
final GBDeviceEventNotificationControl deviceEvtNotificationControl = new GBDeviceEventNotificationControl();
switch (cmd.getSubtype()) { switch (cmd.getSubtype()) {
case CMD_NOTIFICATION_DISMISS:
final int dismissNotificationId = cmd.getNotification().getNotification4().getNotificationId().getId();
LOG.info("Watch dismiss notification {}", dismissNotificationId);
deviceEvtNotificationControl.handle = dismissNotificationId;
deviceEvtNotificationControl.event = GBDeviceEventNotificationControl.Event.DISMISS;
getSupport().evaluateGBDeviceEvent(deviceEvtNotificationControl);
return;
case CMD_CALL_REJECT: case CMD_CALL_REJECT:
LOG.debug("Reject call"); LOG.debug("Reject call");
deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT; deviceEvtCallControl.event = GBDeviceEventCallControl.Event.REJECT;
@ -304,6 +313,7 @@ public class XiaomiNotificationService extends AbstractXiaomiService implements
final Drawable icon = NotificationUtils.getAppIcon(getSupport().getContext(), iconPackageName); final Drawable icon = NotificationUtils.getAppIcon(getSupport().getContext(), iconPackageName);
if (icon == null) { if (icon == null) {
// FIXME the packageName is sometimes truncated
LOG.warn("Failed to get icon for {}", iconPackageName); LOG.warn("Failed to get icon for {}", iconPackageName);
return; return;
} }