Calendar trigger

This commit is contained in:
Jens 2024-01-06 23:57:52 +01:00
parent ec62b91449
commit eaecf63724
7 changed files with 32 additions and 16 deletions

View File

@ -373,6 +373,11 @@ public class Rule implements Comparable<Rule>
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
return true;
}
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
return true;
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
}

View File

@ -376,6 +376,11 @@ public class Rule implements Comparable<Rule>
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
return true;
}
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
return true;
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
}

View File

@ -128,7 +128,18 @@ public class AutomationService extends Service implements OnInitListener
// Store a reference to myself. Other classes often need a context or something, this can provide that.
centralInstance = this;
Miscellaneous.setDisplayLanguage(AutomationService.this);
/*
This has been reported to throw a NullPointerException under
rare circumstances. The root cause remains unknown.
*/
try
{
Miscellaneous.setDisplayLanguage(AutomationService.this);
}
catch(NullPointerException e)
{
Miscellaneous.logEvent("e", "setDisplayLanguage()", Log.getStackTraceString(e), 3);
}
}
public boolean checkStartupRequirements(Context context, boolean startAtBoot)

View File

@ -644,6 +644,12 @@ public class Trigger
// No contradictions found
Miscellaneous.logEvent("i", "CalendarCheck", "Event " + event + " matches.", 4);
/*
At this point the rule will either get executed for this event or it already has been executed for it.
*/
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(getParentRule(), event));
return true;
}
@ -756,11 +762,6 @@ public class Trigger
// No contradictions found
Miscellaneous.logEvent("i", "CalendarCheck", "Event " + event + " matches.", 4);
/*
At this point the rule will either get executed for this event or it already has been executed for it.
*/
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(getParentRule(), event));
return true;
}

View File

@ -55,7 +55,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
if(newWifiSsid.length() > 0)
{
if(!newWifiSsid.equals(unknownSsidName))
WifiBroadcastReceiver.lastWifiSsidReal = lastWifiSsid;
WifiBroadcastReceiver.lastWifiSsidReal = lastWifiSsid;
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
}

View File

@ -57,7 +57,8 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
this.event = event;
}
}
static List<RuleEventPair> calendarEventsUsed = new ArrayList<>(); // To determine for which events which rules have been executed
// To determine for which events which rules have been executed
static List<RuleEventPair> calendarEventsUsed = new ArrayList<>();
public static void addUsedPair(RuleEventPair pair)
{
// Add pair only if it's not in the list already.
@ -100,14 +101,6 @@ public class CalendarReceiver extends BroadcastReceiver implements AutomationLis
static void checkForRules(Context context)
{
/*
Kann die selbe Regel mehrfach pro Termin ausgeführt werden? Nein, eh nicht, ne?
Am nächsten Tag ist es wieder ein anderer Termin.
Wenn zwei zeitgleiche Termine mit gleichen Inhalten in verschiedenen Kalendern sind,
würde die Regel so 2x ausgeführt werden.
*/
//TODO: Second appointment directly one after another or overlapping won't get executed
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.calendarEvent);
for (int i = 0; i < ruleCandidates.size(); i++)
{

View File

@ -3,6 +3,7 @@
* Fixed: Bug in Android 14 (not in Automation!!!) required a change when dialing MMI codes containing a # character.
* Fixed: Storage permission might be displayed as not granted even if it was
* Fixed: Applied a very old bugfix also to F-Droid and Google-Play editions that had by mistake been implemented only in the APK edition (timeFrame trigger with repetitions)
* Fixed: Rare crash while starting service
* Added: new action -> take screenshot
* Added: Location service (GPS) can be toggled between states if WRITE_SECURE_SETTINGS has been granted from a computer
* Added: triggerUrl action can now be used with POST and parameters