Fixed crash when exiting settings while service is running

This commit is contained in:
jens 2024-05-23 16:02:58 +02:00
parent 8788a89e48
commit eb893a7f21
3 changed files with 8 additions and 4 deletions

View File

@ -321,6 +321,8 @@ public class AutomationService extends Service implements OnInitListener
ReceiverCoordinator.applySettingsAndRules(); ReceiverCoordinator.applySettingsAndRules();
DateTimeListener.setOrResetAlarms(); DateTimeListener.setOrResetAlarms();
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance()))
CalendarReceiver.armOrRearmTimer(); CalendarReceiver.armOrRearmTimer();
} }

View File

@ -1,5 +1,6 @@
package com.jens.automation2; package com.jens.automation2;
import android.Manifest;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
@ -212,7 +213,7 @@ public class ReceiverCoordinator
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance()); ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance());
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance()))
CalendarReceiver.startCalendarReceiver(AutomationService.getInstance()); CalendarReceiver.startCalendarReceiver(AutomationService.getInstance());
} }
@ -469,7 +470,7 @@ public class ReceiverCoordinator
} }
} }
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent)) if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.calendarEvent) && ActivityPermissions.isPermissionDeclaratedInManifest(AutomationService.getInstance(), Manifest.permission.READ_CALENDAR) && ActivityPermissions.havePermission(Manifest.permission.READ_CALENDAR, AutomationService.getInstance()))
{ {
if(!CalendarReceiver.getInstance().isListenerRunning()) if(!CalendarReceiver.getInstance().isListenerRunning())
CalendarReceiver.getInstance().startListener(AutomationService.getInstance()); CalendarReceiver.getInstance().startListener(AutomationService.getInstance());

View File

@ -1,2 +1,3 @@
* Fixed: Calendar trigger hidden from Play version * Fixed: Calendar trigger hidden from Play version
* Fixed: Parameters not correctly supplied when starting other apps * Fixed: Parameters not correctly supplied when starting other apps
* Fixed: Crash when exiting settings while service is running