Fixed speakerphone toggling during mobile calls
This commit is contained in:
@ -2434,6 +2434,20 @@ class BaresipService: Service() {
|
|||||||
handler.postDelayed(runnable, 500)
|
handler.postDelayed(runnable, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toggleSpeakerphone() {
|
||||||
|
speakerPhone = !speakerPhone
|
||||||
|
// Notify the UI to update the icon color
|
||||||
|
postServiceEvent(
|
||||||
|
ServiceEvent(
|
||||||
|
"speaker update,$speakerPhone",
|
||||||
|
arrayListOf(0L, 0L),
|
||||||
|
System.nanoTime()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// Apply the new audio route
|
||||||
|
ensureCommunicationMode()
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("WakelockTimeout", "Wakelock")
|
@SuppressLint("WakelockTimeout", "Wakelock")
|
||||||
private fun proximitySensing(enable: Boolean) {
|
private fun proximitySensing(enable: Boolean) {
|
||||||
if (enable) {
|
if (enable) {
|
||||||
|
|||||||
@ -643,23 +643,8 @@ private fun TopAppBar(
|
|||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = {
|
onClick = {
|
||||||
val aor = viewModel.selectedAor.value
|
// Unified toggle via BaresipService
|
||||||
val ua = uas.value.find { it.account.aor == aor }
|
BaresipService.instance?.toggleSpeakerphone()
|
||||||
val call = ua?.currentCall()
|
|
||||||
val connection =
|
|
||||||
if (call != null) ConnectionService.connections[call.callp] else null
|
|
||||||
if (connection != null) {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
connection.setAudioRoute(
|
|
||||||
if (isSpeakerOn)
|
|
||||||
android.telecom.CallAudioState.ROUTE_EARPIECE
|
|
||||||
else
|
|
||||||
android.telecom.CallAudioState.ROUTE_SPEAKER
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
BaresipService.speakerPhone = !isSpeakerOn
|
|
||||||
viewModel.updateSpeakerPhoneStatus(BaresipService.speakerPhone)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
alertTitle.value = speakerPhoneTitle
|
alertTitle.value = speakerPhoneTitle
|
||||||
|
|||||||
Reference in New Issue
Block a user