mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
VoIP: always use silent for pending call notification
This commit is contained in:
parent
81f7932cb7
commit
a16086db6f
@ -144,10 +144,6 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
|
||||
ACTION_CALL_TERMINATED -> {
|
||||
handleCallTerminated(intent)
|
||||
}
|
||||
ACTION_ONGOING_CALL_BG -> {
|
||||
// there is an ongoing call but call activity is in background
|
||||
displayCallOnGoingInBackground(intent)
|
||||
}
|
||||
else -> {
|
||||
// Should not happen
|
||||
callRingPlayerIncoming?.stop()
|
||||
@ -278,26 +274,6 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
|
||||
notificationManager.notify(callId.hashCode(), notification)
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a call in progress notification.
|
||||
*/
|
||||
private fun displayCallOnGoingInBackground(intent: Intent) {
|
||||
Timber.v("## VOIP displayCallInProgressNotification")
|
||||
val callId = intent.getStringExtra(EXTRA_CALL_ID) ?: return
|
||||
val call = callManager.getCallById(callId) ?: return
|
||||
if (!knownCalls.contains(callId)) {
|
||||
Timber.v("Call in in background for unknown call $callId$")
|
||||
return
|
||||
}
|
||||
val opponentMatrixItem = getOpponentMatrixItem(call)
|
||||
|
||||
val notification = notificationUtils.buildPendingCallNotification(
|
||||
mxCall = call.mxCall,
|
||||
title = opponentMatrixItem?.getBestName() ?: call.mxCall.opponentUserId,
|
||||
fromBg = true)
|
||||
notificationManager.notify(callId.hashCode(), notification)
|
||||
}
|
||||
|
||||
fun addConnection(callConnection: CallConnection) {
|
||||
connections[callConnection.callId] = callConnection
|
||||
}
|
||||
@ -313,7 +289,6 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
|
||||
private const val ACTION_OUTGOING_RINGING_CALL = "im.vector.app.core.services.CallService.ACTION_OUTGOING_RINGING_CALL"
|
||||
private const val ACTION_CALL_CONNECTING = "im.vector.app.core.services.CallService.ACTION_CALL_CONNECTING"
|
||||
private const val ACTION_ONGOING_CALL = "im.vector.app.core.services.CallService.ACTION_ONGOING_CALL"
|
||||
private const val ACTION_ONGOING_CALL_BG = "im.vector.app.core.services.CallService.ACTION_ONGOING_CALL_BG"
|
||||
private const val ACTION_CALL_TERMINATED = "im.vector.app.core.services.CallService.ACTION_CALL_TERMINATED"
|
||||
private const val ACTION_NO_ACTIVE_CALL = "im.vector.app.core.services.CallService.NO_ACTIVE_CALL"
|
||||
// private const val ACTION_ACTIVITY_VISIBLE = "im.vector.app.core.services.CallService.ACTION_ACTIVITY_VISIBLE"
|
||||
@ -334,16 +309,6 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
}
|
||||
|
||||
fun onOnGoingCallBackground(context: Context,
|
||||
callId: String) {
|
||||
val intent = Intent(context, CallService::class.java)
|
||||
.apply {
|
||||
action = ACTION_ONGOING_CALL_BG
|
||||
putExtra(EXTRA_CALL_ID, callId)
|
||||
}
|
||||
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
}
|
||||
|
||||
fun onOutgoingCallRinging(context: Context,
|
||||
callId: String) {
|
||||
|
@ -323,18 +323,6 @@ class WebRtcCall(val mxCall: MxCall,
|
||||
remoteVideoTrack?.removeSink(it)
|
||||
}
|
||||
}
|
||||
if (remoteSurfaceRenderers.isEmpty()) {
|
||||
// The call is going to continue in background, so ensure notification is visible
|
||||
mxCall
|
||||
.takeIf { it.state is CallState.Connected }
|
||||
?.let { mxCall ->
|
||||
// Start background service with notification
|
||||
CallService.onOnGoingCallBackground(
|
||||
context = context,
|
||||
callId = mxCall.callId
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun setupOutgoingCall() = withContext(dispatcher) {
|
||||
|
@ -1323,6 +1323,7 @@ class RoomDetailViewModel @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe {
|
||||
Timber.v("Unread state: $it")
|
||||
setState { copy(unreadState = it) }
|
||||
}
|
||||
.disposeOnClear()
|
||||
|
@ -393,9 +393,9 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
fun buildPendingCallNotification(mxCall: MxCall,
|
||||
title: String,
|
||||
fromBg: Boolean = false): Notification {
|
||||
val builder = NotificationCompat.Builder(context, if (fromBg) CALL_NOTIFICATION_CHANNEL_ID else SILENT_NOTIFICATION_CHANNEL_ID)
|
||||
title: String): Notification {
|
||||
|
||||
val builder = NotificationCompat.Builder(context, SILENT_NOTIFICATION_CHANNEL_ID)
|
||||
.setContentTitle(ensureTitleNotEmpty(title))
|
||||
.apply {
|
||||
if (mxCall.isVideoCall) {
|
||||
@ -407,11 +407,6 @@ class NotificationUtils @Inject constructor(private val context: Context,
|
||||
.setSmallIcon(R.drawable.incoming_call_notification_transparent)
|
||||
.setCategory(NotificationCompat.CATEGORY_CALL)
|
||||
|
||||
if (fromBg) {
|
||||
builder.priority = NotificationCompat.PRIORITY_LOW
|
||||
builder.setOngoing(true)
|
||||
}
|
||||
|
||||
val rejectCallPendingIntent = buildRejectCallPendingIntent(mxCall.callId)
|
||||
|
||||
builder.addAction(
|
||||
|
@ -4,6 +4,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:style="@style/AlertStyle"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
Loading…
Reference in New Issue
Block a user