1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

clean: remove unused slots in calander for huami devices

If an event is deleted, it may still remain on the device without this
change
This commit is contained in:
Robbert Gurdeep Singh 2021-03-06 21:52:06 +01:00 committed by Gitea
parent b79e24c0d0
commit 2d7bd6ae7b

View File

@ -1865,13 +1865,14 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
Calendar calendar = Calendar.getInstance();
int iteration = 0;
int iterationMax = 8;
for (CalendarEvents.CalendarEvent calendarEvent : calendarEvents) {
if (calendarEvent.isAllDay()) {
continue;
}
if (iteration > 8) { // limit ?
if (iteration > iterationMax) { // limit ?
break;
}
@ -1903,6 +1904,19 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
iteration++;
}
// Continue by deleting the events
for(;iteration < iterationMax; iteration++){
int length = 1 + 1 + 4 + 6 + 6 + 1 + 0 + 1;
ByteBuffer buf = ByteBuffer.allocate(length);
buf.order(ByteOrder.LITTLE_ENDIAN);
buf.put((byte) 0x0b); // always 0x0b?
buf.put((byte) iteration); // id
buf.putInt(0x08); // flags 0x01 = enable, 0x04 = end date present, 0x08 = has text
buf.put(new byte[6 + 6 + 1 + 1]); // default value is 0
writeToChunked(builder, 2, buf.array());
}
return this;
}