Actually do not disable earpiece, it works even without telecom manager support

This commit is contained in:
Sylvain Berfini 2024-10-03 09:54:29 +02:00
parent 248a06c8be
commit 86e09b5dce
3 changed files with 1 additions and 17 deletions

View file

@ -168,12 +168,6 @@ class TelecomCallControlCallback(
}.launchIn(scope) }.launchIn(scope)
} }
fun isEarpieceAvailable(): Boolean {
return availableEndpoints.find {
it.type == CallEndpointCompat.Companion.TYPE_EARPIECE
} != null
}
fun applyAudioRouteToCallWithId(routes: List<AudioDevice.Type>): Boolean { fun applyAudioRouteToCallWithId(routes: List<AudioDevice.Type>): Boolean {
Log.i("$TAG Looking for audio endpoint with type [${routes.first()}]") Log.i("$TAG Looking for audio endpoint with type [${routes.first()}]")

View file

@ -194,10 +194,4 @@ class TelecomManager @WorkerThread constructor(context: Context) {
return callControlCallback.applyAudioRouteToCallWithId(routes) return callControlCallback.applyAudioRouteToCallWithId(routes)
} }
@WorkerThread
fun isEarpieceAvailable(callId: String): Boolean {
val callControlCallback = map[callId]
return callControlCallback?.isEarpieceAvailable() ?: false
}
} }

View file

@ -681,9 +681,6 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
coreContext.postOnCoreThread { core -> coreContext.postOnCoreThread { core ->
val audioDevices = core.audioDevices val audioDevices = core.audioDevices
val list = arrayListOf<AudioDeviceModel>() val list = arrayListOf<AudioDeviceModel>()
val isEarpieceAvailable = coreContext.telecomManager.isEarpieceAvailable(
currentCall.callLog.callId ?: ""
)
for (device in audioDevices) { for (device in audioDevices) {
// Only list output audio devices // Only list output audio devices
if (!device.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) continue if (!device.hasCapability(AudioDevice.Capabilities.CapabilityPlay)) continue
@ -717,8 +714,7 @@ class CurrentCallViewModel @UiThread constructor() : GenericViewModel() {
} }
val currentDevice = currentCall.outputAudioDevice val currentDevice = currentCall.outputAudioDevice
val isCurrentlyInUse = device.type == currentDevice?.type && device.deviceName == currentDevice?.deviceName val isCurrentlyInUse = device.type == currentDevice?.type && device.deviceName == currentDevice?.deviceName
val enabled = if (device.type == AudioDevice.Type.Earpiece) isEarpieceAvailable else true val model = AudioDeviceModel(device, name, device.type, isCurrentlyInUse, true) {
val model = AudioDeviceModel(device, name, device.type, isCurrentlyInUse, enabled) {
// onSelected // onSelected
coreContext.postOnCoreThread { coreContext.postOnCoreThread {
Log.i("$TAG Selected audio device with ID [${device.id}]") Log.i("$TAG Selected audio device with ID [${device.id}]")