mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Mi Band 2: wait at least 4s before sending notification text
This fixes notification text not displaying when a short vibration pattern is set. If the notification text is sent while the icon is still visible it is not displayed. We need to wait until it disapears (about 4 seconds)
This commit is contained in:
committed by
Andreas Shimokawa
parent
501f9d8dc8
commit
00ee9b6828
+5
-2
@@ -40,14 +40,17 @@ public class Mi2NotificationStrategy extends V2NotificationStrategy<MiBand2Suppo
|
|||||||
startNotify(builder, vibrationProfile.getAlertLevel(), simpleNotification);
|
startNotify(builder, vibrationProfile.getAlertLevel(), simpleNotification);
|
||||||
BluetoothGattCharacteristic alert = getSupport().getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL);
|
BluetoothGattCharacteristic alert = getSupport().getCharacteristic(GattCharacteristic.UUID_CHARACTERISTIC_ALERT_LEVEL);
|
||||||
byte repeat = (byte) (vibrationProfile.getRepeat() * (vibrationProfile.getOnOffSequence().length / 2));
|
byte repeat = (byte) (vibrationProfile.getRepeat() * (vibrationProfile.getOnOffSequence().length / 2));
|
||||||
|
int waitDuration = 0;
|
||||||
if (repeat > 0) {
|
if (repeat > 0) {
|
||||||
short vibration = (short) vibrationProfile.getOnOffSequence()[0];
|
short vibration = (short) vibrationProfile.getOnOffSequence()[0];
|
||||||
short pause = (short) vibrationProfile.getOnOffSequence()[1];
|
short pause = (short) vibrationProfile.getOnOffSequence()[1];
|
||||||
int duration = (vibration + pause) * repeat;
|
waitDuration = (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.write(alert, new byte[]{-1, (byte) (vibration & 255), (byte) (vibration >> 8 & 255), (byte) (pause & 255), (byte) (pause >> 8 & 255), repeat});
|
||||||
builder.wait(duration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitDuration = Math.max(waitDuration, 4000);
|
||||||
|
builder.wait(waitDuration);
|
||||||
|
|
||||||
if (extraAction != null) {
|
if (extraAction != null) {
|
||||||
builder.add(extraAction);
|
builder.add(extraAction);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user