mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent crashes in case of exception
This commit is contained in:
parent
e14a142fb7
commit
5cc491335c
2 changed files with 23 additions and 7 deletions
|
|
@ -499,8 +499,12 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
fun postOnCoreThread(
|
||||
@WorkerThread lambda: (core: Core) -> Unit
|
||||
) {
|
||||
coreThread.post {
|
||||
lambda.invoke(core)
|
||||
if (::coreThread.isInitialized) {
|
||||
coreThread.post {
|
||||
lambda.invoke(core)
|
||||
}
|
||||
} else {
|
||||
Log.e("$TAG Core's thread not initialized yet!")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -509,9 +513,13 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
@WorkerThread lambda: (core: Core) -> Unit,
|
||||
delay: Long
|
||||
) {
|
||||
coreThread.postDelayed({
|
||||
lambda.invoke(core)
|
||||
}, delay)
|
||||
if (::coreThread.isInitialized) {
|
||||
coreThread.postDelayed({
|
||||
lambda.invoke(core)
|
||||
}, delay)
|
||||
} else {
|
||||
Log.e("$TAG Core's thread not initialized yet!")
|
||||
}
|
||||
}
|
||||
|
||||
@AnyThread
|
||||
|
|
|
|||
|
|
@ -148,12 +148,20 @@ class PermissionsFragment : GenericFragment() {
|
|||
if (core.accountList.isNotEmpty()) {
|
||||
coreContext.postOnMainThread {
|
||||
Log.w("$TAG At least one account was found, leaving assistant")
|
||||
requireActivity().finish()
|
||||
try {
|
||||
requireActivity().finish()
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.e("$TAG Failed to finish activity: $ise")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
coreContext.postOnMainThread {
|
||||
Log.w("$TAG No account was found, going to landing fragment")
|
||||
goToLoginFragment()
|
||||
try {
|
||||
goToLoginFragment()
|
||||
} catch (ise: IllegalStateException) {
|
||||
Log.e("$TAG Failed to navigate to login fragment: $ise")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue