Improved mute handling so that Android system bar mic icon is not shown when call is muted
This commit is contained in:
@@ -1031,18 +1031,20 @@ class BaresipService: Service() {
|
||||
}
|
||||
updateStatusNotification()
|
||||
proximitySensing(proximitySensing)
|
||||
if (isMicMuted)
|
||||
setMicMute(true)
|
||||
}
|
||||
if (!isMainVisible)
|
||||
return
|
||||
}
|
||||
"call update" -> {
|
||||
val newHeldState = when (ev[1].toInt()) {
|
||||
Api.SDP_INACTIVE, Api.SDP_RECVONLY -> true
|
||||
else -> false
|
||||
}
|
||||
val connection = ConnectionService.connections[callp]
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
if (call != null) {
|
||||
val newHeldState = when (ev[1].toInt()) {
|
||||
Api.SDP_INACTIVE, Api.SDP_RECVONLY -> true
|
||||
else -> false
|
||||
}
|
||||
val connection = ConnectionService.connections[callp]
|
||||
if (call.held && !newHeldState) {
|
||||
Log.d(TAG, "Call ${call.callp} un-held by peer.")
|
||||
call.onhold = false
|
||||
@@ -1173,6 +1175,7 @@ class BaresipService: Service() {
|
||||
else -> DisconnectCause.REMOTE
|
||||
}
|
||||
connection.setDisconnected(DisconnectCause(cause))
|
||||
connection.safeDestroy()
|
||||
ConnectionService.connections.remove(callp)
|
||||
}
|
||||
if (call != null) {
|
||||
@@ -1201,15 +1204,8 @@ class BaresipService: Service() {
|
||||
}
|
||||
val isConference = call.conferenceCall
|
||||
val hasOtherCalls = synchronized(calls) { calls.any { it.ua == ua } }
|
||||
if (noMoreCalls) {
|
||||
aec?.release()
|
||||
aec = null
|
||||
agc?.release()
|
||||
agc = null
|
||||
ns?.release()
|
||||
ns = null
|
||||
recorderSessionId = 0
|
||||
}
|
||||
if (noMoreCalls)
|
||||
releaseAudioEffects()
|
||||
updateStatusNotification()
|
||||
if (isConference && !hasOtherCalls) {
|
||||
Log.d(TAG, "Last conference call closed, scheduling mixminus unload")
|
||||
@@ -1236,9 +1232,9 @@ class BaresipService: Service() {
|
||||
!reason.startsWith("Connection reset by")
|
||||
|
||||
val missed = call.dir == "in" && call.startTime == null && !call.rejected
|
||||
val completedElsewhere = missed && ev[2].startsWith("SIP") &&
|
||||
ev[2].contains(";cause=200")
|
||||
if (ua.account.callHistory) {
|
||||
val completedElsewhere = missed && ev[2].startsWith("SIP") &&
|
||||
ev[2].contains(";cause=200")
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val history = CallHistoryNew(aor, call.peerUri, call.dir)
|
||||
history.stopTime = GregorianCalendar()
|
||||
@@ -2512,7 +2508,7 @@ class BaresipService: Service() {
|
||||
)
|
||||
}
|
||||
if (isMicMuted) {
|
||||
isMicMuted = false
|
||||
setMicMute(false)
|
||||
postServiceEvent(
|
||||
ServiceEvent(
|
||||
"mic muted,false",
|
||||
@@ -2771,6 +2767,7 @@ class BaresipService: Service() {
|
||||
cm.unregisterNetworkCallback(networkCallback)
|
||||
if (this::androidContactsObserver.isInitialized)
|
||||
contentResolver.unregisterContentObserver(androidContactsObserver)
|
||||
releaseAudioEffects()
|
||||
isServiceClean = true
|
||||
}
|
||||
}
|
||||
@@ -2849,6 +2846,19 @@ class BaresipService: Service() {
|
||||
private var btAdapter: BluetoothAdapter? = null
|
||||
private var audioFocusRequest: AudioFocusRequest? = null
|
||||
|
||||
private fun releaseAudioEffects() {
|
||||
aec?.enabled = false
|
||||
aec?.release()
|
||||
aec = null
|
||||
agc?.enabled = false
|
||||
agc?.release()
|
||||
agc = null
|
||||
ns?.enabled = false
|
||||
ns?.release()
|
||||
ns = null
|
||||
recorderSessionId = 0
|
||||
}
|
||||
|
||||
var rt: Ringtone? = null
|
||||
|
||||
var colorblind = false
|
||||
@@ -2873,6 +2883,15 @@ class BaresipService: Service() {
|
||||
return PhoneAccountHandle(componentName, PHONE_ACCOUNT_ID)
|
||||
}
|
||||
|
||||
fun setMicMute(mute: Boolean) {
|
||||
instance?.let {
|
||||
val am = it.getSystemService(AUDIO_SERVICE) as AudioManager
|
||||
am.isMicrophoneMute = mute
|
||||
}
|
||||
isMicMuted = mute
|
||||
Api.calls_mute(mute)
|
||||
}
|
||||
|
||||
fun postServiceEvent(event: ServiceEvent) {
|
||||
synchronized(serviceEvents) {
|
||||
serviceEvents.add(event)
|
||||
|
||||
Reference in New Issue
Block a user