Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class CallForegroundService : Service() {

override fun onBind(intent: Intent?): IBinder? = null

@Suppress("ForegroundServiceType")
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val conversationName = intent?.getStringExtra(EXTRA_CONVERSATION_NAME)
val callExtras = intent?.getBundleExtra(EXTRA_CALL_INTENT_EXTRAS)
val notification = buildNotification(conversationName, callExtras)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val foregroundServiceType = resolveForegroundServiceType(callExtras)
val foregroundServiceType = resolveForegroundServiceType(callExtras)

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && foregroundServiceType != FOREGROUND_SERVICE_TYPE_ZERO) {
startForeground(NOTIFICATION_ID, notification, foregroundServiceType)
} else {
startForeground(NOTIFICATION_ID, notification)
Expand Down Expand Up @@ -107,6 +107,7 @@ class CallForegroundService : Service() {

companion object {
private const val NOTIFICATION_ID = 47001
private const val FOREGROUND_SERVICE_TYPE_ZERO = 0
private const val EXTRA_CONVERSATION_NAME = "extra_conversation_name"
private const val EXTRA_CALL_INTENT_EXTRAS = "extra_call_intent_extras"

Expand Down
Loading