From 90926cb5790dbdad6cdee5e98a8698258bd1b19c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Fri, 6 Oct 2023 15:21:46 -0400
Subject: [PATCH] fix calls for Android 14

Change-Id: Ie49fbb9cb253fd330f3edc356e737badf2f3307d
---
 jami-android/app/src/main/AndroidManifest.xml                 | 2 ++
 .../src/main/java/cx/ring/service/CallNotificationService.kt  | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/jami-android/app/src/main/AndroidManifest.xml b/jami-android/app/src/main/AndroidManifest.xml
index e55c57ff6..1afc31913 100644
--- a/jami-android/app/src/main/AndroidManifest.xml
+++ b/jami-android/app/src/main/AndroidManifest.xml
@@ -49,6 +49,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
     <uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
     <uses-permission android:name="com.android.providers.tv.permission.WRITE_EPG_DATA" />
 
     <uses-feature
diff --git a/jami-android/app/src/main/java/cx/ring/service/CallNotificationService.kt b/jami-android/app/src/main/java/cx/ring/service/CallNotificationService.kt
index 805ed71d9..c5a30cfce 100644
--- a/jami-android/app/src/main/java/cx/ring/service/CallNotificationService.kt
+++ b/jami-android/app/src/main/java/cx/ring/service/CallNotificationService.kt
@@ -39,7 +39,9 @@ class CallNotificationService : Service() {
         if (ACTION_START == intent.action) {
             val notification = mNotificationService.showCallNotification(intent.getIntExtra(NotificationService.KEY_NOTIFICATION_ID, -1)) as Notification?
             if (notification != null) {
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
+                    startForeground(NotificationServiceImpl.NOTIF_CALL_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL)
+                else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
                     startForeground(NotificationServiceImpl.NOTIF_CALL_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL or ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)
                 else
                     startForeground(NotificationServiceImpl.NOTIF_CALL_ID, notification)
-- 
GitLab