From e3e99d1c551daded78ce70bc905b8ef537f57560 Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Mon, 2 Dec 2024 09:20:23 +0100 Subject: [PATCH 1/6] When startForegroundService crashes, just send the notification without a service --- .../internal/service/CallService.kt | 125 ++++++++++++------ 1 file changed, 86 insertions(+), 39 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt index 7b52ad73a8..f2ea1e4786 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt @@ -16,13 +16,16 @@ package io.getstream.video.android.core.notifications.internal.service +import android.Manifest import android.annotation.SuppressLint import android.app.ActivityManager import android.app.Notification import android.app.Service +import android.content.ComponentName import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.content.pm.PackageManager import android.content.pm.ServiceInfo import android.media.AudioAttributes import android.media.AudioFocusRequest @@ -47,6 +50,7 @@ import io.getstream.video.android.core.notifications.NotificationHandler.Compani import io.getstream.video.android.core.notifications.NotificationHandler.Companion.INTENT_EXTRA_CALL_DISPLAY_NAME import io.getstream.video.android.core.notifications.internal.receivers.ToggleCameraBroadcastReceiver import io.getstream.video.android.core.utils.safeCallWithDefault +import io.getstream.video.android.core.utils.safeCallWithResult import io.getstream.video.android.core.utils.startForegroundWithServiceType import io.getstream.video.android.model.StreamCallId import io.getstream.video.android.model.streamCallDisplayName @@ -164,34 +168,63 @@ internal open class CallService : Service() { intent ?: Intent(context, CallService::class.java) } - fun showIncomingCall(context: Context, callId: StreamCallId, callDisplayName: String?, callServiceConfiguration: CallServiceConfig = callServiceConfig()) { + fun showIncomingCall( + context: Context, + callId: StreamCallId, + callDisplayName: String?, + callServiceConfiguration: CallServiceConfig = callServiceConfig(), + ) { val hasActiveCall = StreamVideo.instanceOrNull()?.state?.activeCall?.value != null - - if (!hasActiveCall) { - ContextCompat.startForegroundService( - context, - buildStartIntent( + safeCallWithResult { + val result = if (!hasActiveCall) { + ContextCompat.startForegroundService( context, - callId, - TRIGGER_INCOMING_CALL, - callDisplayName, - callServiceConfiguration, - ), - ) - } else { - context.startService( - buildStartIntent( + buildStartIntent( + context, + callId, + TRIGGER_INCOMING_CALL, + callDisplayName, + callServiceConfiguration, + ), + ) + ComponentName(context, CallService::class.java) + } else { + context.startService( + buildStartIntent( + context, + callId, + TRIGGER_INCOMING_CALL, + callDisplayName, + callServiceConfiguration, + ), + ) + } + result!! + }.onError { + // Show notification + if (ContextCompat.checkSelfPermission( context, - callId, - TRIGGER_INCOMING_CALL, - callDisplayName, - callServiceConfiguration, - ), - ) + Manifest.permission.POST_NOTIFICATIONS, + ) != PackageManager.PERMISSION_GRANTED + ) { + StreamVideo.instanceOrNull()?.getRingingCallNotification( + ringingState = RingingState.Incoming(), + callId = callId, + callDisplayName = callDisplayName, + shouldHaveContentIntent = true, + )?.let { + NotificationManagerCompat.from(context) + .notify(INCOMING_CALL_NOTIFICATION_ID, it) + } + } } } - fun removeIncomingCall(context: Context, callId: StreamCallId, config: CallServiceConfig = callServiceConfig()) { + fun removeIncomingCall( + context: Context, + callId: StreamCallId, + config: CallServiceConfig = callServiceConfig(), + ) { context.startService( buildStartIntent( context, @@ -202,22 +235,23 @@ internal open class CallService : Service() { ) } - private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean = safeCallWithDefault( - true, - ) { - val activityManager = context.getSystemService( - Context.ACTIVITY_SERVICE, - ) as ActivityManager - val runningServices = activityManager.getRunningServices(Int.MAX_VALUE) - for (service in runningServices) { - if (serviceClass.name == service.service.className) { - StreamLog.w(TAG) { "Service is running: $serviceClass" } - return true + private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean = + safeCallWithDefault( + true, + ) { + val activityManager = context.getSystemService( + Context.ACTIVITY_SERVICE, + ) as ActivityManager + val runningServices = activityManager.getRunningServices(Int.MAX_VALUE) + for (service in runningServices) { + if (serviceClass.name == service.service.className) { + StreamLog.w(TAG) { "Service is running: $serviceClass" } + return true + } } + StreamLog.w(TAG) { "Service is NOT running: $serviceClass" } + return false } - StreamLog.w(TAG) { "Service is NOT running: $serviceClass" } - return false - } } override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { @@ -347,7 +381,11 @@ internal open class CallService : Service() { } } - private fun maybePromoteToForegroundService(videoClient: StreamVideoClient, notificationId: Int, trigger: String) { + private fun maybePromoteToForegroundService( + videoClient: StreamVideoClient, + notificationId: Int, + trigger: String, + ) { val hasActiveCall = videoClient.state.activeCall.value != null val not = if (hasActiveCall) " not" else "" @@ -631,7 +669,11 @@ internal open class CallService : Service() { } } - private fun handleIncomingCallAcceptedByMeOnAnotherDevice(acceptedByUserId: String, myUserId: String, callRingingState: RingingState) { + private fun handleIncomingCallAcceptedByMeOnAnotherDevice( + acceptedByUserId: String, + myUserId: String, + callRingingState: RingingState, + ) { // If accepted event was received, with event user being me, but current device is still ringing, it means the call was accepted on another device if (acceptedByUserId == myUserId && callRingingState is RingingState.Incoming) { // So stop ringing on this device @@ -639,7 +681,12 @@ internal open class CallService : Service() { } } - private fun handleIncomingCallRejectedByMeOrCaller(rejectedByUserId: String, myUserId: String, createdByUserId: String?, activeCallExists: Boolean) { + private fun handleIncomingCallRejectedByMeOrCaller( + rejectedByUserId: String, + myUserId: String, + createdByUserId: String?, + activeCallExists: Boolean, + ) { // If rejected event was received (even from another device), with event user being me OR the caller, remove incoming call / stop service. if (rejectedByUserId == myUserId || rejectedByUserId == createdByUserId) { if (activeCallExists) { From 0752db9d82f562412106868f9ee3e496a95a66e7 Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Mon, 2 Dec 2024 12:03:16 +0100 Subject: [PATCH 2/6] Wrap most `startForeground` calls with results and simply show the notification if the service start fails. --- .../api/stream-video-android-core.api | 3 +- .../video/android/core/StreamVideoBuilder.kt | 4 + .../DefaultNotificationHandler.kt | 12 ++- .../internal/service/CallService.kt | 73 ++++++++++++------- .../video/android/core/utils/AndroidUtils.kt | 2 +- 5 files changed, 63 insertions(+), 31 deletions(-) diff --git a/stream-video-android-core/api/stream-video-android-core.api b/stream-video-android-core/api/stream-video-android-core.api index 2c865fa4c5..89390e86f9 100644 --- a/stream-video-android-core/api/stream-video-android-core.api +++ b/stream-video-android-core/api/stream-video-android-core.api @@ -837,7 +837,8 @@ public final class io/getstream/video/android/core/StreamVideoBuilder { public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;)V public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;)V public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;J)V - public synthetic fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JZ)V + public synthetic fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun build ()Lio/getstream/video/android/core/StreamVideo; } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt index 4548cf4d6f..34e8e4acd7 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt @@ -121,6 +121,7 @@ public class StreamVideoBuilder @JvmOverloads constructor( private val appName: String? = null, private val audioProcessing: ManagedAudioProcessingFactory? = null, private val leaveAfterDisconnectSeconds: Long = 30, + private val autoRegisterPushDevice: Boolean = true, ) { private val context: Context = context.applicationContext private val scope = UserScope(ClientScope()) @@ -235,6 +236,9 @@ public class StreamVideoBuilder @JvmOverloads constructor( scope.launch { try { val result = client.connectAsync().await() + if (autoRegisterPushDevice) { + client.registerPushDevice() + } result.onSuccess { streamLog { "Connection succeeded! (duration: ${result.getOrNull()})" } }.onError { diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt index 4027d2d355..a3132b2f5f 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt @@ -94,7 +94,17 @@ public open class DefaultNotificationHandler( override fun onRingingCall(callId: StreamCallId, callDisplayName: String) { logger.d { "[onRingingCall] #ringing; callId: ${callId.id}" } - CallService.showIncomingCall(application, callId, callDisplayName) + CallService.showIncomingCall( + application, + callId, + callDisplayName, + notification = getRingingCallNotification( + RingingState.Incoming(), + callId, + callDisplayName, + shouldHaveContentIntent = true, + ), + ) } override fun onMissedCall(callId: StreamCallId, callDisplayName: String) { diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt index f2ea1e4786..a3d1f582ec 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt @@ -37,6 +37,7 @@ import android.net.Uri import android.os.Build import android.os.IBinder import androidx.annotation.RequiresApi +import androidx.core.app.ActivityCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat import io.getstream.log.StreamLog @@ -173,6 +174,7 @@ internal open class CallService : Service() { callId: StreamCallId, callDisplayName: String?, callServiceConfiguration: CallServiceConfig = callServiceConfig(), + notification: Notification?, ) { val hasActiveCall = StreamVideo.instanceOrNull()?.state?.activeCall?.value != null safeCallWithResult { @@ -202,20 +204,17 @@ internal open class CallService : Service() { result!! }.onError { // Show notification - if (ContextCompat.checkSelfPermission( - context, - Manifest.permission.POST_NOTIFICATIONS, - ) != PackageManager.PERMISSION_GRANTED + StreamLog.e(TAG) { "Could not start service, showing notification only: $it" } + val hasPermission = ContextCompat.checkSelfPermission( + context, + Manifest.permission.POST_NOTIFICATIONS, + ) == PackageManager.PERMISSION_GRANTED + StreamLog.i(TAG) { "Has permission: $hasPermission" } + StreamLog.i(TAG) { "Notification: $notification" } + if (hasPermission && notification != null ) { - StreamVideo.instanceOrNull()?.getRingingCallNotification( - ringingState = RingingState.Incoming(), - callId = callId, - callDisplayName = callDisplayName, - shouldHaveContentIntent = true, - )?.let { - NotificationManagerCompat.from(context) - .notify(INCOMING_CALL_NOTIFICATION_ID, it) - } + NotificationManagerCompat.from(context) + .notify(INCOMING_CALL_NOTIFICATION_ID, notification) } } } @@ -225,14 +224,18 @@ internal open class CallService : Service() { callId: StreamCallId, config: CallServiceConfig = callServiceConfig(), ) { - context.startService( - buildStartIntent( - context, - callId, - TRIGGER_REMOVE_INCOMING_CALL, - callServiceConfiguration = config, - ), - ) + safeCallWithResult { + context.startService( + buildStartIntent( + context, + callId, + TRIGGER_REMOVE_INCOMING_CALL, + callServiceConfiguration = config, + ), + )!! + }.onError { + NotificationManagerCompat.from(context).cancel(INCOMING_CALL_NOTIFICATION_ID) + } } private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean = @@ -394,12 +397,25 @@ internal open class CallService : Service() { } if (!hasActiveCall) { - videoClient.getSettingUpCallNotification()?.let { - startForegroundWithServiceType(notificationId, it, trigger, serviceType) + videoClient.getSettingUpCallNotification()?.let { notification -> + startForegroundWithServiceType( + notificationId, + notification, + trigger, + serviceType, + ).onError { + justNotify(notificationId, notification) + } } } } + private fun justNotify(notificationId: Int, notification: Notification) { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) { + NotificationManagerCompat.from(this).notify(notificationId, notification) + } + } + @SuppressLint("MissingPermission") private fun showIncomingCall(notificationId: Int, notification: Notification) { if (callId == null) { // If there isn't another call in progress (callId is set in onStartCommand()) @@ -409,12 +425,12 @@ internal open class CallService : Service() { notification, TRIGGER_INCOMING_CALL, serviceType, - ) + ).onError { + justNotify(notificationId, notification) + } } else { // Else, we show a simple notification (the service was already started as a foreground service). - NotificationManagerCompat - .from(this) - .notify(notificationId, notification) + justNotify(notificationId, notification) } } @@ -708,7 +724,8 @@ internal open class CallService : Service() { notification, TRIGGER_ONGOING_CALL, serviceType, - ) + ).onError { + } } } diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/AndroidUtils.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/AndroidUtils.kt index 7b91b1e030..a284078367 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/AndroidUtils.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/utils/AndroidUtils.kt @@ -189,7 +189,7 @@ internal fun Service.startForegroundWithServiceType( notification: Notification, trigger: String, foregroundServiceType: Int = ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL, -) { +) = safeCallWithResult { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { startForeground(notificationId, notification) } else { From 6b5384002187f771497c131bf3960413364ae47d Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Mon, 2 Dec 2024 12:12:56 +0100 Subject: [PATCH 3/6] Do not show setup notification eagerly if something fails --- .../core/notifications/internal/service/CallService.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt index a3d1f582ec..8ca067a45c 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt @@ -403,9 +403,7 @@ internal open class CallService : Service() { notification, trigger, serviceType, - ).onError { - justNotify(notificationId, notification) - } + ) } } } From c621df04b0d1db24aa2dd251fb084a5c2d00f371 Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Mon, 2 Dec 2024 12:26:52 +0100 Subject: [PATCH 4/6] Move config into the `NotificationConfig` --- .../io/getstream/video/android/core/StreamVideoBuilder.kt | 3 +-- .../video/android/core/notifications/NotificationConfig.kt | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt index 34e8e4acd7..32ba5443c1 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt @@ -121,7 +121,6 @@ public class StreamVideoBuilder @JvmOverloads constructor( private val appName: String? = null, private val audioProcessing: ManagedAudioProcessingFactory? = null, private val leaveAfterDisconnectSeconds: Long = 30, - private val autoRegisterPushDevice: Boolean = true, ) { private val context: Context = context.applicationContext private val scope = UserScope(ClientScope()) @@ -236,7 +235,7 @@ public class StreamVideoBuilder @JvmOverloads constructor( scope.launch { try { val result = client.connectAsync().await() - if (autoRegisterPushDevice) { + if (notificationConfig.autoRegisterPushDevice) { client.registerPushDevice() } result.onSuccess { diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/NotificationConfig.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/NotificationConfig.kt index 79370a887f..9afc05948d 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/NotificationConfig.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/NotificationConfig.kt @@ -23,6 +23,7 @@ public data class NotificationConfig( val pushDeviceGenerators: List = emptyList(), val requestPermissionOnAppLaunch: () -> Boolean = { true }, val notificationHandler: NotificationHandler = NoOpNotificationHandler, + val autoRegisterPushDevice: Boolean = true, val requestPermissionOnDeviceRegistration: () -> Boolean = { true }, /** * Set this to true if you want to make the ringing notifications as low-priority From 62017a637bfb166498ee846152bde4ab58b62948 Mon Sep 17 00:00:00 2001 From: Aleksandar Apostolov Date: Mon, 2 Dec 2024 12:27:37 +0100 Subject: [PATCH 5/6] Api --- .../api/stream-video-android-core.api | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/stream-video-android-core/api/stream-video-android-core.api b/stream-video-android-core/api/stream-video-android-core.api index 89390e86f9..d48a1390ce 100644 --- a/stream-video-android-core/api/stream-video-android-core.api +++ b/stream-video-android-core/api/stream-video-android-core.api @@ -837,8 +837,7 @@ public final class io/getstream/video/android/core/StreamVideoBuilder { public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;)V public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;)V public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;J)V - public fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JZ)V - public synthetic fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Landroid/content/Context;Ljava/lang/String;Lio/getstream/video/android/core/GEO;Lio/getstream/video/android/model/User;Ljava/lang/String;Lkotlin/jvm/functions/Function2;Lio/getstream/video/android/core/socket/common/token/TokenProvider;Lio/getstream/video/android/core/logging/LoggingLevel;Lio/getstream/video/android/core/notifications/NotificationConfig;Lkotlin/jvm/functions/Function1;JZLjava/lang/String;ZLio/getstream/video/android/core/notifications/internal/service/CallServiceConfig;Ljava/lang/String;Lio/getstream/video/android/core/sounds/Sounds;ZLio/getstream/video/android/core/permission/android/StreamPermissionCheck;ILjava/lang/String;Lorg/webrtc/ManagedAudioProcessingFactory;JILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun build ()Lio/getstream/video/android/core/StreamVideo; } @@ -4227,16 +4226,18 @@ public final class io/getstream/video/android/core/notifications/DefaultNotifica public final class io/getstream/video/android/core/notifications/NotificationConfig { public fun ()V - public fun (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;Lkotlin/jvm/functions/Function0;Z)V - public synthetic fun (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;Lkotlin/jvm/functions/Function0;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;ZLkotlin/jvm/functions/Function0;Z)V + public synthetic fun (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;ZLkotlin/jvm/functions/Function0;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/util/List; public final fun component2 ()Lkotlin/jvm/functions/Function0; public final fun component3 ()Lio/getstream/video/android/core/notifications/NotificationHandler; - public final fun component4 ()Lkotlin/jvm/functions/Function0; - public final fun component5 ()Z - public final fun copy (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;Lkotlin/jvm/functions/Function0;Z)Lio/getstream/video/android/core/notifications/NotificationConfig; - public static synthetic fun copy$default (Lio/getstream/video/android/core/notifications/NotificationConfig;Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;Lkotlin/jvm/functions/Function0;ZILjava/lang/Object;)Lio/getstream/video/android/core/notifications/NotificationConfig; + public final fun component4 ()Z + public final fun component5 ()Lkotlin/jvm/functions/Function0; + public final fun component6 ()Z + public final fun copy (Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;ZLkotlin/jvm/functions/Function0;Z)Lio/getstream/video/android/core/notifications/NotificationConfig; + public static synthetic fun copy$default (Lio/getstream/video/android/core/notifications/NotificationConfig;Ljava/util/List;Lkotlin/jvm/functions/Function0;Lio/getstream/video/android/core/notifications/NotificationHandler;ZLkotlin/jvm/functions/Function0;ZILjava/lang/Object;)Lio/getstream/video/android/core/notifications/NotificationConfig; public fun equals (Ljava/lang/Object;)Z + public final fun getAutoRegisterPushDevice ()Z public final fun getHideRingingNotificationInForeground ()Z public final fun getNotificationHandler ()Lio/getstream/video/android/core/notifications/NotificationHandler; public final fun getPushDeviceGenerators ()Ljava/util/List; From a1fbad4da60bb6524c24e87d1548a9e12efaa4b5 Mon Sep 17 00:00:00 2001 From: Liviu Timar <65943217+liviu-timar@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:45:25 +0200 Subject: [PATCH 6/6] Clean up --- .../core/notifications/internal/service/CallService.kt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt index 8ca067a45c..6d1af4606a 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt @@ -211,8 +211,7 @@ internal open class CallService : Service() { ) == PackageManager.PERMISSION_GRANTED StreamLog.i(TAG) { "Has permission: $hasPermission" } StreamLog.i(TAG) { "Notification: $notification" } - if (hasPermission && notification != null - ) { + if (hasPermission && notification != null) { NotificationManagerCompat.from(context) .notify(INCOMING_CALL_NOTIFICATION_ID, notification) } @@ -239,9 +238,7 @@ internal open class CallService : Service() { } private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean = - safeCallWithDefault( - true, - ) { + safeCallWithDefault(true) { val activityManager = context.getSystemService( Context.ACTIVITY_SERVICE, ) as ActivityManager @@ -722,8 +719,7 @@ internal open class CallService : Service() { notification, TRIGGER_ONGOING_CALL, serviceType, - ).onError { - } + ) } }