diff --git a/app/src/main/java/org/linphone/core/CoreContext.kt b/app/src/main/java/org/linphone/core/CoreContext.kt index 27cf540d6..3395fdf04 100644 --- a/app/src/main/java/org/linphone/core/CoreContext.kt +++ b/app/src/main/java/org/linphone/core/CoreContext.kt @@ -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)