From b36fe52a65819bb5f2660ac26f0bf0bae34cc00b Mon Sep 17 00:00:00 2001 From: Dmitry Markin Date: Sun, 19 Jan 2020 20:15:13 +0300 Subject: [PATCH] Mi Band 2: properly stop a call notification when text notifications are disabled --- .../devices/huami/miband2/Mi2NotificationStrategy.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband2/Mi2NotificationStrategy.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband2/Mi2NotificationStrategy.java index 6924f0eaa..52b0fad20 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband2/Mi2NotificationStrategy.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband2/Mi2NotificationStrategy.java @@ -24,6 +24,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile; import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; +import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory; import nodomain.freeyourgadget.gadgetbridge.service.devices.common.SimpleNotification; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.V2NotificationStrategy; @@ -50,8 +51,11 @@ public class Mi2NotificationStrategy extends V2NotificationStrategy> 8 & 255), (byte) (pause & 255), (byte) (pause >> 8 & 255), repeat}); } - waitDuration = Math.max(waitDuration, 4000); - builder.wait(waitDuration); + // Don't wait during an incoming call, otherwise we'll not be able to stop the call notification + if (simpleNotification == null || simpleNotification.getAlertCategory() != AlertCategory.IncomingCall) { + waitDuration = Math.max(waitDuration, 4000); + builder.wait(waitDuration); + } if (extraAction != null) { builder.add(extraAction);