Allow to stop service after action task

This commit is contained in:
J-Jamet
2021-08-17 18:36:44 +02:00
parent 60747db945
commit 0756474d40

View File

@@ -62,6 +62,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
private var mActionTaskBinder = ActionTaskBinder()
private var mActionTaskListeners = LinkedList<ActionTaskListener>()
private var mActionRunning = false
private var mStopServiceAfterCurrentActionFinished = false
private var mIconId: Int = R.drawable.notification_ic_database_load
private var mTitleId: Int = R.string.database_opened
@@ -299,7 +300,9 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
}
removeIntentData(intent)
TimeoutHelper.releaseTemporarilyDisableTimeout()
if (TimeoutHelper.checkTimeAndLockIfTimeout(this@DatabaseTaskNotificationService)) {
if (mStopServiceAfterCurrentActionFinished)
stopSelf()
else if (TimeoutHelper.checkTimeAndLockIfTimeout(this@DatabaseTaskNotificationService)) {
if (!database.loaded) {
stopSelf()
} else {
@@ -492,6 +495,11 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
}
}
override fun onTaskRemoved(rootIntent: Intent?) {
super.onTaskRemoved(rootIntent)
mStopServiceAfterCurrentActionFinished = true
}
private fun buildDatabaseCreateActionTask(intent: Intent, database: Database): ActionRunnable? {
if (intent.hasExtra(DATABASE_URI_KEY)