mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-26 01:00:52 +02:00
Pebble: do not start calendar event listener at all when calendar access is denied
Fixes #678
This commit is contained in:
parent
805a38ae3c
commit
bbbb9dd448
@ -18,6 +18,7 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service;
|
package nodomain.freeyourgadget.gadgetbridge.service;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@ -27,9 +28,11 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -584,12 +587,14 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
|
|
||||||
if (enable && initialized && coordinator != null && coordinator.supportsCalendarEvents()) {
|
if (enable && initialized && coordinator != null && coordinator.supportsCalendarEvents()) {
|
||||||
if (mCalendarReceiver == null && getPrefs().getBoolean("enable_calendar_sync", true)) {
|
if (mCalendarReceiver == null && getPrefs().getBoolean("enable_calendar_sync", true)) {
|
||||||
IntentFilter calendarIntentFilter = new IntentFilter();
|
if (!(GBApplication.isRunningMarshmallowOrLater() && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_DENIED)) {
|
||||||
calendarIntentFilter.addAction("android.intent.action.PROVIDER_CHANGED");
|
IntentFilter calendarIntentFilter = new IntentFilter();
|
||||||
calendarIntentFilter.addDataScheme("content");
|
calendarIntentFilter.addAction("android.intent.action.PROVIDER_CHANGED");
|
||||||
calendarIntentFilter.addDataAuthority("com.android.calendar", null);
|
calendarIntentFilter.addDataScheme("content");
|
||||||
mCalendarReceiver = new CalendarReceiver(mGBDevice);
|
calendarIntentFilter.addDataAuthority("com.android.calendar", null);
|
||||||
registerReceiver(mCalendarReceiver, calendarIntentFilter);
|
mCalendarReceiver = new CalendarReceiver(mGBDevice);
|
||||||
|
registerReceiver(mCalendarReceiver, calendarIntentFilter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (mAlarmReceiver == null) {
|
if (mAlarmReceiver == null) {
|
||||||
mAlarmReceiver = new AlarmReceiver();
|
mAlarmReceiver = new AlarmReceiver();
|
||||||
|
Loading…
Reference in New Issue
Block a user