Using call.callLog.remoteAddress() instead of call.remoteAddress() to have Address' displayName use P-Asserted-Identity info if available

This commit is contained in:
Sylvain Berfini 2024-06-24 14:24:16 +02:00
parent c6550b6256
commit 515b645b89
6 changed files with 15 additions and 12 deletions

View file

@ -536,7 +536,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
.format(missedCallCount.toString())
Log.i("$TAG Updating missed calls notification count to $missedCallCount")
} else {
val remoteAddress = call.remoteAddress
val remoteAddress = call.callLog.remoteAddress
val friend: Friend? = coreContext.contactsManager.findContactByAddress(remoteAddress)
body = context.getString(R.string.notification_missed_call)
.format(friend?.name ?: LinphoneUtils.getDisplayName(remoteAddress))
@ -910,7 +910,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
val declineIntent = getCallDeclinePendingIntent(notifiable)
val answerIntent = getCallAnswerPendingIntent(notifiable)
val remoteAddress = call.remoteAddress
val remoteAddress = call.callLog.remoteAddress
val remoteContactAddress = call.remoteContactAddress
val conferenceInfo = if (remoteContactAddress != null) {
call.core.findConferenceInformationFromUri(remoteContactAddress) ?: call.callLog.conferenceInfo

View file

@ -81,7 +81,7 @@ class TelecomManager @WorkerThread constructor(context: Context) {
fun onCallCreated(call: Call) {
Log.i("$TAG Call created: $call")
val address = call.remoteAddress
val address = call.callLog.remoteAddress
val friend = coreContext.contactsManager.findContactByAddress(address)
val displayName = friend?.name ?: LinphoneUtils.getDisplayName(address)

View file

@ -42,7 +42,7 @@ class CallModel @WorkerThread constructor(val call: Call) {
val isPaused = MutableLiveData<Boolean>()
val friend = coreContext.contactsManager.findContactByAddress(call.remoteAddress)
val friend = coreContext.contactsManager.findContactByAddress(call.callLog.remoteAddress)
val contact = MutableLiveData<ContactAvatarModel>()
@ -58,16 +58,17 @@ class CallModel @WorkerThread constructor(val call: Call) {
call.addListener(callListener)
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(call.remoteAddress)
val remoteAddress = call.callLog.remoteAddress
val avatarModel = if (conferenceInfo != null) {
coreContext.contactsManager.getContactAvatarModelForConferenceInfo(conferenceInfo)
} else {
coreContext.contactsManager.getContactAvatarModelForAddress(
call.remoteAddress
remoteAddress
)
}
contact.postValue(avatarModel)
displayName.postValue(
avatarModel.friend.name ?: LinphoneUtils.getDisplayName(call.remoteAddress)
avatarModel.friend.name ?: LinphoneUtils.getDisplayName(remoteAddress)
)
state.postValue(LinphoneUtils.callStateToString(call.state))

View file

@ -245,15 +245,16 @@ class CallsViewModel @UiThread constructor() : GenericViewModel() {
}
callsTopBarIcon.postValue(R.drawable.phone_pause)
if (found != null) {
val remoteAddress = found.callLog.remoteAddress
val conference = found.conference
if (conference != null) {
callsTopBarLabel.postValue(conference.subject)
} else {
val contact = coreContext.contactsManager.findContactByAddress(
found.remoteAddress
remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(found.remoteAddress)
contact?.name ?: LinphoneUtils.getDisplayName(remoteAddress)
)
}
callsTopBarStatus.postValue(LinphoneUtils.callStateToString(found.state))
@ -275,11 +276,12 @@ class CallsViewModel @UiThread constructor() : GenericViewModel() {
if (conference != null) {
callsTopBarLabel.postValue(conference.subject)
} else {
val remoteAddress = call.callLog.remoteAddress
val contact = coreContext.contactsManager.findContactByAddress(
call.remoteAddress
remoteAddress
)
callsTopBarLabel.postValue(
contact?.name ?: LinphoneUtils.getDisplayName(call.remoteAddress)
contact?.name ?: LinphoneUtils.getDisplayName(remoteAddress)
)
}
callsTopBarStatus.postValue(LinphoneUtils.callStateToString(call.state))

View file

@ -1118,7 +1118,7 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
isPausedByRemote.postValue(call.state == Call.State.PausedByRemote)
canBePaused.postValue(canCallBePaused())
val address = call.remoteAddress
val address = call.callLog.remoteAddress
val uri = if (corePreferences.onlyDisplaySipUriUsername) {
address.username ?: ""
} else {

View file

@ -398,7 +398,7 @@ class MainViewModel @UiThread constructor() : ViewModel() {
val currentCall = core.currentCall ?: core.calls.firstOrNull()
if (currentCall != null) {
val address = currentCall.remoteAddress
val address = currentCall.callLog.remoteAddress
val contact = coreContext.contactsManager.findContactByAddress(address)
val label = if (contact != null) {
contact.name ?: LinphoneUtils.getDisplayName(address)