fix in DateTimeTrigger management and executions when service already stopped

This commit is contained in:
jens 2022-04-03 16:20:20 +02:00
parent 152b0c3c49
commit 0d3a13e753
5 changed files with 10 additions and 13 deletions

View File

@ -222,6 +222,10 @@ public class ActivityControlCenter extends Activity
} }
Settings.readFromPersistentStorage(ActivityControlCenter.this); Settings.readFromPersistentStorage(ActivityControlCenter.this);
AutomationService service = AutomationService.getInstance();
if(service != null)
service.applySettingsAndRules();
} }
else else
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();

View File

@ -34,7 +34,6 @@ public class ActivityManagePoi extends Activity
public LocationManager myLocationManager; public LocationManager myLocationManager;
MyLocationListenerGps myLocationListenerGps = new MyLocationListenerGps(); MyLocationListenerGps myLocationListenerGps = new MyLocationListenerGps();
Location locationGps = null, locationNetwork = null; Location locationGps = null, locationNetwork = null;
// Location locationWifi = null;
MyLocationListenerNetwork myLocationListenerNetwork = new MyLocationListenerNetwork(); MyLocationListenerNetwork myLocationListenerNetwork = new MyLocationListenerNetwork();
Button bGetPosition, bSavePoi; Button bGetPosition, bSavePoi;
ImageButton ibShowOnMap; ImageButton ibShowOnMap;

View File

@ -50,12 +50,8 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
public void onReceive(Context context, Intent intent) public void onReceive(Context context, Intent intent)
{ {
Miscellaneous.logEvent("i", "AlarmListener", "Alarm received", 2); Miscellaneous.logEvent("i", "AlarmListener", "Alarm received", 2);
Date now = new Date();
String timeString = String.valueOf(now.getHours()) + ":" + String.valueOf(now.getMinutes()) + ":" + String.valueOf(now.getSeconds());
Time passTime = Time.valueOf(timeString);
ArrayList<Rule> allRulesWithNowInTimeFrame = Rule.findRuleCandidates(Trigger_Enum.timeFrame); ArrayList<Rule> allRulesWithNowInTimeFrame = Rule.findRuleCandidates(Trigger_Enum.timeFrame);
// ArrayList<Rule> allRulesWithNowInTimeFrame = Rule.findRuleCandidatesByTime(passTime);
for(int i=0; i<allRulesWithNowInTimeFrame.size(); i++) for(int i=0; i<allRulesWithNowInTimeFrame.size(); i++)
{ {
if(allRulesWithNowInTimeFrame.get(i).getsGreenLight(context)) if(allRulesWithNowInTimeFrame.get(i).getsGreenLight(context))
@ -385,8 +381,6 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
calSet.set(Calendar.SECOND, 0); calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0); calSet.set(Calendar.MILLISECOND, 0);
// if(this.applies(null))
// {
// If the starting time is a day ahead remove 1 day. // If the starting time is a day ahead remove 1 day.
if(calSet.getTimeInMillis() > now.getTimeInMillis()) if(calSet.getTimeInMillis() > now.getTimeInMillis())
calSet.add(Calendar.DAY_OF_MONTH, -1); calSet.add(Calendar.DAY_OF_MONTH, -1);
@ -401,11 +395,8 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
* Das war mal aktiviert. Allerdings: Die ganze Funktion liefert zurück, wenn die Regel NOCH nicht * Das war mal aktiviert. Allerdings: Die ganze Funktion liefert zurück, wenn die Regel NOCH nicht
* zutrifft, aber wir z.B. gleich den zeitlichen Bereich betreten. * zutrifft, aber wir z.B. gleich den zeitlichen Bereich betreten.
*/ */
// if(trigger.checkDateTime(calSchedule.getTime(), false))
// {
return calSchedule; return calSchedule;
// }
// }
} }
else else
Miscellaneous.logEvent("i", "DateTimeListener", "Trigger " + trigger.toString() + " is not executed repeatedly.", 5); Miscellaneous.logEvent("i", "DateTimeListener", "Trigger " + trigger.toString() + " is not executed repeatedly.", 5);

View File

@ -57,7 +57,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:ems="10"
android:inputType="numberSigned" /> android:inputType="text" />
</TableRow> </TableRow>
@ -78,7 +78,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ems="10" android:ems="10"
android:inputType="numberSigned" /> android:inputType="text" />
</TableRow> </TableRow>
<TableRow <TableRow

View File

@ -0,0 +1,3 @@
* Fixed: Management of DateTimeTrigger was sometimes releaded incorrectly while service was running
* Fixed: DateTimeTrigger: Repeated executions sometimes not working
* Fixed: DateTimeTrigger: Repeated executions continued to run after service was stopped