From e4fe55a9496cce7955fc1fee9112d5a2f7e3a652 Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Tue, 4 Jan 2022 08:58:52 +0100 Subject: [PATCH 1/3] Disable proximity sensor and enable sleep after call ended --- .../Controllers/MXKCallViewController.m | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m index 55781b1060..55acfb1b53 100644 --- a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m +++ b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m @@ -1422,29 +1422,26 @@ - (void)updateTimeStatusLabel } } -- (void)updateProximityAndSleep -{ - BOOL inCall = (mxCall.state == MXCallStateConnected || mxCall.state == MXCallStateRinging || mxCall.state == MXCallStateInviteSent || mxCall.state == MXCallStateConnecting || mxCall.state == MXCallStateCreateOffer || mxCall.state == MXCallStateCreateAnswer); - - if (inCall) - { - BOOL isBuiltInReceiverUsed = self.isBuiltInReceiverAudioOuput; - - // Enable the proximity monitoring when the built in receiver is used as the audio output. - BOOL enableProxMonitoring = isBuiltInReceiverUsed; - [[UIDevice currentDevice] setProximityMonitoringEnabled:enableProxMonitoring]; - - // Disable the idle timer during a video call, or during a voice call which is performed with the built-in receiver. - // Note: if the device is locked, VoIP calling get dropped if an incoming GSM call is received. - BOOL disableIdleTimer = mxCall.isVideoCall || isBuiltInReceiverUsed; - - UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; - if (sharedApplication) - { - sharedApplication.idleTimerDisabled = disableIdleTimer; - } - } -} + - (void)updateProximityAndSleep + { + BOOL inCall = (mxCall.state == MXCallStateConnected || mxCall.state == MXCallStateRinging || mxCall.state == MXCallStateInviteSent || mxCall.state == MXCallStateConnecting || mxCall.state == MXCallStateCreateOffer || mxCall.state == MXCallStateCreateAnswer); + + BOOL isBuiltInReceiverUsed = self.isBuiltInReceiverAudioOuput; + + // Enable the proximity monitoring when the built in receiver is used as the audio output. + BOOL enableProxMonitoring = inCall && isBuiltInReceiverUsed; + [[UIDevice currentDevice] setProximityMonitoringEnabled:enableProxMonitoring]; + + // Disable the idle timer during a video call, or during a voice call which is performed with the built-in receiver. + // Note: if the device is locked, VoIP calling get dropped if an incoming GSM call is received. + BOOL disableIdleTimer = inCall && (mxCall.isVideoCall || isBuiltInReceiverUsed); + + UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; + if (sharedApplication) + { + sharedApplication.idleTimerDisabled = disableIdleTimer; + } + } - (UIView *)createIncomingCallView { From d8291fb3bbfe26e2edf9059679ba6dc9c747ee49 Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Tue, 25 Jan 2022 09:02:56 +0100 Subject: [PATCH 2/3] Add changelog --- changelog.d/4103.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4103.bugfix diff --git a/changelog.d/4103.bugfix b/changelog.d/4103.bugfix new file mode 100644 index 0000000000..2093e302e7 --- /dev/null +++ b/changelog.d/4103.bugfix @@ -0,0 +1 @@ +Fix proximity sensor staying on and sleep timer staying disabled after call ends From cdf11e45ccfa38cab9dc567b304b13ea532ddd4a Mon Sep 17 00:00:00 2001 From: Simon Wiedmer Date: Mon, 31 Jan 2022 11:13:07 +0100 Subject: [PATCH 3/3] Call native api only if there is a change --- .../MatrixKit/Controllers/MXKCallViewController.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m index 55acfb1b53..7f23a8ec6d 100644 --- a/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m +++ b/Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m @@ -1430,14 +1430,19 @@ - (void)updateProximityAndSleep // Enable the proximity monitoring when the built in receiver is used as the audio output. BOOL enableProxMonitoring = inCall && isBuiltInReceiverUsed; - [[UIDevice currentDevice] setProximityMonitoringEnabled:enableProxMonitoring]; + + UIDevice *device = [UIDevice currentDevice]; + if (device && device.isProximityMonitoringEnabled != enableProxMonitoring) + { + [device setProximityMonitoringEnabled:enableProxMonitoring]; + } // Disable the idle timer during a video call, or during a voice call which is performed with the built-in receiver. // Note: if the device is locked, VoIP calling get dropped if an incoming GSM call is received. BOOL disableIdleTimer = inCall && (mxCall.isVideoCall || isBuiltInReceiverUsed); UIApplication *sharedApplication = [UIApplication performSelector:@selector(sharedApplication)]; - if (sharedApplication) + if (sharedApplication && sharedApplication.isIdleTimerDisabled != disableIdleTimer) { sharedApplication.idleTimerDisabled = disableIdleTimer; }