From 7ce2991b0fce036610638398c3f29aa176c26126 Mon Sep 17 00:00:00 2001 From: Clark Date: Wed, 6 Dec 2023 08:37:33 -0500 Subject: [PATCH] Do not turn screen on automatically for calls. --- .../service/webrtc/DeviceAwareActionProcessor.java | 7 ++++++- .../service/webrtc/IncomingCallActionProcessor.java | 2 +- .../service/webrtc/IncomingGroupCallActionProcessor.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/DeviceAwareActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/DeviceAwareActionProcessor.java index e419d2f0fb..c02845fb75 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/DeviceAwareActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/DeviceAwareActionProcessor.java @@ -4,6 +4,7 @@ import androidx.annotation.NonNull; import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.components.webrtc.BroadcastVideoSink; +import org.thoughtcrime.securesms.events.WebRtcViewModel; import org.thoughtcrime.securesms.ringrtc.CameraState; import org.thoughtcrime.securesms.ringrtc.RemotePeer; import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState; @@ -27,7 +28,11 @@ public abstract class DeviceAwareActionProcessor extends WebRtcActionProcessor { Log.i(tag, "handleAudioDeviceChanged(): active: " + activeDevice + " available: " + availableDevices); if (!currentState.getLocalDeviceState().getCameraState().isEnabled()) { - webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context)); + if (currentState.getCallInfoState().getCallState() == WebRtcViewModel.State.CALL_CONNECTED) { + webRtcInteractor.updatePhoneState(WebRtcUtil.getInCallPhoneState(context)); + } else { + Log.i(tag, "handleAudioDeviceChanged(): call not connected, not updating phone state"); + } } return currentState.builder() diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingCallActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingCallActionProcessor.java index 7d6162d23a..c0229e053c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingCallActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingCallActionProcessor.java @@ -183,10 +183,10 @@ public class IncomingCallActionProcessor extends DeviceAwareActionProcessor { CallTable.Direction.INCOMING, CallTable.Event.ONGOING); - webRtcInteractor.updatePhoneState(LockManager.PhoneState.INTERACTIVE); boolean shouldDisturbUserWithCall = DoNotDisturbUtil.shouldDisturbUserWithCall(context.getApplicationContext(), recipient); if (shouldDisturbUserWithCall) { + webRtcInteractor.updatePhoneState(LockManager.PhoneState.INTERACTIVE); boolean started = webRtcInteractor.startWebRtcCallActivityIfPossible(); if (!started) { Log.i(TAG, "Unable to start call activity due to OS version or not being in the foreground"); diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java index cabe78a8da..dc6f2b62a5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java @@ -120,11 +120,11 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro currentState = WebRtcVideoUtil.initializeVideo(context, webRtcInteractor.getCameraEventListener(), currentState, RemotePeer.GROUP_CALL_ID.longValue()); webRtcInteractor.setCallInProgressNotification(TYPE_INCOMING_RINGING, remotePeerGroup, true); - webRtcInteractor.updatePhoneState(LockManager.PhoneState.INTERACTIVE); webRtcInteractor.initializeAudioForCall(); boolean shouldDisturbUserWithCall = DoNotDisturbUtil.shouldDisturbUserWithCall(context.getApplicationContext()); if (shouldDisturbUserWithCall) { + webRtcInteractor.updatePhoneState(LockManager.PhoneState.INTERACTIVE); boolean started = webRtcInteractor.startWebRtcCallActivityIfPossible(); if (!started) { Log.i(TAG, "Unable to start call activity due to OS version or not being in the foreground");