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