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)
{}
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.location.LocationProvider;
import com.jens.automation2.receivers.DateTimeListener;
import com.jens.automation2.receivers.PackageReplacedReceiver;
import com.jens.automation2.receivers.PhoneStatusListener;
@ -57,6 +58,8 @@ public class AutomationService extends Service implements OnInitListener
protected Calendar lockSoundChangesEnd = null;
protected boolean isRunning;
protected static AutomationService centralInstance = null;
public void nullLockSoundChangesEnd()
{
lockSoundChangesEnd = null;
@ -94,8 +97,6 @@ public class AutomationService extends Service implements OnInitListener
return myLocationProvider;
}
protected static AutomationService centralInstance = null;
public static AutomationService getInstance()
{
return centralInstance;
@ -287,6 +288,8 @@ public class AutomationService extends Service implements OnInitListener
myLocationProvider.applySettingsAndRules();
ReceiverCoordinator.applySettingsAndRules();
DateTimeListener.reloadAlarms();
}
@Override
@ -460,6 +463,8 @@ public class AutomationService extends Service implements OnInitListener
ttsEngine.shutdown();
PackageReplacedReceiver.setHasServiceBeenRunning(false, this);
centralInstance = null;
}
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);
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.setTimeInMillis(scheduleCandidate.time.getTimeInMillis());
Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4);