mirror of
https://github.com/SimpleMobileTools/Simple-Dialer.git
synced 2025-06-05 21:49:23 +02:00
properly handle routing audio through speakerphone
This commit is contained in:
@ -98,6 +98,8 @@
|
||||
|
||||
<service
|
||||
android:name=".services.CallService"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:permission="android.permission.BIND_INCALL_SERVICE">
|
||||
<meta-data
|
||||
android:name="android.telecom.IN_CALL_SERVICE_UI"
|
||||
|
@ -12,6 +12,7 @@ import android.os.Handler
|
||||
import android.os.PowerManager
|
||||
import android.provider.MediaStore
|
||||
import android.telecom.Call
|
||||
import android.telecom.CallAudioState
|
||||
import android.util.Size
|
||||
import android.view.WindowManager
|
||||
import android.widget.RemoteViews
|
||||
@ -159,6 +160,9 @@ class CallActivity : SimpleActivity() {
|
||||
val drawable = if (isSpeakerOn) R.drawable.ic_speaker_on_vector else R.drawable.ic_speaker_off_vector
|
||||
call_toggle_speaker.setImageDrawable(getDrawable(drawable))
|
||||
audioManager.isSpeakerphoneOn = isSpeakerOn
|
||||
|
||||
val newRoute = if (isSpeakerOn) CallAudioState.ROUTE_SPEAKER else CallAudioState.ROUTE_EARPIECE
|
||||
CallManager.inCallService?.setAudioRoute(newRoute)
|
||||
}
|
||||
|
||||
private fun toggleMicrophone() {
|
||||
@ -166,6 +170,7 @@ class CallActivity : SimpleActivity() {
|
||||
val drawable = if (isMicrophoneOn) R.drawable.ic_microphone_vector else R.drawable.ic_microphone_off_vector
|
||||
call_toggle_microphone.setImageDrawable(getDrawable(drawable))
|
||||
audioManager.isMicrophoneMute = !isMicrophoneOn
|
||||
CallManager.inCallService?.setMuted(!isMicrophoneOn)
|
||||
}
|
||||
|
||||
private fun toggleDialpadVisibility() {
|
||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.telecom.Call
|
||||
import android.telecom.InCallService
|
||||
import android.telecom.VideoProfile
|
||||
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||
import com.simplemobiletools.dialer.models.CallContact
|
||||
@ -13,6 +14,7 @@ import com.simplemobiletools.dialer.models.CallContact
|
||||
class CallManager {
|
||||
companion object {
|
||||
var call: Call? = null
|
||||
var inCallService: InCallService? = null
|
||||
|
||||
fun accept() {
|
||||
call?.answer(VideoProfile.STATE_AUDIO_ONLY)
|
||||
|
@ -13,10 +13,12 @@ class CallService : InCallService() {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
CallManager.call = call
|
||||
CallManager.inCallService = this
|
||||
}
|
||||
|
||||
override fun onCallRemoved(call: Call) {
|
||||
super.onCallRemoved(call)
|
||||
CallManager.call = null
|
||||
CallManager.inCallService = null
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user