From 67eff0583c90ec80a1a132ab2b2f776d6a1439a4 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 27 Sep 2020 08:57:32 +0200 Subject: [PATCH 1/5] Fix for vector-im#2100: Using Ringtone and RingtoneManager classes to control ringtones for incoming calls. Using systemwide setting for ringtone and volume. --- .../app/core/services/CallRingPlayer.kt | 27 ++++++++++++++++--- .../vector/app/core/services/CallService.kt | 22 +++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt index b14a097eb6..71733c7f07 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt @@ -17,6 +17,8 @@ package im.vector.app.core.services import android.content.Context +import android.media.Ringtone +import android.media.RingtoneManager import android.media.AudioAttributes import android.media.AudioManager import android.media.MediaPlayer @@ -25,7 +27,26 @@ import androidx.core.content.getSystemService import im.vector.app.R import timber.log.Timber -class CallRingPlayer( +class CallRingPlayerIncoming( + context: Context +) { + + private val applicationContext = context.applicationContext + private var r: Ringtone? = null + + fun start() { + val notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE) + r = RingtoneManager.getRingtone(applicationContext, notification) + Timber.v("## VOIP Starting ringing incomming") + r?.play() + } + + fun stop() { + r?.stop() + } +} + +class CallRingPlayerOutgoing( context: Context ) { @@ -44,12 +65,12 @@ class CallRingPlayer( try { if (player?.isPlaying == false) { player?.start() - Timber.v("## VOIP Starting ringing") + Timber.v("## VOIP Starting ringing outgoing") } else { Timber.v("## VOIP already playing") } } catch (failure: Throwable) { - Timber.e(failure, "## VOIP Failed to start ringing") + Timber.e(failure, "## VOIP Failed to start ringing outgoing") player = null } } else { diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt index 1362c20be1..075b237be2 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallService.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt @@ -40,7 +40,8 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe private lateinit var notificationUtils: NotificationUtils private lateinit var webRtcPeerConnectionManager: WebRtcPeerConnectionManager - private var callRingPlayer: CallRingPlayer? = null + private var callRingPlayerIncoming: CallRingPlayerIncoming? = null + private var callRingPlayerOutgoing: CallRingPlayerOutgoing? = null private var wiredHeadsetStateReceiver: WiredHeadsetStateReceiver? = null private var bluetoothHeadsetStateReceiver: BluetoothHeadsetReceiver? = null @@ -63,14 +64,16 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe super.onCreate() notificationUtils = vectorComponent().notificationUtils() webRtcPeerConnectionManager = vectorComponent().webRtcPeerConnectionManager() - callRingPlayer = CallRingPlayer(applicationContext) + callRingPlayerIncoming = CallRingPlayerIncoming(applicationContext) + callRingPlayerOutgoing = CallRingPlayerOutgoing(applicationContext) wiredHeadsetStateReceiver = WiredHeadsetStateReceiver.createAndRegister(this, this) bluetoothHeadsetStateReceiver = BluetoothHeadsetReceiver.createAndRegister(this, this) } override fun onDestroy() { super.onDestroy() - callRingPlayer?.stop() + callRingPlayerIncoming?.stop() + callRingPlayerOutgoing?.stop() wiredHeadsetStateReceiver?.let { WiredHeadsetStateReceiver.unRegister(this, it) } wiredHeadsetStateReceiver = null bluetoothHeadsetStateReceiver?.let { BluetoothHeadsetReceiver.unRegister(this, it) } @@ -100,16 +103,17 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe when (intent.action) { ACTION_INCOMING_RINGING_CALL -> { mediaSession?.isActive = true - callRingPlayer?.start() + callRingPlayerIncoming?.start() displayIncomingCallNotification(intent) } ACTION_OUTGOING_RINGING_CALL -> { mediaSession?.isActive = true - callRingPlayer?.start() + callRingPlayerOutgoing?.start() displayOutgoingRingingCallNotification(intent) } ACTION_ONGOING_CALL -> { - callRingPlayer?.stop() + callRingPlayerIncoming?.stop() + callRingPlayerOutgoing?.stop() displayCallInProgressNotification(intent) } ACTION_NO_ACTIVE_CALL -> hideCallNotifications() @@ -117,7 +121,8 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe // lower notification priority displayCallInProgressNotification(intent) // stop ringing - callRingPlayer?.stop() + callRingPlayerIncoming?.stop() + callRingPlayerOutgoing?.stop() } ACTION_ONGOING_CALL_BG -> { // there is an ongoing call but call activity is in background @@ -125,7 +130,8 @@ class CallService : VectorService(), WiredHeadsetStateReceiver.HeadsetEventListe } else -> { // Should not happen - callRingPlayer?.stop() + callRingPlayerIncoming?.stop() + callRingPlayerOutgoing?.stop() myStopSelf() } } From a9f7fb46b346ca1719de61c42ab5f9a2b53c83ed Mon Sep 17 00:00:00 2001 From: Markus Date: Mon, 12 Oct 2020 15:06:49 +0200 Subject: [PATCH 2/5] Fix for ticket #2246: Ringtone volume cannot bechanged while ringing This fix delays the creation of the audioManager until the call is connected. This way the call feature does not takes the focus from the core service (where the ringtone is generated) until the call is esablished. This way the volume can be controled correctly while the phone is ringing (incoming and outgoing). --- .../main/java/im/vector/app/core/services/CallRingPlayer.kt | 2 +- .../java/im/vector/app/features/call/CallAudioManager.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt index 71733c7f07..d5d8bb14dd 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallRingPlayer.kt @@ -95,7 +95,7 @@ class CallRingPlayerOutgoing( } else { mediaPlayer.setAudioAttributes(AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) - .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING) + .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) .build()) } return mediaPlayer diff --git a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt index 9b3c42ab5d..73d25662cd 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt @@ -93,6 +93,10 @@ class CallAudioManager( fun startForCall(mxCall: MxCall) { Timber.v("## VOIP: AudioManager startForCall ${mxCall.callId}") + } + + fun setupAudioManager(mxCall: MxCall) { + Timber.v("## VOIP: AudioManager setupAudioManager ${mxCall.callId}") val audioManager = audioManager ?: return savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn savedIsMicrophoneMute = audioManager.isMicrophoneMute @@ -150,6 +154,7 @@ class CallAudioManager( fun onCallConnected(mxCall: MxCall) { Timber.v("##VOIP: AudioManager call answered, adjusting current sound device") + setupAudioManager(mxCall) adjustCurrentSoundDevice(mxCall) } From aa2a24e68a21f1f79732a22dbae6c9374753727a Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 31 Oct 2020 13:17:25 +0100 Subject: [PATCH 3/5] Changes requested by BillCarsonFs review. Thanks for the comments! --- .../main/java/im/vector/app/features/call/CallAudioManager.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt index 73d25662cd..3a24cf6d48 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallAudioManager.kt @@ -95,7 +95,7 @@ class CallAudioManager( Timber.v("## VOIP: AudioManager startForCall ${mxCall.callId}") } - fun setupAudioManager(mxCall: MxCall) { + private fun setupAudioManager(mxCall: MxCall) { Timber.v("## VOIP: AudioManager setupAudioManager ${mxCall.callId}") val audioManager = audioManager ?: return savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn @@ -155,7 +155,6 @@ class CallAudioManager( fun onCallConnected(mxCall: MxCall) { Timber.v("##VOIP: AudioManager call answered, adjusting current sound device") setupAudioManager(mxCall) - adjustCurrentSoundDevice(mxCall) } fun getAvailableSoundDevices(): List { From 7a11ab5bcafd6871fbd2c3ba9ef8a958fa6bbec9 Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 31 Oct 2020 13:48:53 +0100 Subject: [PATCH 4/5] Updated CHANGES.md --- CHANGES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 99058117b6..75ff66a35d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,12 @@ +Changes in Element 1.0.10 (xxxx-xx-xx) +=================================================== + +Features ✨: + - + +Bugfix 🐛: + - Fixed ringtone handling (#2100 & #2246) + Changes in Element 1.0.9 (2020-10-16) =================================================== From 3364dd3380b79a4ea7cc09da563137c06f0c0476 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 1 Nov 2020 10:13:27 +0100 Subject: [PATCH 5/5] Merged latest CHANGES.md --- CHANGES.md | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 75ff66a35d..9f7ce6d999 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,11 +1,39 @@ -Changes in Element 1.0.10 (xxxx-xx-xx) +Changes in Element 1.0.10 (2020-XX-XX) =================================================== Features ✨: - + +Improvements 🙌: + - Rework sending Event management (#154) + - New room creation screen: set topic and avatar in the room creation form (#2078) + - Toggle Low priority tag (#1490) + - Add option to send with enter (#1195) + - Use Hardware keyboard enter to send message (use shift-enter for new line) (#1881, #1440) + - Edit and remove icons are now visible on image attachment preview screen (#2294) + - Room profile: BigImageViewerActivity now only display the image. Use the room setting to change or delete the room Avatar + - Better visibility of text reactions in dark theme (#1118) + - Room member profile: Add action to create (or open) a DM (#2310) + - Prepare changelog for F-Droid (#2296) + - Add graphic resources for F-Droid (#812, #2220) + - Highlight text in the body of the displayed result (#2200) Bugfix 🐛: - Fixed ringtone handling (#2100 & #2246) + - Messages encrypted with no way to decrypt after SDK update from 0.18 to 1.0.0 (#2252) + - Search Result | scroll jumps after pagination (#2238) + +Translations 🗣: + - + +SDK API changes ⚠️: + - + +Build 🧱: + - + +Other changes: + - Changes in Element 1.0.9 (2020-10-16) ===================================================