Removed proximity sensor when speaker is enabled + refresh register when resuming LinphoneActivity if notification service is disabled

This commit is contained in:
Sylvain Berfini 2017-06-26 14:57:53 +02:00
parent 89c317be26
commit f04964814a
4 changed files with 15 additions and 7 deletions

View file

@ -803,7 +803,9 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
private void showAudioView() {
if (LinphoneManager.getLc().getCurrentCall() != null) {
LinphoneManager.getInstance().enableProximitySensing(true);
if (!isSpeakerEnabled) {
LinphoneManager.getInstance().enableProximitySensing(true);
}
}
replaceFragmentVideoByAudio();
displayAudioCall();
@ -886,6 +888,9 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
protected void toggleSpeaker() {
isSpeakerEnabled = !isSpeakerEnabled;
if (LinphoneManager.getLc().getCurrentCall() != null) {
LinphoneManager.getInstance().enableProximitySensing(!isSpeakerEnabled);
}
if (isSpeakerEnabled) {
LinphoneManager.getInstance().routeAudioToSpeaker();
speaker.setImageResource(R.drawable.speaker_selected);
@ -1182,8 +1187,10 @@ public class CallActivity extends LinphoneGenericActivity implements OnClickList
}
if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
LinphoneManager.getInstance().enableProximitySensing(true);
removeCallbacks();
if (!isSpeakerEnabled) {
LinphoneManager.getInstance().enableProximitySensing(true);
removeCallbacks();
}
}
}

View file

@ -31,6 +31,7 @@ import java.util.List;
import org.linphone.SettingsFragment;
import org.linphone.LinphoneManager.AddressType;
import org.linphone.LinphoneService;
import org.linphone.assistant.AssistantActivity;
import org.linphone.assistant.RemoteProvisioningLoginActivity;
import org.linphone.compatibility.Compatibility;
@ -1345,6 +1346,9 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
lc.addListener(mListener);
if (!LinphoneService.instance().displayServiceNotification()) {
lc.refreshRegisters();
}
}
if (isTablet()) {

View file

@ -1383,8 +1383,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
if (state == State.Connected) {
if (mLc.getCallsNb() == 1) {
//Enabling proximity sensor
enableProximitySensing(true);
//It is for incoming calls, because outgoing calls enter MODE_IN_COMMUNICATION immediately when they start.
//However, incoming call first use the MODE_RINGING to play the local ring.
if(call.getDirection() == CallDirection.Incoming) {
@ -1446,7 +1444,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
setAudioManagerInCallMode();
requestAudioFocus(STREAM_VOICE_CALL);
startBluetooth();
enableProximitySensing(true);
}
if (state == State.StreamsRunning) {

View file

@ -264,7 +264,7 @@ public final class LinphoneService extends Service {
mMsgNotifCount = 0;
}
private boolean displayServiceNotification() {
public boolean displayServiceNotification() {
return LinphonePreferences.instance().getServiceNotificationVisibility();
}