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() {
|
private void releaseProximityWakeLock() {
|
||||||
if (this.mProximityWakeLock != null && mProximityWakeLock.isHeld()) {
|
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.release();
|
||||||
this.mProximityWakeLock = null;
|
this.mProximityWakeLock = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void putProximityWakeLockInProperState() {
|
||||||
|
if (requireRtpConnection().getAudioManager().getSelectedAudioDevice() == AppRTCAudioManager.AudioDevice.EARPIECE) {
|
||||||
|
acquireProximityWakeLock();
|
||||||
|
} else {
|
||||||
|
releaseProximityWakeLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshUiReal() {
|
protected void refreshUiReal() {
|
||||||
|
|
||||||
|
@ -200,6 +208,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
|
|
||||||
private void proposeJingleRtpSession(final Account account, final Jid with) {
|
private void proposeJingleRtpSession(final Account account, final Jid with) {
|
||||||
xmppConnectionService.getJingleConnectionManager().proposeJingleRtpSession(account, 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();
|
putScreenInCallMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,6 +515,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
|
||||||
requireRtpConnection().isMicrophoneEnabled()
|
requireRtpConnection().isMicrophoneEnabled()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
putProximityWakeLockInProperState();
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
Log.d(Config.LOGTAG, "RTP connection was not available when audio device changed");
|
Log.d(Config.LOGTAG, "RTP connection was not available when audio device changed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class WebRTCWrapper {
|
||||||
mainHandler.post(() -> {
|
mainHandler.post(() -> {
|
||||||
appRTCAudioManager = AppRTCAudioManager.create(context, AppRTCAudioManager.SpeakerPhonePreference.EARPIECE);
|
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);
|
peerConnection.setAudioRecording(true);
|
||||||
this.peerConnection = peerConnection;
|
this.peerConnection = peerConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
final PeerConnection peerConnection = this.peerConnection;
|
final PeerConnection peerConnection = this.peerConnection;
|
||||||
if (peerConnection != null) {
|
if (peerConnection != null) {
|
||||||
|
|
Loading…
Reference in a new issue