More audio fixes
This commit is contained in:
@@ -17,8 +17,6 @@ import android.content.Intent
|
|||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.pm.ServiceInfo
|
import android.content.pm.ServiceInfo
|
||||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
|
|
||||||
import android.content.pm.ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.database.ContentObserver
|
import android.database.ContentObserver
|
||||||
import android.graphics.ImageDecoder
|
import android.graphics.ImageDecoder
|
||||||
@@ -889,10 +887,8 @@ class BaresipService: Service() {
|
|||||||
proximitySensing(proximitySensing)
|
proximitySensing(proximitySensing)
|
||||||
}
|
}
|
||||||
"call ringing" -> {
|
"call ringing" -> {
|
||||||
if (!telecom) {
|
if (!telecom) ensureCommunicationMode()
|
||||||
ensureCommunicationMode()
|
|
||||||
playRingBack()
|
playRingBack()
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
"call progress" -> {
|
"call progress" -> {
|
||||||
@@ -900,7 +896,7 @@ class BaresipService: Service() {
|
|||||||
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
else {
|
else {
|
||||||
if (!telecom) playRingBack()
|
playRingBack()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -982,6 +978,7 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
"call answered" -> {
|
"call answered" -> {
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
|
ConnectionService.connections[callp]?.setActive()
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
if (call!!.status.value == "incoming")
|
if (call!!.status.value == "incoming")
|
||||||
call.status.value = "answered"
|
call.status.value = "answered"
|
||||||
@@ -992,7 +989,6 @@ class BaresipService: Service() {
|
|||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
}
|
}
|
||||||
"call established" -> {
|
"call established" -> {
|
||||||
ConnectionService.connections[callp]?.setActive()
|
|
||||||
ensureCommunicationMode()
|
ensureCommunicationMode()
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
nm.cancel(CALL_NOTIFICATION_ID)
|
nm.cancel(CALL_NOTIFICATION_ID)
|
||||||
@@ -1039,10 +1035,12 @@ class BaresipService: Service() {
|
|||||||
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
if ((ev[1].toInt() and Api.SDP_RECVONLY) != 0)
|
||||||
stopMediaPlayer()
|
stopMediaPlayer()
|
||||||
else {
|
else {
|
||||||
|
if (!telecom) {
|
||||||
ConnectionService.connections[callp]?.setRinging()
|
ConnectionService.connections[callp]?.setRinging()
|
||||||
playRingBack()
|
playRingBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (call.status.value == "connected" && !call.held && !call.onhold) {
|
if (call.status.value == "connected" && !call.held && !call.onhold) {
|
||||||
if (call.callOnHold.value || call.showOnHoldNotice.value) {
|
if (call.callOnHold.value || call.showOnHoldNotice.value) {
|
||||||
Log.d(TAG, "Safety guard: Clearing stuck hold flags for ${call.callp}")
|
Log.d(TAG, "Safety guard: Clearing stuck hold flags for ${call.callp}")
|
||||||
@@ -1755,16 +1753,15 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun foregroundServiceType(): Int {
|
private fun foregroundServiceType(): Int {
|
||||||
return if (VERSION.SDK_INT >= 34) {
|
var type = 0
|
||||||
ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
if (VERSION.SDK_INT >= 30) {
|
||||||
} else if (VERSION.SDK_INT >= 30) {
|
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
||||||
if (ContextCompat.checkSelfPermission(this, RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED)
|
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
|
||||||
FOREGROUND_SERVICE_TYPE_PHONE_CALL or FOREGROUND_SERVICE_TYPE_MICROPHONE
|
|
||||||
else
|
|
||||||
FOREGROUND_SERVICE_TYPE_PHONE_CALL
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
if (VERSION.SDK_INT >= 34) {
|
||||||
|
type = type or ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE
|
||||||
|
}
|
||||||
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("WakelockTimeout")
|
@SuppressLint("WakelockTimeout")
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ class ConnectionService : ConnectionService() {
|
|||||||
Connection.CAPABILITY_HOLD or
|
Connection.CAPABILITY_HOLD or
|
||||||
Connection.CAPABILITY_MERGE_CONFERENCE or
|
Connection.CAPABILITY_MERGE_CONFERENCE or
|
||||||
Connection.CAPABILITY_SWAP_CONFERENCE
|
Connection.CAPABILITY_SWAP_CONFERENCE
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 31)
|
||||||
connection.audioModeIsVoip = true
|
connection.audioModeIsVoip = true
|
||||||
|
|
||||||
val call = Call.ofCallp(callp)
|
val call = Call.ofCallp(callp)
|
||||||
@@ -123,6 +124,7 @@ class ConnectionService : ConnectionService() {
|
|||||||
Connection.CAPABILITY_HOLD or
|
Connection.CAPABILITY_HOLD or
|
||||||
Connection.CAPABILITY_MERGE_CONFERENCE or
|
Connection.CAPABILITY_MERGE_CONFERENCE or
|
||||||
Connection.CAPABILITY_SWAP_CONFERENCE
|
Connection.CAPABILITY_SWAP_CONFERENCE
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 31)
|
||||||
connection.audioModeIsVoip = true
|
connection.audioModeIsVoip = true
|
||||||
|
|
||||||
// Start the SIP connection logic
|
// Start the SIP connection logic
|
||||||
|
|||||||
Reference in New Issue
Block a user