From 0206753d78847402b4ab0d0014337ada6e0a7b23 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 May 2024 15:50:48 +0200 Subject: [PATCH] Fixed proximity sensor not disabled during incoming call --- .../voip/viewmodels/ControlsViewModel.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt index fc8b58bb4..e295a4b1d 100644 --- a/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt +++ b/app/src/main/java/org/linphone/activities/voip/viewmodels/ControlsViewModel.kt @@ -555,6 +555,13 @@ class ControlsViewModel : ViewModel() { } private fun shouldProximitySensorBeEnabled(): Boolean { + if (forceDisableProximitySensor.value == true) { + Log.i( + "[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)" + ) + return false + } + val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull() if (currentCall != null) { when (val state = currentCall.state) { @@ -574,11 +581,7 @@ class ControlsViewModel : ViewModel() { } } - if (forceDisableProximitySensor.value == true) { - Log.i( - "[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)" - ) - } else if (isVideoEnabled.value == true) { + if (isVideoEnabled.value == true) { Log.i( "[Call Controls] Active call current params says video is enabled, proximity sensor will be disabled" ) @@ -588,8 +591,7 @@ class ControlsViewModel : ViewModel() { ) } - return forceDisableProximitySensor.value == false && - !(isVideoEnabled.value ?: false) && + return !(isVideoEnabled.value ?: false) && !(nonEarpieceOutputAudioDevice.value ?: false) } }