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

View file

@ -598,11 +598,14 @@ class CoreContext(val context: Context, coreConfig: Config) {
params.recordFile = LinphoneUtils.getRecordingFilePathForAddress(address)
if (localAddress != null) {
params.account = core.accountList.find { account ->
val account = core.accountList.find { account ->
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")
} else {
Log.e("[Context] Failed to find account matching address ${localAddress.asStringUriOnly()}")
}
}