fix calendar synchronization (#4403)

Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/4403
Co-authored-by: DeLoooping <cj-codeberg@loooping.de>
Co-committed-by: DeLoooping <cj-codeberg@loooping.de>
This commit is contained in:
DeLoooping 2024-12-14 15:53:55 +00:00 committed by José Rebelo
parent 624deee7bc
commit 59caecf717

View File

@ -18,6 +18,8 @@
package nodomain.freeyourgadget.gadgetbridge.externalevents;
import static androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@ -28,7 +30,7 @@ import android.os.Handler;
import android.provider.CalendarContract;
import android.widget.Toast;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.core.content.ContextCompat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -110,7 +112,7 @@ public class CalendarReceiver extends ContentObserver {
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)
LocalBroadcastManager.getInstance(mContext).registerReceiver(mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC));
ContextCompat.registerReceiver(mContext, mForceSyncReceiver, new IntentFilter(ACTION_FORCE_SYNC), RECEIVER_NOT_EXPORTED);
}
public GBDevice getGBDevice() {
@ -265,7 +267,7 @@ public class CalendarReceiver extends ContentObserver {
public void dispose() {
mContext.getContentResolver().unregisterContentObserver(this);
LocalBroadcastManager.getInstance(mContext).unregisterReceiver(mForceSyncReceiver);
mContext.unregisterReceiver(mForceSyncReceiver);
mSyncHandler.removeCallbacksAndMessages(null);
}