Introduced BaresipService.speakerPhoneAuto variable
This commit is contained in:
@ -638,6 +638,7 @@ private fun checkOnClick(ctx: Context): Result {
|
|||||||
|
|
||||||
if (newSpeakerPhone != oldSpeakerPhone) {
|
if (newSpeakerPhone != oldSpeakerPhone) {
|
||||||
Config.replaceVariable("speaker_phone", if (newSpeakerPhone) "yes" else "no")
|
Config.replaceVariable("speaker_phone", if (newSpeakerPhone) "yes" else "no")
|
||||||
|
BaresipService.speakerPhoneAuto = newSpeakerPhone
|
||||||
save = true
|
save = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -782,7 +782,7 @@ class BaresipService: Service() {
|
|||||||
"call outgoing" -> {
|
"call outgoing" -> {
|
||||||
if (call!!.status.value == "transferring")
|
if (call!!.status.value == "transferring")
|
||||||
break
|
break
|
||||||
if (Config.variable("speaker_phone") == "yes") {
|
if (speakerPhoneAuto) {
|
||||||
Log.d(TAG, "Auto-on speakerphone for outgoing call")
|
Log.d(TAG, "Auto-on speakerphone for outgoing call")
|
||||||
speakerPhone = true
|
speakerPhone = true
|
||||||
}
|
}
|
||||||
@ -792,16 +792,12 @@ class BaresipService: Service() {
|
|||||||
proximitySensing(proximitySensing)
|
proximitySensing(proximitySensing)
|
||||||
}
|
}
|
||||||
"call ringing" -> {
|
"call ringing" -> {
|
||||||
if (Config.variable("speaker_phone") == "yes")
|
|
||||||
speakerPhone = true
|
|
||||||
ConnectionService.connections[callp]?.setRinging()
|
ConnectionService.connections[callp]?.setRinging()
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
playRingBack()
|
playRingBack()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
"call progress" -> {
|
"call progress" -> {
|
||||||
if (Config.variable("speaker_phone") == "yes")
|
|
||||||
speakerPhone = true
|
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
@ -812,6 +808,10 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
"incoming call" -> {
|
"incoming call" -> {
|
||||||
|
if (speakerPhoneAuto) {
|
||||||
|
Log.d(TAG, "Auto-on speakerphone for incoming call")
|
||||||
|
speakerPhone = true
|
||||||
|
}
|
||||||
val peerUri = ev[1]
|
val peerUri = ev[1]
|
||||||
val toastMsg = if (Call.isAnyCallActive(applicationContext))
|
val toastMsg = if (Call.isAnyCallActive(applicationContext))
|
||||||
String.format(getString(R.string.call_auto_rejected),
|
String.format(getString(R.string.call_auto_rejected),
|
||||||
@ -845,6 +845,7 @@ class BaresipService: Service() {
|
|||||||
packageName
|
packageName
|
||||||
)
|
)
|
||||||
if (resourceId != 0) {
|
if (resourceId != 0) {
|
||||||
|
ensureCommunicationMode()
|
||||||
playUnInterrupted(resourceId, 1)
|
playUnInterrupted(resourceId, 1)
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Callwaiting tone $name.wav not found")
|
Log.e(TAG, "Callwaiting tone $name.wav not found")
|
||||||
@ -861,10 +862,6 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
"call incoming" -> {
|
"call incoming" -> {
|
||||||
if (Config.variable("speaker_phone") == "yes") {
|
|
||||||
Log.d(TAG, "Auto-on speakerphone for incoming call")
|
|
||||||
speakerPhone = true
|
|
||||||
}
|
|
||||||
val peerUri = ev[1]
|
val peerUri = ev[1]
|
||||||
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
||||||
if (Call.ofCallp(callp) == null)
|
if (Call.ofCallp(callp) == null)
|
||||||
@ -881,8 +878,6 @@ class BaresipService: Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
"call answered" -> {
|
"call answered" -> {
|
||||||
if (Config.variable("speaker_phone") == "yes")
|
|
||||||
speakerPhone = true
|
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
if (call!!.status.value == "incoming")
|
if (call!!.status.value == "incoming")
|
||||||
@ -894,8 +889,6 @@ class BaresipService: Service() {
|
|||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
}
|
}
|
||||||
"call established" -> {
|
"call established" -> {
|
||||||
if (Config.variable("speaker_phone") == "yes")
|
|
||||||
speakerPhone = true
|
|
||||||
ConnectionService.connections[callp]?.setActive()
|
ConnectionService.connections[callp]?.setActive()
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
nm.cancel(CALL_NOTIFICATION_ID)
|
nm.cancel(CALL_NOTIFICATION_ID)
|
||||||
@ -2258,6 +2251,7 @@ class BaresipService: Service() {
|
|||||||
var callVolume = 0
|
var callVolume = 0
|
||||||
@Volatile
|
@Volatile
|
||||||
var speakerPhone = false
|
var speakerPhone = false
|
||||||
|
var speakerPhoneAuto = false
|
||||||
var audioDelay = if (VERSION.SDK_INT < 31) 1500L else 500L
|
var audioDelay = if (VERSION.SDK_INT < 31) 1500L else 500L
|
||||||
var dynDns = false
|
var dynDns = false
|
||||||
var filesPath = ""
|
var filesPath = ""
|
||||||
|
|||||||
@ -177,8 +177,11 @@ object Config {
|
|||||||
val speakerPhone = previousVariable("speaker_phone")
|
val speakerPhone = previousVariable("speaker_phone")
|
||||||
if (speakerPhone != "") {
|
if (speakerPhone != "") {
|
||||||
config = "${config}speaker_phone $speakerPhone\n"
|
config = "${config}speaker_phone $speakerPhone\n"
|
||||||
} else {
|
BaresipService.speakerPhoneAuto = speakerPhone == "yes"
|
||||||
|
}
|
||||||
|
else {
|
||||||
config = "${config}speaker_phone no\n"
|
config = "${config}speaker_phone no\n"
|
||||||
|
BaresipService.speakerPhoneAuto = false
|
||||||
}
|
}
|
||||||
BaresipService.speakerPhone = false
|
BaresipService.speakerPhone = false
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ class ConnectionService : ConnectionService() {
|
|||||||
|
|
||||||
val ua = UserAgent.ofUap(uap)
|
val ua = UserAgent.ofUap(uap)
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
if (BaresipService.speakerPhone || Config.variable("speaker_phone") == "yes") {
|
if (BaresipService.speakerPhone || BaresipService.speakerPhoneAuto) {
|
||||||
BaresipService.speakerPhone = true
|
BaresipService.speakerPhone = true
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER)
|
connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER)
|
||||||
@ -122,7 +122,7 @@ class ConnectionService : ConnectionService() {
|
|||||||
val connection = BaresipConnection(uap, 0L)
|
val connection = BaresipConnection(uap, 0L)
|
||||||
pendingOutgoingConnection = connection
|
pendingOutgoingConnection = connection
|
||||||
|
|
||||||
if (BaresipService.speakerPhone || Config.variable("speaker_phone") == "yes") {
|
if (BaresipService.speakerPhone || BaresipService.speakerPhoneAuto) {
|
||||||
BaresipService.speakerPhone = true
|
BaresipService.speakerPhone = true
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER)
|
connection.setAudioRoute(CallAudioState.ROUTE_SPEAKER)
|
||||||
|
|||||||
Reference in New Issue
Block a user