Handle absent notification managers and nullable call channels explicitly
This commit is contained in:
1 parent
15a2a7bb70
commit
dd9aac79a2
1 file changed
+4
-3
@@ -66,7 +66,7 @@ class CallService : Service() {
|
||||
}
|
||||
|
||||
private fun createChannel() {
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
val manager = requireNotNull(getSystemService(NotificationManager::class.java)) { "notification manager unavailable" }
|
||||
manager.createNotificationChannel(
|
||||
NotificationChannel(CHANNEL, AppLanguage.text(R.string.ongoing_call), NotificationManager.IMPORTANCE_DEFAULT).apply {
|
||||
description = AppLanguage.text(R.string.ongoing_call_description)
|
||||
@@ -77,7 +77,7 @@ class CallService : Service() {
|
||||
val channel = manager.getNotificationChannel(CHANNEL)
|
||||
LogManager.addLog("INFO", "CallService",
|
||||
"notification channel=$CHANNEL enabled=${manager.areNotificationsEnabled()} " +
|
||||
"importance=${channel.importance} lockscreenVisibility=${channel.lockscreenVisibility}")
|
||||
"importance=${channel?.importance} lockscreenVisibility=${channel?.lockscreenVisibility}")
|
||||
}
|
||||
|
||||
fun refreshLanguage() { createChannel(); updateNotification() }
|
||||
@@ -164,7 +164,8 @@ class CallService : Service() {
|
||||
}
|
||||
|
||||
fun updateNotification() {
|
||||
getSystemService(NotificationManager::class.java).notify(NOTIFICATION_ID, notification())
|
||||
requireNotNull(getSystemService(NotificationManager::class.java)) { "notification manager unavailable" }
|
||||
.notify(NOTIFICATION_ID, notification())
|
||||
LogManager.addLog("INFO", "CallService", "notification updated id=$callId phase=${CallController.state.value?.phase}")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user