1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 04:46:51 +01:00

Huawei: Event alarms fix

Should fix event alarms for the Huawei MagicWatch 2 (#3877).
This commit is contained in:
Martin.JM 2024-07-11 23:02:35 +02:00
parent 0946fc408b
commit d7490639af

View File

@ -29,19 +29,26 @@ public class Alarms {
public static class EventAlarm { public static class EventAlarm {
public byte index; public byte index;
public boolean status; public boolean status = false;
public byte startHour; public byte startHour = -1;
public byte startMinute; public byte startMinute = -1;
public byte repeat; public byte repeat = 0;
public String name; public String name = "Alarm";
public EventAlarm(HuaweiTLV tlv) throws ParseException { public EventAlarm(HuaweiTLV tlv) throws ParseException {
this.index = tlv.getByte(0x03); this.index = tlv.getByte(0x03);
this.status = tlv.getBoolean(0x04); if (tlv.contains(0x04))
this.startHour = (byte) ((tlv.getShort(0x05) >> 8) & 0xFF); this.status = tlv.getBoolean(0x04);
this.startMinute = (byte) (tlv.getShort(0x05) & 0xFF); if (this.status || tlv.contains(0x05)) {
this.repeat = tlv.getByte(0x06); // I think we should refuse to set the alarm to a default time if it's enabled.
this.name = tlv.getString(0x07); // If it is enabled, it should have the time set.
this.startHour = (byte) ((tlv.getShort(0x05) >> 8) & 0xFF);
this.startMinute = (byte) (tlv.getShort(0x05) & 0xFF);
}
if (tlv.contains(0x06))
this.repeat = tlv.getByte(0x06);
if (tlv.contains(0x07))
this.name = tlv.getString(0x07);
} }
public EventAlarm(byte index, boolean status, byte startHour, byte startMinute, byte repeat, String name) { public EventAlarm(byte index, boolean status, byte startHour, byte startMinute, byte repeat, String name) {