bug when importing config while service is not running

This commit is contained in:
jens 2022-05-08 20:04:45 +02:00
parent 9fce7d987e
commit 52a10fe626
3 changed files with 8 additions and 13 deletions

View File

@ -252,15 +252,5 @@ public class ActivityMainRules extends ActivityGeneric
} }
catch(NullPointerException e) catch(NullPointerException e)
{} {}
try
{
if(AutomationService.isMyServiceRunning(this))
DateTimeListener.reloadAlarms();
}
catch(NullPointerException e)
{
// AlarmManager instance not prepared, yet.
}
} }
} }

View File

@ -28,6 +28,7 @@ import androidx.core.app.NotificationManagerCompat;
import com.jens.automation2.Trigger.Trigger_Enum; import com.jens.automation2.Trigger.Trigger_Enum;
import com.jens.automation2.location.LocationProvider; import com.jens.automation2.location.LocationProvider;
import com.jens.automation2.receivers.DateTimeListener;
import com.jens.automation2.receivers.PackageReplacedReceiver; import com.jens.automation2.receivers.PackageReplacedReceiver;
import com.jens.automation2.receivers.PhoneStatusListener; import com.jens.automation2.receivers.PhoneStatusListener;
@ -57,6 +58,8 @@ public class AutomationService extends Service implements OnInitListener
protected Calendar lockSoundChangesEnd = null; protected Calendar lockSoundChangesEnd = null;
protected boolean isRunning; protected boolean isRunning;
protected static AutomationService centralInstance = null;
public void nullLockSoundChangesEnd() public void nullLockSoundChangesEnd()
{ {
lockSoundChangesEnd = null; lockSoundChangesEnd = null;
@ -94,8 +97,6 @@ public class AutomationService extends Service implements OnInitListener
return myLocationProvider; return myLocationProvider;
} }
protected static AutomationService centralInstance = null;
public static AutomationService getInstance() public static AutomationService getInstance()
{ {
return centralInstance; return centralInstance;
@ -287,6 +288,8 @@ public class AutomationService extends Service implements OnInitListener
myLocationProvider.applySettingsAndRules(); myLocationProvider.applySettingsAndRules();
ReceiverCoordinator.applySettingsAndRules(); ReceiverCoordinator.applySettingsAndRules();
DateTimeListener.reloadAlarms();
} }
@Override @Override
@ -460,6 +463,8 @@ public class AutomationService extends Service implements OnInitListener
ttsEngine.shutdown(); ttsEngine.shutdown();
PackageReplacedReceiver.setHasServiceBeenRunning(false, this); PackageReplacedReceiver.setHasServiceBeenRunning(false, this);
centralInstance = null;
} }
protected static Builder createDefaultNotificationBuilderOld() protected static Builder createDefaultNotificationBuilderOld()

View File

@ -245,7 +245,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent); centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent);
SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm:ss");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(scheduleCandidate.time.getTimeInMillis()); calendar.setTimeInMillis(scheduleCandidate.time.getTimeInMillis());
Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4); Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4);