Fixed proximity sensor not disabled during incoming call

This commit is contained in:
Sylvain Berfini 2024-05-13 15:50:48 +02:00
parent cce13828d9
commit 0206753d78

View file

@ -555,6 +555,13 @@ class ControlsViewModel : ViewModel() {
} }
private fun shouldProximitySensorBeEnabled(): Boolean { 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() val currentCall = coreContext.core.currentCall ?: coreContext.core.calls.firstOrNull()
if (currentCall != null) { if (currentCall != null) {
when (val state = currentCall.state) { when (val state = currentCall.state) {
@ -574,11 +581,7 @@ class ControlsViewModel : ViewModel() {
} }
} }
if (forceDisableProximitySensor.value == true) { if (isVideoEnabled.value == true) {
Log.i(
"[Call Controls] Forcing proximity sensor to be disabled (usually in incoming/outgoing call fragments)"
)
} else if (isVideoEnabled.value == true) {
Log.i( Log.i(
"[Call Controls] Active call current params says video is enabled, proximity sensor will be disabled" "[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 && return !(isVideoEnabled.value ?: false) &&
!(isVideoEnabled.value ?: false) &&
!(nonEarpieceOutputAudioDevice.value ?: false) !(nonEarpieceOutputAudioDevice.value ?: false)
} }
} }