Change summary
src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java | 12
src/main/java/eu/siacs/conversations/xmpp/jingle/WebRTCWrapper.java | 4
2 files changed, 14 insertions(+), 2 deletions(-)
Detailed changes
@@ -135,12 +135,20 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
private void releaseProximityWakeLock() {
if (this.mProximityWakeLock != null && mProximityWakeLock.isHeld()) {
- Log.d(Config.LOGTAG, "releasing wake lock");
+ Log.d(Config.LOGTAG, "releasing proximity wake lock");
this.mProximityWakeLock.release();
this.mProximityWakeLock = null;
}
}
+ private void putProximityWakeLockInProperState() {
+ if (requireRtpConnection().getAudioManager().getSelectedAudioDevice() == AppRTCAudioManager.AudioDevice.EARPIECE) {
+ acquireProximityWakeLock();
+ } else {
+ releaseProximityWakeLock();
+ }
+ }
+
@Override
protected void refreshUiReal() {
@@ -200,6 +208,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
private void proposeJingleRtpSession(final Account account, final Jid with) {
xmppConnectionService.getJingleConnectionManager().proposeJingleRtpSession(account, with);
+ //TODO maybe we donβt want to acquire a wake lock just yet and wait for audio manager to discover what speaker we are using
putScreenInCallMode();
}
@@ -506,6 +515,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
requireRtpConnection().isMicrophoneEnabled()
);
}
+ putProximityWakeLockInProperState();
} catch (IllegalStateException e) {
Log.d(Config.LOGTAG, "RTP connection was not available when audio device changed");
}
@@ -145,7 +145,8 @@ public class WebRTCWrapper {
);
mainHandler.post(() -> {
appRTCAudioManager = AppRTCAudioManager.create(context, AppRTCAudioManager.SpeakerPhonePreference.EARPIECE);
- appRTCAudioManager.start(audioManagerEvents);
+ appRTCAudioManager.start(audioManagerEvents);
+ eventCallback.onAudioDeviceChanged(appRTCAudioManager.getSelectedAudioDevice(), appRTCAudioManager.getAudioDevices());
});
}
@@ -218,6 +219,7 @@ public class WebRTCWrapper {
peerConnection.setAudioRecording(true);
this.peerConnection = peerConnection;
}
+
public void close() {
final PeerConnection peerConnection = this.peerConnection;
if (peerConnection != null) {