From 0533642f59ab298a1bc3879ac54e9a5a0790237b Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 11 Jul 2019 18:19:21 +0300 Subject: [PATCH] - Set volume control stream to STREAM_VOICE_CALL also when '183 Session Progress' response is received. - Set volume control stream to STREAM_VOICE_CALL only once. - When call is closed, set volume control stream to DEFAULT_STREAM_TYPE. --- .../kotlin/com/tutpro/baresip/BaresipService.kt | 16 ++++++++++++++-- .../kotlin/com/tutpro/baresip/MainActivity.kt | 5 +++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index f7103cb4..ead01752 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -338,19 +338,27 @@ class BaresipService: Service() { else status[account_index] = R.drawable.dot_green updateStatusNotification() + if (!Utils.isVisible()) + return } "registering failed" -> { status[account_index] = R.drawable.dot_red updateStatusNotification() + if (!Utils.isVisible()) + return } "unregistering" -> { status[account_index] = R.drawable.dot_yellow updateStatusNotification() + if (!Utils.isVisible()) + return } "call progress", "call ringing" -> { if (!isAudioFocused()) { requestAudioFocus(AudioManager.STREAM_VOICE_CALL) setCallVolume() + } else { + return } } "call incoming" -> { @@ -430,6 +438,8 @@ class BaresipService: Service() { requestAudioFocus(AudioManager.STREAM_VOICE_CALL) setCallVolume() } + if (!Utils.isVisible()) + return } "call verified", "call secure" -> { val call = Call.find(callp) @@ -443,6 +453,8 @@ class BaresipService: Service() { call.security = R.drawable.box_green call.zid = ev[1] } + if (!Utils.isVisible()) + return } "call transfer" -> { val call = Call.find(callp) @@ -515,6 +527,8 @@ class BaresipService: Service() { if (am.isSpeakerphoneOn) am.isSpeakerphoneOn = false speakerPhone = false } + if (!Utils.isVisible()) + return } "transfer failed" -> { Log.d(LOG_TAG, "AoR $aor hanging up call $callp with ${ev[1]}") @@ -524,8 +538,6 @@ class BaresipService: Service() { } } } - if (!Utils.isVisible()) - return if (newEvent == null) newEvent = event val intent = Intent("service event") intent.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index 2a4d7053..285e3359 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -630,8 +630,8 @@ class MainActivity : AppCompatActivity() { ": ${ev[1]}", Toast.LENGTH_LONG).show() } - "call ringing" -> { - setVolumeControlStream(AudioManager.STREAM_VOICE_CALL) + "call ringing", "call progress" -> { + volumeControlStream = AudioManager.STREAM_VOICE_CALL } "call rejected" -> { if (ua == UserAgent.uas()[aorSpinner.selectedItemPosition]) { @@ -785,6 +785,7 @@ class MainActivity : AppCompatActivity() { callsButton.setImageResource(R.drawable.calls_missed) } speakerIcon.setIcon(R.drawable.speaker_off) + volumeControlStream = AudioManager.USE_DEFAULT_STREAM_TYPE val param = ev[1].trim() if ((param != "") && (Call.uaCalls(ua, "").size == 0)) { if (param.get(0).isDigit())