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)
|
handleIncomingCall(call)
|
||||||
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
||||||
Log.d(TAG, "Auto-answering external call ${call.callp}")
|
Log.d(TAG, "Auto-answering external call ${call.callp}")
|
||||||
call.answer()
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
call.answer()
|
||||||
|
}, 2000)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
postServiceEvent(ServiceEvent(
|
postServiceEvent(ServiceEvent(
|
||||||
"call outgoing",
|
"call outgoing",
|
||||||
arrayListOf(ua.uap, call.callp),
|
arrayListOf(ua.uap, call.callp),
|
||||||
System.nanoTime())
|
System.nanoTime())
|
||||||
)
|
)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleExternalCallRemoved(telecomCall: android.telecom.Call) {
|
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() {
|
private fun stopMediaPlayer() {
|
||||||
mediaPlayer?.stop()
|
mediaPlayer?.stop()
|
||||||
mediaPlayer?.release()
|
mediaPlayer?.release()
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package com.tutpro.baresip
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.telecom.CallAudioState
|
import android.telecom.CallAudioState
|
||||||
import android.telecom.Connection
|
import android.telecom.Connection
|
||||||
import android.telecom.ConnectionRequest
|
import android.telecom.ConnectionRequest
|
||||||
@ -78,11 +80,12 @@ class ConnectionService : ConnectionService() {
|
|||||||
|
|
||||||
val ua = UserAgent.ofUap(uap)
|
val ua = UserAgent.ofUap(uap)
|
||||||
if (ua != null) {
|
if (ua != null) {
|
||||||
|
connection.setRinging()
|
||||||
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
if (ua.account.answerMode == Api.ANSWERMODE_AUTO) {
|
||||||
Log.d(TAG, "Auto-answering call $callp")
|
Log.d(TAG, "Auto-answering call $callp")
|
||||||
connection.onAnswer()
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
} else {
|
connection.onAnswer()
|
||||||
connection.setRinging()
|
}, 2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user