Preserve last service command

This commit is contained in:
M66B 2021-03-16 08:42:32 +01:00
parent 01d8c048e3
commit 5a93ac6fb4
1 changed files with 6 additions and 2 deletions

View File

@ -2144,6 +2144,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private class MediatorState extends MediatorLiveData<List<TupleAccountNetworkState>> {
private boolean running = true;
private Bundle lastCommand = null;
private ConnectionHelper.NetworkState lastNetworkState = null;
private List<TupleAccountState> lastAccountStates = null;
@ -2159,12 +2160,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private void post(ConnectionHelper.NetworkState networkState) {
lastNetworkState = networkState;
post(null, lastNetworkState, lastAccountStates);
post(lastCommand, lastNetworkState, lastAccountStates);
}
private void post(List<TupleAccountState> accountStates) {
lastAccountStates = accountStates;
post(null, lastNetworkState, lastAccountStates);
post(lastCommand, lastNetworkState, lastAccountStates);
}
private void postDestroy() {
@ -2185,9 +2186,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (accountStates == null) {
EntityLog.log(ServiceSynchronize.this, "### no accounts");
lastCommand = command;
return;
}
lastCommand = null;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this);
boolean enabled = prefs.getBoolean("enabled", true);
int pollInterval = prefs.getInt("poll_interval", DEFAULT_POLL_INTERVAL);