mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Try to prevent crash seen in Crashlytics
This commit is contained in:
parent
a743a0d2c6
commit
cf901a9c2b
3 changed files with 16 additions and 2 deletions
|
|
@ -55,6 +55,10 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
|
||||
lateinit var core: Core
|
||||
|
||||
fun isCoreAvailable(): Boolean {
|
||||
return ::core.isInitialized
|
||||
}
|
||||
|
||||
val contactsManager = ContactsManager()
|
||||
|
||||
val notificationsManager = NotificationsManager(context)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ class CoreFileTransferService : FileTransferService() {
|
|||
|
||||
var builder = NotificationCompat.Builder(this, SERVICE_NOTIFICATION_CHANNEL_ID)
|
||||
|
||||
var listenerAdded = false
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
@WorkerThread
|
||||
override fun onRemainingNumberOfFileTransferChanged(
|
||||
|
|
@ -57,12 +59,19 @@ class CoreFileTransferService : FileTransferService() {
|
|||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
coreContext.core.addListener(coreListener)
|
||||
if (!listenerAdded && coreContext.isCoreAvailable()) {
|
||||
coreContext.core.addListener(coreListener)
|
||||
listenerAdded = true
|
||||
}
|
||||
Log.i("$TAG Created")
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
Log.i("$TAG onStartCommand")
|
||||
if (!listenerAdded && coreContext.isCoreAvailable()) {
|
||||
coreContext.core.addListener(coreListener)
|
||||
listenerAdded = true
|
||||
}
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
|
|
@ -74,6 +83,7 @@ class CoreFileTransferService : FileTransferService() {
|
|||
override fun onDestroy() {
|
||||
Log.i("$TAG onDestroy")
|
||||
coreContext.core.removeListener(coreListener)
|
||||
listenerAdded = false
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
|||
Log.i("$TAG Call added to Telecom's CallsManager")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("$TAG Failed to add call to Telecom's CallsManager!")
|
||||
Log.e("$TAG Failed to add call to Telecom's CallsManager: $e")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue