mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: fix channel closing
This commit is contained in:
@@ -124,6 +124,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||||||
mActionTaskListeners.remove(actionTaskListener)
|
mActionTaskListeners.remove(actionTaskListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExperimentalCoroutinesApi
|
||||||
fun addRequestChallengeListener(requestChallengeListener: RequestChallengeListener) {
|
fun addRequestChallengeListener(requestChallengeListener: RequestChallengeListener) {
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
val requestChannel = mRequestChallengeListenerChannel
|
val requestChannel = mRequestChallengeListenerChannel
|
||||||
@@ -138,7 +139,11 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||||||
|
|
||||||
fun removeRequestChallengeListener() {
|
fun removeRequestChallengeListener() {
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
mRequestChallengeListenerChannel?.cancel()
|
try {
|
||||||
|
mRequestChallengeListenerChannel?.cancel()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(TAG, "Request challenge listener cannot be closed.", e)
|
||||||
|
}
|
||||||
mRequestChallengeListenerChannel = null
|
mRequestChallengeListenerChannel = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,6 +270,7 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||||||
mResponseChallengeChannel = null
|
mResponseChallengeChannel = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExperimentalCoroutinesApi
|
||||||
fun respondToChallenge(response: ByteArray) {
|
fun respondToChallenge(response: ByteArray) {
|
||||||
mainScope.launch {
|
mainScope.launch {
|
||||||
val responseChannel = mResponseChallengeChannel
|
val responseChannel = mResponseChallengeChannel
|
||||||
@@ -416,7 +422,9 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
|||||||
try {
|
try {
|
||||||
startService(Intent(applicationContext,
|
startService(Intent(applicationContext,
|
||||||
DatabaseTaskNotificationService::class.java))
|
DatabaseTaskNotificationService::class.java))
|
||||||
} catch (e: IllegalStateException) {}
|
} catch (e: IllegalStateException) {
|
||||||
|
Log.w(TAG, "Cannot restart the database task service", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mTaskRemovedRequested = false
|
mTaskRemovedRequested = false
|
||||||
|
|||||||
Reference in New Issue
Block a user