template call service
This commit is contained in:
parent
59bf1ade88
commit
10e4018ac1
26
app/src/main/java/com/bshield/caller/CallConnection.kt
Normal file
26
app/src/main/java/com/bshield/caller/CallConnection.kt
Normal file
@ -0,0 +1,26 @@
|
||||
package com.bshield.caller
|
||||
|
||||
import android.telecom.Connection
|
||||
import android.telecom.DisconnectCause
|
||||
|
||||
class CallConnection() : Connection() {
|
||||
|
||||
// private var clientManager = ClientManager.getInstance(context)
|
||||
|
||||
// init {
|
||||
// audioModeIsVoip = true
|
||||
// }
|
||||
|
||||
// override fun onDisconnect() {
|
||||
// clientManager.endCall(this)
|
||||
// }
|
||||
//
|
||||
// override fun onAnswer() {
|
||||
// setActive()
|
||||
// clientManager.answerCall(this)
|
||||
// }
|
||||
//
|
||||
// override fun onReject() {
|
||||
// clientManager.rejectCall(this)
|
||||
// }
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.bshield.caller
|
||||
|
||||
import android.net.Uri
|
||||
import android.telecom.Connection
|
||||
import android.telecom.ConnectionRequest
|
||||
import android.telecom.ConnectionService
|
||||
import android.telecom.PhoneAccountHandle
|
||||
import android.telecom.TelecomManager
|
||||
|
||||
class CallConnectionService : ConnectionService() {
|
||||
override fun onCreateIncomingConnection(
|
||||
connectionManagerPhoneAccount: PhoneAccountHandle?,
|
||||
request: ConnectionRequest?
|
||||
): Connection {
|
||||
val from = request?.extras?.getString("from")
|
||||
val connection = CallConnection()
|
||||
connection.setAddress(Uri.parse("tel:$from"), TelecomManager.PRESENTATION_ALLOWED)
|
||||
connection.connectionProperties = Connection.PROPERTY_SELF_MANAGED
|
||||
connection.setRinging()
|
||||
return connection
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user