diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java index acc04e2d1..0f7f66763 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBandSupport.java @@ -171,6 +171,10 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport { } private NotificationStrategy getNotificationStrategy() { + if (mDeviceInfo == null) { + // not initialized yet? + return new NoNotifcationStrategy(); + } if (mDeviceInfo.getFirmwareVersion() < MiBandFWHelper.FW_16779790) { return new V1NotificationStrategy(this); } else { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/NoNotifcationStrategy.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/NoNotifcationStrategy.java new file mode 100644 index 000000000..26a45d4db --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/NoNotifcationStrategy.java @@ -0,0 +1,25 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.miband; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile; +import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction; +import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; + +/** + * Does not do anything. + */ +public class NoNotifcationStrategy implements NotificationStrategy { + private static final Logger LOG = LoggerFactory.getLogger(NoNotifcationStrategy.class); + + @Override + public void sendDefaultNotification(TransactionBuilder builder, BtLEAction extraAction) { + LOG.info("dummy notification stragegy: default notification"); + } + + @Override + public void sendCustomNotification(VibrationProfile vibrationProfile, int flashTimes, int flashColour, int originalColour, long flashDuration, BtLEAction extraAction, TransactionBuilder builder) { + LOG.info("dummy notification stragegy: custom notification"); + } +}