mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 19:45:50 +01:00
Zepp OS: Fix calendar sync for Zepp OS 2
This commit is contained in:
parent
d6567e553f
commit
515b9efce8
@ -34,6 +34,7 @@ import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
@ -224,4 +225,10 @@ public class CalendarReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void forceSync() {
|
||||
final Intent intent = new Intent("FORCE_CALENDAR_SYNC");
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
GBApplication.getContext().sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.BangleJSActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.CalendarSyncState;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.CalendarSyncStateDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.CalendarReceiver;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationManager;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.LocationProviderType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
@ -869,10 +870,7 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
GB.toast("Database Error while forcefully syncing Calendar", Toast.LENGTH_SHORT, GB.ERROR, e1);
|
||||
}
|
||||
//force a syncCalendar now, send missing events
|
||||
Context context = GBApplication.getContext();
|
||||
Intent intent = new Intent("FORCE_CALENDAR_SYNC");
|
||||
intent.setPackage(BuildConfig.APPLICATION_ID);
|
||||
GBApplication.getContext().sendBroadcast(intent);
|
||||
CalendarReceiver.forceSync();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,6 +81,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsGpxRouteI
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.externalevents.CalendarReceiver;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
@ -94,7 +95,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
@ -335,6 +335,7 @@ public abstract class Huami2021Support extends HuamiSupport implements ZeppOsFil
|
||||
@Override
|
||||
protected Huami2021Support sendCalendarEvents(final TransactionBuilder builder) {
|
||||
// We have native calendar sync
|
||||
CalendarReceiver.forceSync();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class ZeppOsCalendarService extends AbstractZeppOsService {
|
||||
case CMD_CAPABILITIES_RESPONSE:
|
||||
version = payload[1];
|
||||
getSupport().evaluateGBDeviceEvent(new GBDeviceEventUpdatePreferences(PREF_VERSION, version));
|
||||
if (version != 1) {
|
||||
if (version != 1 && version != 3) {
|
||||
LOG.warn("Unsupported calendar service version {}", version);
|
||||
return;
|
||||
}
|
||||
@ -121,6 +121,11 @@ public class ZeppOsCalendarService extends AbstractZeppOsService {
|
||||
length += calendarEventSpec.description.getBytes(StandardCharsets.UTF_8).length;
|
||||
}
|
||||
|
||||
if (version == 3) {
|
||||
// Extra null byte at the end
|
||||
length++;
|
||||
}
|
||||
|
||||
final ByteBuffer buf = ByteBuffer.allocate(length);
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put(CMD_CREATE_EVENT);
|
||||
@ -163,6 +168,10 @@ public class ZeppOsCalendarService extends AbstractZeppOsService {
|
||||
buf.put((byte) 0x00); // ?
|
||||
// TODO: Description here
|
||||
|
||||
if (version == 3) {
|
||||
buf.put((byte) 0x00); // ?
|
||||
}
|
||||
|
||||
write("add calendar event", buf.array());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user