Stop proximity sensor while sharing screen.
This commit is contained in:
parent
cf3d145cd6
commit
9a1dbb27d4
@ -156,9 +156,10 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAudioDevicesChange() {
|
override fun onAudioDevicesChange() = withState { state ->
|
||||||
val currentSoundDevice = callManager.audioManager.selectedDevice ?: return
|
val currentSoundDevice = callManager.audioManager.selectedDevice ?: return@withState
|
||||||
if (currentSoundDevice == CallAudioManager.Device.Phone) {
|
val webRtcCall = callManager.getCallById(state.callId)
|
||||||
|
if (webRtcCall != null && shouldActivateProximitySensor(webRtcCall)) {
|
||||||
proximityManager.start()
|
proximityManager.start()
|
||||||
} else {
|
} else {
|
||||||
proximityManager.stop()
|
proximityManager.stop()
|
||||||
@ -205,7 +206,7 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||||||
callManager.addListener(callManagerListener)
|
callManager.addListener(callManagerListener)
|
||||||
webRtcCall.addListener(callListener)
|
webRtcCall.addListener(callListener)
|
||||||
val currentSoundDevice = callManager.audioManager.selectedDevice
|
val currentSoundDevice = callManager.audioManager.selectedDevice
|
||||||
if (currentSoundDevice == CallAudioManager.Device.Phone) {
|
if (shouldActivateProximitySensor(webRtcCall)) {
|
||||||
proximityManager.start()
|
proximityManager.start()
|
||||||
}
|
}
|
||||||
setState {
|
setState {
|
||||||
@ -232,6 +233,10 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun shouldActivateProximitySensor(webRtcCall: WebRtcCall): Boolean {
|
||||||
|
return callManager.audioManager.selectedDevice == CallAudioManager.Device.Phone && !webRtcCall.isSharingScreen()
|
||||||
|
}
|
||||||
|
|
||||||
private fun WebRtcCall.extractCallInfo(): VectorCallViewState.CallInfo {
|
private fun WebRtcCall.extractCallInfo(): VectorCallViewState.CallInfo {
|
||||||
val assertedIdentity = this.remoteAssertedIdentity
|
val assertedIdentity = this.remoteAssertedIdentity
|
||||||
val matrixItem = if (assertedIdentity != null) {
|
val matrixItem = if (assertedIdentity != null) {
|
||||||
@ -351,6 +356,7 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
is VectorCallViewActions.StartScreenSharing -> {
|
is VectorCallViewActions.StartScreenSharing -> {
|
||||||
call?.startSharingScreen(action.videoCapturer)
|
call?.startSharingScreen(action.videoCapturer)
|
||||||
|
proximityManager.stop()
|
||||||
setState {
|
setState {
|
||||||
copy(isSharingScreen = true)
|
copy(isSharingScreen = true)
|
||||||
}
|
}
|
||||||
@ -367,6 +373,9 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(
|
_viewEvents.post(
|
||||||
VectorCallViewEvents.StopScreenSharingService
|
VectorCallViewEvents.StopScreenSharingService
|
||||||
)
|
)
|
||||||
|
if (callManager.audioManager.selectedDevice == CallAudioManager.Device.Phone) {
|
||||||
|
proximityManager.start()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_viewEvents.post(
|
_viewEvents.post(
|
||||||
VectorCallViewEvents.ShowScreenSharingPermissionDialog
|
VectorCallViewEvents.ShowScreenSharingPermissionDialog
|
||||||
|
Loading…
Reference in New Issue
Block a user