Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proximity sensor and sleep timer #5428

Merged
merged 5 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions Riot/Modules/MatrixKit/Controllers/MXKCallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1422,29 +1422,31 @@ - (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 *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 && sharedApplication.isIdleTimerDisabled != disableIdleTimer)
{
sharedApplication.idleTimerDisabled = disableIdleTimer;
langleyd marked this conversation as resolved.
Show resolved Hide resolved
}
}

- (UIView *)createIncomingCallView
{
Expand Down
1 change: 1 addition & 0 deletions changelog.d/4103.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix proximity sensor staying on and sleep timer staying disabled after call ends