Added error toast with reason when call ends in error

This commit is contained in:
Sylvain Berfini 2024-04-29 13:49:54 +02:00
parent 0239d3a3a6
commit 7e06c5d85a
6 changed files with 75 additions and 5 deletions

View file

@ -166,6 +166,16 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
showCallActivity()
}
}
Call.State.Error -> {
val errorInfo = call.errorInfo
Log.w(
"$TAG Call error reason is [${errorInfo.reason}](${errorInfo.protocolCode}): ${errorInfo.phrase}"
)
val text = LinphoneUtils.getCallErrorInfoToast(call)
redToastToShowEvent.postValue(
Event(Pair(text, org.linphone.R.drawable.warning_circle))
)
}
else -> {
}
}

View file

@ -185,7 +185,11 @@ class CallActivity : GenericActivity() {
}
callViewModel.goToEndedCallEvent.observe(this) {
it.consume {
it.consume { message ->
if (message.isNotEmpty()) {
showRedToast(message, R.drawable.warning_circle)
}
val action = ActiveCallFragmentDirections.actionGlobalEndedCallFragment()
findNavController(R.id.call_nav_container).navigate(action)
}

View file

@ -140,8 +140,8 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<Boolean>>()
}
val goToEndedCallEvent: MutableLiveData<Event<Boolean>> by lazy {
MutableLiveData<Event<Boolean>>()
val goToEndedCallEvent: MutableLiveData<Event<String>> by lazy {
MutableLiveData<Event<String>>()
}
val requestRecordAudioPermission: MutableLiveData<Event<Boolean>> by lazy {
@ -256,13 +256,23 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
"$TAG Failed to get a valid call to display, go to ended call fragment"
)
updateCallDuration()
goToEndedCallEvent.postValue(Event(true))
val text = if (call.state == Call.State.Error) {
LinphoneUtils.getCallErrorInfoToast(call)
} else {
""
}
goToEndedCallEvent.postValue(Event(text))
}
} else {
updateCallDuration()
Log.i("$TAG Call is ending, go to ended call fragment")
// Show that call was ended for a few seconds, then leave
goToEndedCallEvent.postValue(Event(true))
val text = if (call.state == Call.State.Error) {
LinphoneUtils.getCallErrorInfoToast(call)
} else {
""
}
goToEndedCallEvent.postValue(Event(text))
}
} else {
val videoEnabled = call.currentParams.isVideoEnabled

View file

@ -40,6 +40,7 @@ import org.linphone.core.ChatRoom
import org.linphone.core.ConferenceInfo
import org.linphone.core.Core
import org.linphone.core.Factory
import org.linphone.core.Reason
import org.linphone.core.tools.Log
import org.linphone.ui.main.contacts.model.ContactAvatarModel
@ -121,6 +122,37 @@ class LinphoneUtils {
}
}
@WorkerThread
fun getCallErrorInfoToast(call: Call): String {
val errorInfo = call.errorInfo
Log.w(
"$TAG Call error reason is [${errorInfo.reason}](${errorInfo.protocolCode}): ${errorInfo.phrase}"
)
return when (errorInfo.reason) {
Reason.Busy -> {
AppUtils.getString(R.string.toast_call_error_user_busy)
}
Reason.IOError -> {
AppUtils.getString(R.string.toast_call_error_io_error)
}
Reason.NotAcceptable -> {
AppUtils.getString(R.string.toast_call_error_incompatible_media_params)
}
Reason.NotFound -> {
AppUtils.getString(R.string.toast_call_error_user_not_found)
}
Reason.ServerTimeout -> {
AppUtils.getString(R.string.toast_call_error_server_timeout)
}
Reason.TemporarilyUnavailable -> {
AppUtils.getString(R.string.toast_call_error_temporarily_unavailable)
}
else -> {
"${errorInfo.protocolCode} / ${errorInfo.phrase}"
}
}
}
@WorkerThread
fun isEndToEndEncryptedChatAvailable(core: Core): Boolean {
return core.isLimeX3DhEnabled &&

View file

@ -107,6 +107,13 @@
<string name="toast_failed_to_join_conference">Echec lors de la connexion à la conférence!</string>
<string name="toast_remote_provisioning_config_applied">Configuration appliquée avec succès</string>
<string name="toast_remote_provisioning_config_failed">Erreur durant la récupération ou l\'application de la configuration</string>
<string name="toast_call_error_user_busy">L\'utilisateur est occupé</string>
<string name="toast_call_error_user_not_found">L\'utilisateur n\'a pu être trouvé</string>
<string name="toast_call_error_incompatible_media_params">Paramètres media incompatibles</string>
<string name="toast_call_error_network_unreachable">Le réseau n\'est pas joignable</string>
<string name="toast_call_error_io_error">Service indisponible ou erreur réseau</string>
<string name="toast_call_error_server_timeout">Délai d\'attente du serveur dépassé</string>
<string name="toast_call_error_temporarily_unavailable">Temporairement indisponible</string>
<!-- Assistant related string (account register / login / etc...) -->
<string name="assistant_dialog_general_terms_and_privacy_policy_title">Conditions de service &amp; politique de confidentialité</string>

View file

@ -142,6 +142,13 @@
<string name="toast_failed_to_join_conference">Failed to join conference!</string>
<string name="toast_remote_provisioning_config_applied">Configuration successfully applied</string>
<string name="toast_remote_provisioning_config_failed">Error while trying to download and apply remote configuration</string>
<string name="toast_call_error_user_busy">User is busy</string>
<string name="toast_call_error_user_not_found">User has not been found</string>
<string name="toast_call_error_incompatible_media_params">Incompatible media parameters</string>
<string name="toast_call_error_network_unreachable">Network is unreachable</string>
<string name="toast_call_error_io_error">Service unavailable or network error</string>
<string name="toast_call_error_server_timeout">Server timeout</string>
<string name="toast_call_error_temporarily_unavailable">Temporarily unavailable</string>
<!-- Assistant related string (account register / login / etc...) -->
<string name="assistant_dialog_general_terms_and_privacy_policy_title">General terms &amp; privacy policy</string>