Fixed duplicated listeners when doing remove provisioning

This commit is contained in:
Sylvain Berfini 2025-02-13 11:59:59 +01:00
parent 037cd71814
commit 8c1889b181

View file

@ -163,6 +163,8 @@ class CoreContext
// Wait for GlobalState.ON as some settings modification won't be saved
// in RC file if Core isn't ON
onCoreStarted()
} else if (state == GlobalState.Shutdown) {
onCoreStopped()
}
}
@ -500,6 +502,14 @@ class CoreContext
Log.i("$TAG Started contacts, telecom & notifications managers")
}
@WorkerThread
private fun onCoreStopped() {
Log.w("$TAG Core is being shut down, notifying managers so they can remove their listeners and do some cleanup if needed")
contactsManager.onCoreStopped(core)
telecomManager.onCoreStopped(core)
notificationsManager.onCoreStopped(core)
}
@WorkerThread
private fun destroyCore() {
if (!::core.isInitialized) {
@ -522,10 +532,6 @@ class CoreContext
core.stop()
contactsManager.onCoreStopped(core)
telecomManager.onCoreStopped(core)
notificationsManager.onCoreStopped(core)
// It's very unlikely the process will survive until the Core reaches GlobalStateOff sadly
Log.w("$TAG Core has been shut down")
exitProcess(0)