diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0c5a66b98..7754ba8e0 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -84,7 +84,7 @@ + android:launchMode="singleTask"> diff --git a/src/org/linphone/InCallActivity.java b/src/org/linphone/InCallActivity.java index c7038afbc..e3296ca3f 100644 --- a/src/org/linphone/InCallActivity.java +++ b/src/org/linphone/InCallActivity.java @@ -1009,7 +1009,6 @@ public class InCallActivity extends FragmentActivity implements @Override protected void onResume() { instance = this; - LinphoneManager.addListener(this); if (isVideoEnabled) { displayVideoCallControlsIfHidden(); @@ -1019,6 +1018,8 @@ public class InCallActivity extends FragmentActivity implements } super.onResume(); + + LinphoneManager.addListener(this); } @Override diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index d9580f3de..c6d39a9c8 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -23,6 +23,7 @@ import static android.content.Intent.ACTION_MAIN; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.List; import org.linphone.LinphoneManager.AddressType; @@ -1267,14 +1268,14 @@ public class LinphoneActivity extends FragmentActivity implements @Override protected void onPause() { + LinphoneManager.removeListener(this); + super.onPause(); refreshStatus(OnlineStatus.Away); } @Override protected void onDestroy() { - LinphoneManager.removeListener(this); - if (chatStorage != null) { chatStorage.close(); chatStorage = null; @@ -1327,12 +1328,27 @@ public class LinphoneActivity extends FragmentActivity implements ((DialerFragment) dialerFragment).newOutgoingCall(intent); } if (LinphoneManager.getLc().getCalls().length > 0) { - LinphoneCall call = LinphoneManager.getLc().getCalls()[0]; - if (call != null && call.getState() != LinphoneCall.State.IncomingReceived) { - if (call.getCurrentParamsCopy().getVideoEnabled()) { - startVideoActivity(call); + LinphoneCall calls[] = LinphoneManager.getLc().getCalls(); + if (calls.length > 0) { + LinphoneCall call = calls[0]; + + if (call != null && call.getState() != LinphoneCall.State.IncomingReceived) { + if (call.getCurrentParamsCopy().getVideoEnabled()) { + startVideoActivity(call); + } else { + startIncallActivity(call); + } + } + } + + // If a call is ringing, start incomingcallactivity + Collection incoming = new ArrayList(); + incoming.add(LinphoneCall.State.IncomingReceived); + if (LinphoneUtils.getCallsInState(LinphoneManager.getLc(), incoming).size() > 0) { + if (InCallActivity.isInstanciated()) { + InCallActivity.instance().startIncomingCallActivity(); } else { - startIncallActivity(call); + startActivity(new Intent(this, IncomingCallActivity.class)); } } } diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 663c2ff7c..b22804c80 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -78,6 +78,7 @@ import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration; import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera; import org.linphone.mediastream.video.capture.hwconf.Hacks; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ContentResolver; @@ -1004,6 +1005,7 @@ public final class LinphoneManager implements LinphoneCoreListener { } } + @SuppressLint("Wakelock") public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message) { Log.i("new state [",state,"]"); if (state == IncomingReceived && !call.equals(lc.getCurrentCall())) { diff --git a/src/org/linphone/LinphoneService.java b/src/org/linphone/LinphoneService.java index eb892693b..ea2f262a4 100644 --- a/src/org/linphone/LinphoneService.java +++ b/src/org/linphone/LinphoneService.java @@ -546,6 +546,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis Log.i("Service not ready, discarding call state change to ",state.toString()); return; } + if (state == LinphoneCall.State.IncomingReceived) { onIncomingReceived(); } @@ -574,6 +575,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis if ((state == State.CallEnd || state == State.Error) && LinphoneManager.getLc().getCallsNb() < 1) { mWifiLock.release(); } + mHandler.post(new Runnable() { public void run() { if (guiListener() != null)