NSCv3: catch stop service crash

This commit is contained in:
Milos Kozak 2023-10-27 23:26:03 +02:00
parent 90251178a9
commit 70db735476

View file

@ -194,7 +194,7 @@ class NSClientV3Plugin @Inject constructor(
disposable += rxBus
.toObservable(EventAppExit::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ if (nsClientV3Service != null) context.unbindService(serviceConnection) }, fabricPrivacy::logException)
.subscribe({ stopService() }, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventConnectivityOptionChanged::class.java)
.observeOn(aapsSchedulers.io)
@ -359,7 +359,11 @@ class NSClientV3Plugin @Inject constructor(
}
private fun stopService() {
if (nsClientV3Service != null) context.unbindService(serviceConnection)
try {
if (nsClientV3Service != null) context.unbindService(serviceConnection)
} catch (e: Exception) {
nsClientV3Service = null
}
}
override fun resend(reason: String) {