Let watchdog reschedule missed alarms

pull/177/head
M66B 6 years ago
parent 3f7187a769
commit 4387237a6f

@ -662,6 +662,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
onAlarm(intent); onAlarm(intent);
break; break;
case "watchdog":
onWatchdog(intent);
break;
default: default:
Log.w("Unknown action: " + action); Log.w("Unknown action: " + action);
} }
@ -713,6 +717,11 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
liveAccountNetworkState.post(command); liveAccountNetworkState.post(command);
} }
private void onWatchdog(Intent intent) {
schedule(this);
onEval(intent);
}
private NotificationCompat.Builder getNotificationService(Integer accounts, Integer operations) { private NotificationCompat.Builder getNotificationService(Integer accounts, Integer operations) {
if (accounts != null) if (accounts != null)
this.lastAccounts = accounts; this.lastAccounts = accounts;
@ -1910,4 +1919,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
new Intent(context, ServiceSynchronize.class) new Intent(context, ServiceSynchronize.class)
.setAction("alarm")); .setAction("alarm"));
} }
static void watchdog(Context context) {
ContextCompat.startForegroundService(context,
new Intent(context, ServiceSynchronize.class)
.setAction("watchdog"));
}
} }

@ -44,7 +44,7 @@ public class WorkerWatchdog extends Worker {
@Override @Override
public Result doWork() { public Result doWork() {
Log.i("Running " + getName()); Log.i("Running " + getName());
ServiceSynchronize.eval(getApplicationContext(), "watchdog"); ServiceSynchronize.watchdog(getApplicationContext());
ServiceSend.watchdog(getApplicationContext()); ServiceSend.watchdog(getApplicationContext());
return Result.success(); return Result.success();
} }

Loading…
Cancel
Save