Fix CalendarEventTest

This commit is contained in:
José Rebelo 2024-12-22 10:01:34 +00:00
parent 1cd30c29c6
commit 3be49090b1
2 changed files with 7 additions and 7 deletions

View File

@ -109,10 +109,6 @@ public class CalendarReceiver extends ContentObserver {
scheduleSync();
}
};
mContext.getContentResolver().registerContentObserver(CalendarContract.Events.CONTENT_URI, true, this);
// Add a receiver to allow us to quickly force as calendar sync (without having to provide data)
ContextCompat.registerReceiver(mContext, mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC), RECEIVER_NOT_EXPORTED);
}
public GBDevice getGBDevice() {
@ -265,6 +261,12 @@ public class CalendarReceiver extends ContentObserver {
}
}
public void registerBroadcastReceivers() {
mContext.getContentResolver().registerContentObserver(CalendarContract.Events.CONTENT_URI, true, this);
// Add a receiver to allow us to quickly force as calendar sync (without having to provide data)
ContextCompat.registerReceiver(mContext, mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC), RECEIVER_NOT_EXPORTED);
}
public void dispose() {
mContext.getContentResolver().unregisterContentObserver(this);
mContext.unregisterReceiver(mForceSyncReceiver);

View File

@ -87,7 +87,6 @@ import nodomain.freeyourgadget.gadgetbridge.externalevents.TinyWeatherForecastGe
import nodomain.freeyourgadget.gadgetbridge.externalevents.gps.GBLocationService;
import nodomain.freeyourgadget.gadgetbridge.externalevents.sleepasandroid.SleepAsAndroidReceiver;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceMusic;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
@ -102,9 +101,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import nodomain.freeyourgadget.gadgetbridge.model.Reminder;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.model.WorldClock;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLEScanService;
import nodomain.freeyourgadget.gadgetbridge.service.btle.BleIntentApi;
import nodomain.freeyourgadget.gadgetbridge.service.receivers.AutoConnectIntervalReceiver;
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBAutoFetchReceiver;
import nodomain.freeyourgadget.gadgetbridge.util.EmojiConverter;
@ -1325,6 +1322,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
if (!deviceHasCalendarReceiverRegistered(deviceWithCalendar)) {
if (!(GBApplication.isRunningMarshmallowOrLater() && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_DENIED)) {
CalendarReceiver receiver = new CalendarReceiver(this, deviceWithCalendar);
receiver.registerBroadcastReceivers();
mCalendarReceiver.add(receiver);
}
}