/** * Handles intents, either {@link #ACTION_RESTART}, or intents having {@link * DeviceStateHolder#EXTRA_HAS_WIFI} or {@link DeviceStateHolder#EXTRA_IS_CHARGING} (which are * handled by {@link DeviceStateHolder}. */ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null) return START_STICKY; if (ACTION_RESTART.equals(intent.getAction()) && mCurrentState == State.ACTIVE) { shutdown(); mCurrentState = State.INIT; updateState(); } else if (ACTION_RESET.equals(intent.getAction())) { shutdown(); new SyncthingRunnable(this, SyncthingRunnable.Command.reset).run(); mCurrentState = State.INIT; updateState(); } else if (mCurrentState != State.INIT) { mDeviceStateHolder.update(intent); updateState(); } return START_STICKY; }