Fix second incoming call from same uri crash.
This commit is contained in:
parent
f8892448ad
commit
546e6648f2
8 changed files with 39 additions and 21 deletions
|
@ -8,6 +8,7 @@
|
|||
<string name="error_adding_new_call">Error adding new call</string>
|
||||
<string name="transfer_started">Transfer started</string>
|
||||
|
||||
<string name="skipable_error_service_not_ready">Warning: service is not ready</string>
|
||||
|
||||
<string name="status_conf_call">conf</string>
|
||||
<string name="status_active_call">active</string>
|
||||
|
|
|
@ -46,7 +46,7 @@ public class IncomingCallActivity extends Activity implements OnClickListener {
|
|||
|
||||
private void findIncomingCall(Intent intent) {
|
||||
String stringUri = intent.getStringExtra("stringUri");
|
||||
mCall = LinphoneManager.getInstance().retrieveIncomingCall(stringUri);
|
||||
mCall = LinphoneManager.getLc().findCallFromUri(stringUri);
|
||||
if (mCall == null) {
|
||||
Log.e("Couldn't find incoming call from ", stringUri);
|
||||
Toast.makeText(this, "Error", Toast.LENGTH_SHORT);
|
||||
|
|
|
@ -959,7 +959,6 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
|
||||
private static class ListenerDispatcher implements LinphoneServiceListener {
|
||||
private LinphoneServiceListener serviceListener;
|
||||
private List<LinphoneCall> incomingCalls = new ArrayList<LinphoneCall>();
|
||||
List<LinphoneSimpleListener> simpleListeners;
|
||||
public ListenerDispatcher(List<LinphoneSimpleListener> simpleListeners) {
|
||||
this.simpleListeners = simpleListeners;
|
||||
|
@ -987,20 +986,8 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
if (serviceListener != null) serviceListener.onCallEncryptionChanged(call, encrypted, authenticationToken);
|
||||
}
|
||||
|
||||
public LinphoneCall retrieveIncomingCall(String stringUri) {
|
||||
for (LinphoneCall call : incomingCalls) {
|
||||
if (stringUri.equals(call.getRemoteAddress().asStringUriOnly())) {
|
||||
return call;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onCallStateChanged(LinphoneCall call, State state,
|
||||
String message) {
|
||||
if (State.IncomingReceived.equals(state)) {
|
||||
incomingCalls.add(call);
|
||||
}
|
||||
if (serviceListener != null) serviceListener.onCallStateChanged(call, state, message);
|
||||
for (LinphoneOnCallStateChangedListener l : getSimpleListeners(LinphoneOnCallStateChangedListener.class)) {
|
||||
l.onCallStateChanged(call, state, message);
|
||||
|
@ -1041,7 +1028,4 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
|||
return instance != null;
|
||||
}
|
||||
|
||||
public LinphoneCall retrieveIncomingCall(String stringUri) {
|
||||
return listenerDispatcher.retrieveIncomingCall(stringUri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
|||
private Handler mHandler = new Handler();
|
||||
private static LinphoneService instance;
|
||||
|
||||
static boolean isReady() { return (instance!=null); }
|
||||
public static boolean isReady() { return (instance!=null); }
|
||||
|
||||
/**
|
||||
* @throws RuntimeException service not instantiated
|
||||
|
|
|
@ -559,4 +559,11 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public synchronized void transferCallToAnother(LinphoneCall call, LinphoneCall dest) {
|
||||
transferCallToAnother(nativePtr, getCallPtr(call), getCallPtr(dest));
|
||||
}
|
||||
|
||||
private native long findCallFromUri(long nativePtr, String uri);
|
||||
@Override
|
||||
public synchronized LinphoneCall findCallFromUri(String uri) {
|
||||
long callPtr = findCallFromUri(nativePtr, uri);
|
||||
return callPtr != 0 ? new LinphoneCallImpl(callPtr) : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
package org.linphone.ui;
|
||||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphoneService;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Digit extends Button implements AddressAware {
|
||||
|
||||
|
@ -77,7 +81,16 @@ public class Digit extends Button implements AddressAware {
|
|||
mKeyCode = Digit.this.getText().subSequence(0, 1);
|
||||
}
|
||||
|
||||
private boolean linphoneServiceReady() {
|
||||
if (!LinphoneService.isReady()) {
|
||||
Log.w("Service is not ready while pressing digit");
|
||||
Toast.makeText(getContext(), getContext().getString(R.string.skipable_error_service_not_ready), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void onClick(View v) {
|
||||
if (!linphoneServiceReady()) return;
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.stopDtmf();
|
||||
mIsDtmfStarted =false;
|
||||
|
@ -96,6 +109,7 @@ public class Digit extends Button implements AddressAware {
|
|||
}
|
||||
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (!linphoneServiceReady()) return true;
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN && mIsDtmfStarted ==false) {
|
||||
LinphoneManager.getInstance().playDtmf(getContext().getContentResolver(), mKeyCode.charAt(0));
|
||||
|
@ -109,6 +123,7 @@ public class Digit extends Button implements AddressAware {
|
|||
}
|
||||
|
||||
public boolean onLongClick(View v) {
|
||||
if (!linphoneServiceReady()) return true;
|
||||
// Called if "0+" dtmf
|
||||
LinphoneCore lc = LinphoneManager.getLc();
|
||||
lc.stopDtmf();
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9ea9dcadbd06bdc90cffc1e0e95d4e5d1c48fd8e
|
||||
Subproject commit df65d113730693274f1b35a516b0a065aa7c755c
|
|
@ -94,10 +94,12 @@ public class TestConferenceActivity extends ConferenceActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
LinphoneManagerWaitHelper.disabled=true;
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//if (!serviceStarted) startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
|
||||
findViewById(R.id.toggleMuteMic).setOnClickListener(null);
|
||||
findViewById(R.id.toggleSpeaker).setOnClickListener(null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,6 +310,15 @@ public class TestConferenceActivity extends ConferenceActivity {
|
|||
public int getVideoDevice() {return 0;}
|
||||
public void setDeviceRotation(int rotation) {}
|
||||
public void setVideoDevice(int id) {}
|
||||
@Override
|
||||
public LinphoneCall findCallFromUri(String uri) {
|
||||
for (LinphoneCall call : calls) {
|
||||
if (call.getRemoteAddress().asStringUriOnly().equals(uri)) {
|
||||
return call;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,7 +329,7 @@ public class TestConferenceActivity extends ConferenceActivity {
|
|||
this.displayName = niceName;
|
||||
this.number = number;}
|
||||
public String asString() {return displayName;}
|
||||
public String asStringUriOnly() {return null;}
|
||||
public String asStringUriOnly() {return getUserName() + "@" + getDomain();}
|
||||
public String getDisplayName() {return displayName;}
|
||||
public String getDomain() {return "example.org";}
|
||||
public String getPort() {return "5060";}
|
||||
|
|
Loading…
Reference in a new issue