Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions stream-video-android-core/api/stream-video-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -13189,6 +13189,7 @@ public class io/getstream/video/android/core/notifications/DefaultNotificationHa
public fun getRejectAction (Landroid/app/PendingIntent;)Landroidx/core/app/NotificationCompat$Action;
public fun getRingingCallNotification (Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZLjava/util/Map;)Landroid/app/Notification;
public fun getSettingUpCallNotification ()Landroid/app/Notification;
public fun getSettingUpCallNotification (Ljava/lang/String;Lio/getstream/video/android/model/StreamCallId;)Landroid/app/Notification;
public fun getStreamNotificationDispatcher ()Lio/getstream/video/android/core/notifications/dispatchers/NotificationDispatcher;
public fun isInForeground ()Z
public fun maybeCreateChannel (Ljava/lang/String;Landroid/content/Context;Lkotlin/jvm/functions/Function1;)V
Expand Down Expand Up @@ -13441,6 +13442,7 @@ public class io/getstream/video/android/core/notifications/handlers/StreamDefaul
public fun getOngoingCallNotification (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZILjava/util/Map;)Landroid/app/Notification;
public fun getRingingCallNotification (Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZLjava/util/Map;)Landroid/app/Notification;
public fun getSettingUpCallNotification ()Landroid/app/Notification;
public fun getSettingUpCallNotification (Ljava/lang/String;Lio/getstream/video/android/model/StreamCallId;)Landroid/app/Notification;
public fun onCallNotificationUpdate (Lio/getstream/video/android/core/Call;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun onLiveCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;Ljava/util/Map;)V
public fun onMissedCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;Ljava/util/Map;)V
Expand Down Expand Up @@ -13544,15 +13546,16 @@ public abstract interface class io/getstream/video/android/core/notifications/ha
public abstract fun onRingingCall (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;Ljava/util/Map;)V
}

public abstract interface class io/getstream/video/android/core/notifications/handlers/StreamNotificationProvider : io/getstream/video/android/core/notifications/handlers/StreamNotificationProviderWithPayload {
public abstract interface class io/getstream/video/android/core/notifications/handlers/StreamNotificationProvider : io/getstream/video/android/core/notifications/handlers/StreamNotificationProviderWithPayload, io/getstream/video/android/core/notifications/handlers/StreamSettingUpCallNotificationProvider {
public fun getIncomingCallNotification (Landroid/app/PendingIntent;Landroid/app/PendingIntent;Landroid/app/PendingIntent;Ljava/lang/String;Z)Landroid/app/Notification;
public fun getMissedCallNotification (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;)Landroid/app/Notification;
public static synthetic fun getMissedCallNotification$default (Lio/getstream/video/android/core/notifications/handlers/StreamNotificationProvider;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ILjava/lang/Object;)Landroid/app/Notification;
public fun getOngoingCallNotification (Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZI)Landroid/app/Notification;
public static synthetic fun getOngoingCallNotification$default (Lio/getstream/video/android/core/notifications/handlers/StreamNotificationProvider;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZIILjava/lang/Object;)Landroid/app/Notification;
public fun getRingingCallNotification (Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;Z)Landroid/app/Notification;
public static synthetic fun getRingingCallNotification$default (Lio/getstream/video/android/core/notifications/handlers/StreamNotificationProvider;Lio/getstream/video/android/core/RingingState;Lio/getstream/video/android/model/StreamCallId;Ljava/lang/String;ZILjava/lang/Object;)Landroid/app/Notification;
public abstract fun getSettingUpCallNotification ()Landroid/app/Notification;
public fun getSettingUpCallNotification ()Landroid/app/Notification;
public fun getSettingUpCallNotification (Ljava/lang/String;Lio/getstream/video/android/model/StreamCallId;)Landroid/app/Notification;
}

public abstract interface class io/getstream/video/android/core/notifications/handlers/StreamNotificationProviderWithPayload {
Expand Down Expand Up @@ -13589,6 +13592,10 @@ public abstract interface class io/getstream/video/android/core/notifications/ha
public abstract fun updateOutgoingCallNotification (Lio/getstream/video/android/core/Call;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}

public abstract interface class io/getstream/video/android/core/notifications/handlers/StreamSettingUpCallNotificationProvider {
public abstract fun getSettingUpCallNotification (Ljava/lang/String;Lio/getstream/video/android/model/StreamCallId;)Landroid/app/Notification;
}

public final class io/getstream/video/android/core/notifications/internal/receivers/ToggleCameraBroadcastReceiver : android/content/BroadcastReceiver {
public fun <init> (Lkotlinx/coroutines/CoroutineScope;)V
public fun onReceive (Landroid/content/Context;Landroid/content/Intent;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@
.build()
}

@Deprecated(
"Use StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
replaceWith = ReplaceWith(
"StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
),
level = DeprecationLevel.WARNING,
)
override fun getSettingUpCallNotification(): Notification? {

Check warning on line 254 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VTUX1wrgZnApz72&open=AZ1I6VTUX1wrgZnApz72&pullRequest=1639
val channelId = application.getString(
R.string.stream_video_call_setup_notification_channel_id,
)
Expand Down Expand Up @@ -277,6 +284,11 @@
}
}

override fun getSettingUpCallNotification(
trigger: String,
callId: StreamCallId,
): Notification? = getSettingUpCallNotification()

Check warning on line 290 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/DefaultNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Deprecated code should not be used.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VTUX1wrgZnApz73&open=AZ1I6VTUX1wrgZnApz73&pullRequest=1639

override suspend fun onCallNotificationUpdate(call: Call): Notification? {
coroutineScope {
val localUser = StreamVideo.instance().state.user.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import io.getstream.video.android.core.notifications.dispatchers.DefaultNotificationDispatcher
import io.getstream.video.android.core.notifications.dispatchers.NotificationDispatcher
import io.getstream.video.android.core.notifications.extractor.DefaultNotificationContentExtractor
import io.getstream.video.android.core.notifications.internal.service.CallService.Companion.TRIGGER_INCOMING_CALL
import io.getstream.video.android.core.notifications.internal.service.ServiceLauncher
import io.getstream.video.android.core.utils.isAppInForeground
import io.getstream.video.android.core.utils.safeCall
Expand Down Expand Up @@ -528,7 +529,14 @@
}
}

@Deprecated(
"Use StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
replaceWith = ReplaceWith(
"StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
),
level = DeprecationLevel.WARNING,
)
override fun getSettingUpCallNotification(): Notification? {

Check warning on line 539 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamDefaultNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VVEX1wrgZnApz76&open=AZ1I6VVEX1wrgZnApz76&pullRequest=1639
logger.d { "[getSettingUpCallNotification]" }
val channelId = notificationChannels.outgoingCallChannel.id
val title = application.getString(R.string.stream_video_call_setup_notification_title)
Expand All @@ -543,6 +551,57 @@
}
}

override fun getSettingUpCallNotification(trigger: String, callId: StreamCallId): Notification? {
return when (trigger) {
/**
* TODO: This logic is duplicated with getIncomingCallNotificationInternal.

Check warning on line 557 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamDefaultNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VVEX1wrgZnApz77&open=AZ1I6VVEX1wrgZnApz77&pullRequest=1639
* Update it soon
*/

TRIGGER_INCOMING_CALL -> {
val title = application.getString(
R.string.stream_video_call_setup_notification_title,
)
val description =
application.getString(R.string.stream_video_call_setup_notification_description)

val notificationChannel = when {
isAppInForeground() && hideRingingNotificationInForeground ->
notificationChannels.incomingCallLowImportanceChannel
else -> notificationChannels.incomingCallChannel
}

val fullScreenPendingIntent = intentResolver.searchIncomingCallPendingIntent(
callId,
payload = emptyMap(),
)

if (fullScreenPendingIntent == null) {
logger.w {
"[getSettingUpCallNotification] fullScreenPendingIntent is null; lock-screen wake-up may not work."
}
}
return ensureChannelAndBuildNotification(notificationChannel) {
priority = if (hideRingingNotificationInForeground) {
NotificationCompat.PRIORITY_LOW
} else {
NotificationCompat.PRIORITY_MAX
}
setContentTitle(title)
setContentText(description)
setSmallIcon(R.drawable.stream_video_ic_call)
setChannelId(notificationChannel.id)
setOngoing(true)
setCategory(NotificationCompat.CATEGORY_CALL)
setFullScreenIntent(fullScreenPendingIntent, true)
setContentIntent(fullScreenPendingIntent)
}
}

else -> getSettingUpCallNotification()

Check warning on line 601 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamDefaultNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Deprecated code should not be used.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VVEX1wrgZnApz78&open=AZ1I6VVEX1wrgZnApz78&pullRequest=1639
}
}

@OptIn(ExperimentalStreamVideoApi::class)
private inline fun getOngoingCallNotificationInternal(
callId: StreamCallId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@
): Notification?
}

interface StreamSettingUpCallNotificationProvider {

Check warning on line 186 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this interface functional or replace it with a function type.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VUpX1wrgZnApz75&open=AZ1I6VUpX1wrgZnApz75&pullRequest=1639
fun getSettingUpCallNotification(trigger: String, callId: StreamCallId): Notification?
}

interface StreamNotificationUpdatesProvider {

/**
Expand Down Expand Up @@ -228,7 +232,7 @@
): Notification?
}

interface StreamNotificationProvider : StreamNotificationProviderWithPayload {
interface StreamNotificationProvider : StreamNotificationProviderWithPayload, StreamSettingUpCallNotificationProvider {

/**
* Customize the notification when you receive a push notification for ringing call with type [RingingState.Incoming]
Expand Down Expand Up @@ -348,7 +352,22 @@
*
* @return A [Notification] object.
*/
fun getSettingUpCallNotification(): Notification?
@Deprecated(
"Use StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
replaceWith = ReplaceWith(
"StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
),
level = DeprecationLevel.WARNING,
)
fun getSettingUpCallNotification(): Notification? = null

Check warning on line 362 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VUpX1wrgZnApz74&open=AZ1I6VUpX1wrgZnApz74&pullRequest=1639

// Inside StreamNotificationProvider interface, add:
override fun getSettingUpCallNotification(
trigger: String,
callId: StreamCallId,
): Notification? {
return getSettingUpCallNotification()

Check warning on line 369 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/handlers/StreamNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Deprecated code should not be used.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I8yTDct5v2qzWJcxA&open=AZ1I8yTDct5v2qzWJcxA&pullRequest=1639
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,18 @@
payload: Map<String, Any?>,
): Notification? = null

@Deprecated(
"Use StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
replaceWith = ReplaceWith(
"StreamSettingUpCallNotificationProvider.getSettingUpCallNotification(trigger,callId)",
),
level = DeprecationLevel.WARNING,
)
override fun getSettingUpCallNotification(): Notification? = null

Check warning on line 125 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/NoOpNotificationHandler.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not forget to remove this deprecated code someday.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VRBX1wrgZnApz71&open=AZ1I6VRBX1wrgZnApz71&pullRequest=1639
override fun getSettingUpCallNotification(
trigger: String,
callId: StreamCallId,
): Notification? = null

@Deprecated(
level = DeprecationLevel.ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
private fun logIntentExtras(intent: Intent?) {
if (intent != null) {
val bundle = intent.extras
val keys = bundle?.keySet()

Check warning on line 164 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Make this collection immutable.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz7z&open=AZ1I6VPmX1wrgZnApz7z&pullRequest=1639
if (keys != null) {
val sb = StringBuilder()
for (key in keys) {
Expand Down Expand Up @@ -202,7 +202,7 @@
private fun handleCallIntent(
params: CallIntentParams,
intent: Intent?,
flags: Int,

Check warning on line 205 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove these unused function parameters.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz7v&open=AZ1I6VPmX1wrgZnApz7v&pullRequest=1639
startId: Int,
): Int {
maybeHandleMediaIntent(intent, params.callId)
Expand All @@ -216,11 +216,16 @@
* Mandatory, if not called then it will throw exception if we directly decide to stop the service.
* For example: it will stop the service if [verifyPermissions] is false
*/
promoteToFgServiceIfNoActiveCall(params.streamVideo, notificationId, params.trigger)
promoteToFgServiceIfNoActiveCall(
params.streamVideo,
notificationId,
params.trigger,
params.callId,
)
val call = params.streamVideo.call(params.callId.type, params.callId.id)

// Rendering incoming call does not need audio/video permissions
if (params.trigger != TRIGGER_INCOMING_CALL) {

Check warning on line 228 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this "if" statement with the nested one.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz70&open=AZ1I6VPmX1wrgZnApz70&pullRequest=1639
if (!verifyPermissions(
params.streamVideo,
call,
Expand Down Expand Up @@ -304,7 +309,7 @@
): CallServiceHandleNotificationResult {
logHandleStart(trigger, call, notificationId)

if (notification == null) { // TODO Rahul check if livestream guest/host will get stuck here

Check warning on line 312 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz7x&open=AZ1I6VPmX1wrgZnApz7x&pullRequest=1639
return handleNullNotification(trigger, callId, call, notificationId)
}

Expand Down Expand Up @@ -350,7 +355,7 @@
trigger: String,
callId: StreamCallId,
call: Call,
fallbackNotificationId: Int,

Check warning on line 358 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused function parameter "fallbackNotificationId".

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz7w&open=AZ1I6VPmX1wrgZnApz7w&pullRequest=1639
): CallServiceHandleNotificationResult {
if (trigger != TRIGGER_REMOVE_INCOMING_CALL) {
logger.e {
Expand Down Expand Up @@ -645,7 +650,7 @@
* Temp Fix!! The observeRingingState scope was getting cancelled and as a result,
* ringing state was not properly updated
*/
serviceStateController.soundPlayer?.stopCallSound() // TODO should check which call owns the sound

Check warning on line 653 in stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=GetStream_stream-video-android&issues=AZ1I6VPmX1wrgZnApz7y&open=AZ1I6VPmX1wrgZnApz7y&pullRequest=1639
serviceScope.cancel()
stopSelf()
}
Expand All @@ -654,8 +659,9 @@
videoClient: StreamVideoClient,
notificationId: Int,
trigger: String,
callId: StreamCallId,
) {
videoClient.getSettingUpCallNotification()?.let { notification ->
videoClient.getSettingUpCallNotification(trigger, callId)?.let { notification ->
startForegroundWithServiceType(
notificationId,
notification,
Expand Down
Loading