When answer mode is auto, play ringing sound for 2 seconds before answering
This commit is contained in:
@ -1835,15 +1835,17 @@ class BaresipService: Service() {
|
||||
handleIncomingCall(call)
|
||||
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
||||
Log.d(TAG, "Auto-answering external call ${call.callp}")
|
||||
call.answer()
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
call.answer()
|
||||
}, 2000)
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
postServiceEvent(ServiceEvent(
|
||||
"call outgoing",
|
||||
arrayListOf(ua.uap, call.callp),
|
||||
System.nanoTime())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun handleExternalCallRemoved(telecomCall: android.telecom.Call) {
|
||||
@ -2170,16 +2172,6 @@ class BaresipService: Service() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun playUnInterrupted(raw: Int, count: Int) {
|
||||
val player = MediaPlayer.create(this, raw)
|
||||
player.setOnCompletionListener {
|
||||
it.stop()
|
||||
it.release()
|
||||
if (count > 1) playUnInterrupted(raw, count - 1)
|
||||
}
|
||||
player.start()
|
||||
}
|
||||
|
||||
private fun stopMediaPlayer() {
|
||||
mediaPlayer?.stop()
|
||||
mediaPlayer?.release()
|
||||
|
||||
@ -2,6 +2,8 @@ package com.tutpro.baresip
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.telecom.CallAudioState
|
||||
import android.telecom.Connection
|
||||
import android.telecom.ConnectionRequest
|
||||
@ -78,11 +80,12 @@ class ConnectionService : ConnectionService() {
|
||||
|
||||
val ua = UserAgent.ofUap(uap)
|
||||
if (ua != null) {
|
||||
connection.setRinging()
|
||||
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
||||
Log.d(TAG, "Auto-answering call $callp")
|
||||
connection.onAnswer()
|
||||
} else {
|
||||
connection.setRinging()
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
connection.onAnswer()
|
||||
}, 2000)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user