From 8c71abb208d7614cb2a595c58d4a5e295ec422d1 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 8 Mar 2022 14:01:53 +0100 Subject: [PATCH] Changes regarding incoming call notification & activity --- app/src/main/AndroidManifest.xml | 6 +++--- .../org/linphone/activities/call/CallActivity.kt | 3 +-- .../activities/call/IncomingCallActivity.kt | 4 ++-- .../activities/call/fragments/ControlsFragment.kt | 8 +++++--- .../linphone/notifications/NotificationsManager.kt | 13 ++++++++++++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 47d14f156..645d02e57 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -121,16 +121,16 @@ android:windowSoftInputMode="adjustResize"/> () { callsViewModel.noMoreCallEvent.observe( viewLifecycleOwner ) { - it.consume { - Log.i("[Controls Fragment] No more call, finishing activity") - requireActivity().finish() + it.consume { noMoreCall -> + if (noMoreCall) { + Log.i("[Controls Fragment] No more call, finishing activity") + requireActivity().finish() + } } } diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 1bde5f34c..ebbf52701 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -445,6 +445,17 @@ class NotificationsManager(private val context: Context) { return } + try { + val showLockScreenNotification = android.provider.Settings.Secure.getInt( + context.contentResolver, + "lock_screen_show_notifications", + 0 + ) + Log.i("[Notifications Manager] Are notifications allowed on lock screen? ${showLockScreenNotification != 0} ($showLockScreenNotification)") + } catch (e: Exception) { + Log.e("[Notifications Manager] Failed to get android.provider.Settings.Secure.getInt(lock_screen_show_notifications): $e") + } + val notifiable = getNotifiableForCall(call) if (notifiable.notificationId == currentForegroundServiceNotificationId) { Log.e("[Notifications Manager] There is already a Service foreground notification for an incoming call, cancelling it") @@ -453,7 +464,7 @@ class NotificationsManager(private val context: Context) { } val incomingCallNotificationIntent = Intent(context, IncomingCallActivity::class.java) - incomingCallNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + incomingCallNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_NO_USER_ACTION) val pendingIntent = PendingIntent.getActivity( context, 0,