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

View file

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

View file

@ -1383,8 +1383,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
if (state == State.Connected) { if (state == State.Connected) {
if (mLc.getCallsNb() == 1) { 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. //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. //However, incoming call first use the MODE_RINGING to play the local ring.
if(call.getDirection() == CallDirection.Incoming) { if(call.getDirection() == CallDirection.Incoming) {
@ -1446,7 +1444,6 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
setAudioManagerInCallMode(); setAudioManagerInCallMode();
requestAudioFocus(STREAM_VOICE_CALL); requestAudioFocus(STREAM_VOICE_CALL);
startBluetooth(); startBluetooth();
enableProximitySensing(true);
} }
if (state == State.StreamsRunning) { if (state == State.StreamsRunning) {

View file

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