Fixed incoming call style notification not always displayed

This commit is contained in:
Sylvain Berfini 2023-10-23 13:59:52 +02:00
parent a49cb0935d
commit a78421d79a
4 changed files with 32 additions and 2 deletions

View file

@ -28,6 +28,9 @@ rls_uri=sips:rls@sip.linphone.org
#remove this property for any application that is not Linphone public version itself
ec_calibrator_cool_tones=1
[audio]
android_disable_audio_focus_requests=1
[video]
displaytype=MSAndroidTextureDisplay
auto_resize_preview_to_keep_ratio=1

View file

@ -366,6 +366,9 @@ fun Friend.getPerson(): Person {
val bm: Bitmap? = getAvatarBitmap()
personBuilder.setIcon(
if (bm == null) {
Log.i(
"[Friend] Can't use friend [$name] picture path, generating avatar based on initials"
)
AvatarGenerator(coreContext.context).setInitials(AppUtils.getInitials(name.orEmpty())).buildIcon()
} else {
IconCompat.createWithAdaptiveBitmap(bm)

View file

@ -61,4 +61,16 @@ class CoreForegroundService : CoreService() {
override fun onBind(p0: Intent?): IBinder? {
return null
}
override fun createServiceNotification() {
// Do nothing, app's Notifications Manager will do the job
}
override fun showForegroundServiceNotification() {
// Do nothing, app's Notifications Manager will do the job
}
override fun hideForegroundServiceNotification() {
// Do nothing, app's Notifications Manager will do the job
}
}

View file

@ -349,6 +349,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
Log.w("$TAG No call anymore, stopping service")
stopCallForeground()
} else {
Log.i("$TAG At least a call is still running")
startCallForeground()
}
}
@ -401,6 +402,8 @@ class NotificationsManager @MainThread constructor(private val context: Context)
@WorkerThread
private fun startCallForeground() {
Log.i("$TAG Trying to start foreground Service using call notification")
val channelId = context.getString(R.string.notification_channel_call_id)
val channel = notificationManager.getNotificationChannel(channelId)
val importance = channel?.importance ?: NotificationManagerCompat.IMPORTANCE_NONE
@ -415,7 +418,12 @@ class NotificationsManager @MainThread constructor(private val context: Context)
val notification = notificationManager.activeNotifications.find {
it.id == notifiable.notificationId
}
notification ?: return
if (notification == null) {
Log.w("$TAG No existing notification found for current Call, aborting")
return
}
Log.i("$TAG Found notification [${notification.id}] for current Call")
val service = coreService
if (service != null) {
@ -726,6 +734,10 @@ class NotificationsManager @MainThread constructor(private val context: Context)
}
}
Log.i(
"Creating notification for ${if (isIncoming) "incoming" else "outgoing"} call with video ${if (isVideo) "enabled" else "disabled"} on channel [$channel]"
)
val builder = NotificationCompat.Builder(
context,
channel
@ -741,7 +753,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
setStyle(style)
} catch (iae: IllegalArgumentException) {
Log.e(
"$TAG Can't use notification call style: $iae, using API 26 notification instead"
"$TAG Can't use notification call style: $iae"
)
}
setSmallIcon(smallIcon)