From 669f4bcdd072af7e857977f5df1c7f7ed9565aff Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 18 Feb 2018 01:36:06 +0100 Subject: [PATCH] Mi Band 2: use native notification patterns instead of manually timed ones What we do now is: - Send a notification with the app icon - Send the vibration pattern right away (this causes the first unwanted vibration to be cancelled immediately and only the pattern is noticable, while the icon stays on screen during the vibration pattern) - (optional) send the text together with a generic sms icon This also fixes problems of text not appearing in newer firmwares when a notification pattern with repeat has been set in Mi Band settings. --- .../miband2/Mi2NotificationStrategy.java | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2NotificationStrategy.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2NotificationStrategy.java index 4ec7471f1..ca104f7e5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2NotificationStrategy.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband2/Mi2NotificationStrategy.java @@ -37,24 +37,19 @@ public class Mi2NotificationStrategy extends V2NotificationStrategy 0) { + short vibration = (short) vibrationProfile.getOnOffSequence()[0]; + short pause = (short) vibrationProfile.getOnOffSequence()[1]; + int duration = (vibration + pause) * repeat; + builder.write(alert, new byte[]{-1, (byte) (vibration & 255), (byte) (vibration >> 8 & 255), (byte) (pause & 255), (byte) (pause >> 8 & 255), repeat}); + builder.wait(duration); + } - if (++j < onOffSequence.length) { - int off = Math.max(onOffSequence[j], 25); // wait at least 25ms - builder.wait(off); - } - - if (extraAction != null) { - builder.add(extraAction); - } - } + if (extraAction != null) { + builder.add(extraAction); } }