Should prevent crash when failing to get account matching local address

This commit is contained in:
Sylvain Berfini 2022-03-16 13:56:56 +01:00
parent 71a2140dbd
commit 13878ee48d
2 changed files with 23 additions and 15 deletions

View file

@ -225,9 +225,11 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
it.consume { callLogGroup -> it.consume { callLogGroup ->
val remoteAddress = callLogGroup.lastCallLog.remoteAddress val remoteAddress = callLogGroup.lastCallLog.remoteAddress
val conferenceInfo = coreContext.core.findConferenceInformationFromUri(remoteAddress) val conferenceInfo = coreContext.core.findConferenceInformationFromUri(remoteAddress)
if (conferenceInfo != null) { when {
conferenceInfo != null -> {
navigateToConferenceWaitingRoom(remoteAddress.asStringUriOnly(), conferenceInfo.subject) navigateToConferenceWaitingRoom(remoteAddress.asStringUriOnly(), conferenceInfo.subject)
} else if (coreContext.core.callsNb > 0) { }
coreContext.core.callsNb > 0 -> {
Log.i("[History] Starting dialer with pre-filled URI ${remoteAddress.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}") Log.i("[History] Starting dialer with pre-filled URI ${remoteAddress.asStringUriOnly()}, is transfer? ${sharedViewModel.pendingCallTransfer}")
sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterCallLogsFragment) sharedViewModel.updateDialerAnimationsBasedOnDestination.value = Event(R.id.masterCallLogsFragment)
val args = Bundle() val args = Bundle()
@ -235,12 +237,15 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer) args.putBoolean("Transfer", sharedViewModel.pendingCallTransfer)
args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it args.putBoolean("SkipAutoCallStart", true) // If auto start call setting is enabled, ignore it
navigateToDialer(args) navigateToDialer(args)
} else { }
else -> {
val localAddress = callLogGroup.lastCallLog.localAddress val localAddress = callLogGroup.lastCallLog.localAddress
Log.i("[History] Starting call to ${remoteAddress.asStringUriOnly()} with local address ${localAddress.asStringUriOnly()}")
coreContext.startCall(remoteAddress, localAddress = localAddress) coreContext.startCall(remoteAddress, localAddress = localAddress)
} }
} }
} }
}
coreContext.core.resetMissedCallsCount() coreContext.core.resetMissedCallsCount()
coreContext.notificationsManager.dismissMissedCallNotification() coreContext.notificationsManager.dismissMissedCallNotification()

View file

@ -598,11 +598,14 @@ class CoreContext(val context: Context, coreConfig: Config) {
params.recordFile = LinphoneUtils.getRecordingFilePathForAddress(address) params.recordFile = LinphoneUtils.getRecordingFilePathForAddress(address)
if (localAddress != null) { if (localAddress != null) {
params.account = core.accountList.find { account -> val account = core.accountList.find { account ->
account.params.identityAddress?.weakEqual(localAddress) ?: false account.params.identityAddress?.weakEqual(localAddress) ?: false
} }
if (params.account != null) { if (account != null) {
params.account = account
Log.i("[Context] Using account matching address ${localAddress.asStringUriOnly()} as From") Log.i("[Context] Using account matching address ${localAddress.asStringUriOnly()} as From")
} else {
Log.e("[Context] Failed to find account matching address ${localAddress.asStringUriOnly()}")
} }
} }