diff --git a/app/src/main/java/com/nutomic/syncthingandroid/http/PostRequest.java b/app/src/main/java/com/nutomic/syncthingandroid/http/PostRequest.java index 9bf439ad..576fe28e 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/http/PostRequest.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/http/PostRequest.java @@ -16,6 +16,7 @@ public class PostRequest extends ApiRequest { public static final String URI_DB_IGNORES = "/rest/db/ignores"; public static final String URI_DB_OVERRIDE = "/rest/db/override"; public static final String URI_SYSTEM_CONFIG = "/rest/system/config"; + public static final String URI_SYSTEM_SHUTDOWN = "/rest/system/shutdown"; public PostRequest(Context context, URL url, String path, String apiKey, @Nullable Map params, @Nullable String postBody, diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java b/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java index a46f5382..64260dc4 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/RestApi.java @@ -410,6 +410,15 @@ public class RestApi { mOnConfigChangedListener.onConfigChanged(); } + /** + * Posts shutdown request. + * This will cause SyncthingNative to exit and not restart. + */ + public void shutdown() { + new PostRequest(mContext, mUrl, PostRequest.URI_SYSTEM_SHUTDOWN, mApiKey, + null, null, null); + } + /** * Returns the version name, or a (text) error message on failure. */ diff --git a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java index bdbce875..5372afed 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/service/SyncthingService.java @@ -658,6 +658,9 @@ public class SyncthingService extends Service { } if (mRestApi != null) { + if (mSyncthingRunnable != null) { + mRestApi.shutdown(); + } mRestApi = null; }