1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-12 18:57:36 +01:00

Fix possible race condition when availableSlots == 3

(There are two difficult things...)
This commit is contained in:
Daniele Gobbetti 2015-12-29 09:18:02 +01:00
parent 9ea2977143
commit 1d9e1d7caf

View File

@ -811,16 +811,17 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
int iteration = 0;
ArrayList<GBAlarm> alarmList = new ArrayList<>();
for(CalendarEvents.CalendarEvent mEvt : mEvents) {
if (iteration >= availableSlots) {
if (iteration >= availableSlots || iteration > 2) {
break;
}
int slotToUse = 2 - iteration;
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(mEvt.getBegin());
byte[] calBytes = MiBandDateConverter.calendarToRawBytes(calendar);
byte[] alarmMessage = new byte[]{
MiBandService.COMMAND_SET_TIMER,
(byte)(2-iteration),
(byte) slotToUse,
(byte) 1,
calBytes[0],
calBytes[1],