turn proximity wake lock and/off depending on speaker configuration
This commit is contained in:
parent
9bc264bd73
commit
ef22071bd1
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -146,6 +146,7 @@ public class WebRTCWrapper {
|
|||
mainHandler.post(() -> {
|
||||
appRTCAudioManager = AppRTCAudioManager.create(context, AppRTCAudioManager.SpeakerPhonePreference.EARPIECE);
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue