1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-07 10:42:07 +00:00

Fix deferred native shutdown not working during State.STARTING (fixes #290) (#296)

Remove SyncthingService#mDestroyScheduled
This commit is contained in:
Catfriend1 2019-01-31 23:51:39 +01:00 committed by GitHub
parent a30163ea1e
commit 976d4e05c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,12 +195,6 @@ public class SyncthingService extends Service {
*/
private boolean mLastDeterminedShouldRun = false;
/**
* True if a service {@link #onDestroy} was requested while syncthing is starting,
* in that case, perform stop in {@link #onApiAvailable}.
*/
private boolean mDestroyScheduled = false;
/**
* True if the user granted the storage permission.
*/
@ -594,17 +588,6 @@ public class SyncthingService extends Service {
mRestApi.applyCustomRunConditions(mRunConditionMonitor);
}
/**
* If the service instance got an onDestroy() event while being in
* State.STARTING we'll trigger the service onDestroy() now. this
* allows the syncthing binary to get gracefully stopped.
*/
if (mDestroyScheduled) {
mDestroyScheduled = false;
stopSelf();
return;
}
if (mEventProcessor == null) {
mEventProcessor = new EventProcessor(SyncthingService.this, mRestApi);
mEventProcessor.start();
@ -633,22 +616,12 @@ public class SyncthingService extends Service {
if (mNotificationHandler != null) {
mNotificationHandler.setAppShutdownInProgress(true);
}
if (mStoragePermissionGranted) {
synchronized (mStateLock) {
if (mCurrentState == State.STARTING) {
Log.i(TAG, "Delay shutting down syncthing binary until initialisation finished");
mDestroyScheduled = true;
} else {
Log.i(TAG, "Shutting down syncthing binary immediately");
shutdown(State.DISABLED);
}
}
} else {
if (!mStoragePermissionGranted) {
// If the storage permission got revoked, we did not start the binary and
// are in State.INIT requiring an immediate shutdown of this service class.
Log.i(TAG, "Shutting down syncthing binary due to missing storage permission.");
shutdown(State.DISABLED);
}
shutdown(State.DISABLED);
super.onDestroy();
}