From 8c7c4bee0d3c30c0c971cffc9122eb784c5dff61 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 16 Apr 2024 11:11:09 +0200 Subject: [PATCH] Update call foreground service types when disabling/enabling video --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 3 ++- .../notifications/NotificationsManager.kt | 20 ++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b3845cf04..499108be3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -174,7 +174,7 @@ dependencies { // https://github.com/Baseflow/PhotoView/blob/master/LICENSE Apache v2.0 implementation 'com.github.chrisbanes:PhotoView:2.3.0' - implementation platform('com.google.firebase:firebase-bom:32.7.2') + implementation platform('com.google.firebase:firebase-bom:32.8.1') implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-crashlytics-ndk' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 45828a0a1..c9178e398 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -45,6 +45,7 @@ android:localeConfig="@xml/locales_config" tools:targetApi="34"> + @@ -126,7 +127,7 @@ diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 9e6879a96..596411849 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -112,6 +112,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) state: Call.State?, message: String ) { + Log.i("$TAG Call state changed: [$state]") when (state) { Call.State.IncomingReceived, Call.State.IncomingEarlyMedia -> { Log.i( @@ -132,6 +133,15 @@ class NotificationsManager @MainThread constructor(private val context: Context) ) showCallNotification(call, false) } + Call.State.Updating -> { + val notifiable = getNotifiableForCall(call) + if (notifiable.notificationId == currentForegroundServiceNotificationId) { + Log.i( + "$TAG Update foreground service type in case video was enabled/disabled since last time" + ) + startCallForeground(call) + } + } Call.State.End, Call.State.Error -> { val remoteSipAddress = call.remoteAddress if (call.dir == Call.Dir.Incoming && currentlyRingingCallRemoteAddress?.weakEqual( @@ -598,10 +608,14 @@ class NotificationsManager @MainThread constructor(private val context: Context) ) { mask = mask or Compatibility.FOREGROUND_SERVICE_TYPE_MICROPHONE Log.i( - "$TAG RECORD_AUDIO permission has been granted, adding FOREGROUND_SERVICE_TYPE_MICROPHONE" + "$TAG RECORD_AUDIO permission has been granted, adding FOREGROUND_SERVICE_TYPE_MICROPHONE to foreground service types mask" ) } - if (call.currentParams.isVideoEnabled) { + val isSendingVideo = when (call.currentParams.videoDirection) { + MediaDirection.SendRecv, MediaDirection.SendOnly -> true + else -> false + } + if (call.currentParams.isVideoEnabled && isSendingVideo) { if (ActivityCompat.checkSelfPermission( context, Manifest.permission.CAMERA @@ -609,7 +623,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) ) { mask = mask or Compatibility.FOREGROUND_SERVICE_TYPE_CAMERA Log.i( - "$TAG CAMERA permission has been granted, adding FOREGROUND_SERVICE_TYPE_CAMERA" + "$TAG CAMERA permission has been granted, adding FOREGROUND_SERVICE_TYPE_CAMERA to foreground service types mask" ) } }