fix inconsistency when a second call arrives

This commit is contained in:
Simon Morlat 2011-09-22 10:55:47 +02:00
parent 93e8705ed5
commit a1992d7c81
4 changed files with 20 additions and 19 deletions

View file

@ -82,6 +82,7 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
private PowerManager.WakeLock mWakeLock; private PowerManager.WakeLock mWakeLock;
private SharedPreferences mPref; private SharedPreferences mPref;
private LinphoneCall mCurrentCall;
private boolean useIncallActivity; private boolean useIncallActivity;
private boolean useVideoActivity; private boolean useVideoActivity;
@ -394,11 +395,13 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
} }
if (state==LinphoneCall.State.OutgoingInit){ if (state==LinphoneCall.State.OutgoingInit){
mCurrentCall=call;
enterIncallMode(lc); enterIncallMode(lc);
if (!LinphoneManager.getInstance().shareMyCamera()) if (!LinphoneManager.getInstance().shareMyCamera())
call.enableCamera(false); call.enableCamera(false);
LinphoneActivity.instance().startOrientationSensor(); LinphoneActivity.instance().startOrientationSensor();
}else if (state==LinphoneCall.State.IncomingReceived){ }else if (state==LinphoneCall.State.IncomingReceived){
mCurrentCall=call;
callPending(call); callPending(call);
if (!LinphoneManager.getInstance().shareMyCamera()) if (!LinphoneManager.getInstance().shareMyCamera())
call.enableCamera(false); call.enableCamera(false);
@ -408,13 +411,19 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
enterIncallMode(lc); enterIncallMode(lc);
} }
}else if (state==LinphoneCall.State.Error){ }else if (state==LinphoneCall.State.Error){
if (mWakeLock.isHeld()) mWakeLock.release(); if (mCurrentCall==call){
showToast(R.string.call_error, message); if (mWakeLock.isHeld()) mWakeLock.release();
exitCallMode(); showToast(R.string.call_error, message);
LinphoneActivity.instance().stopOrientationSensor(); exitCallMode();
LinphoneActivity.instance().stopOrientationSensor();
mCurrentCall=null;
}
}else if (state==LinphoneCall.State.CallEnd){ }else if (state==LinphoneCall.State.CallEnd){
exitCallMode(); if (mCurrentCall==call){
LinphoneActivity.instance().stopOrientationSensor(); exitCallMode();
LinphoneActivity.instance().stopOrientationSensor();
mCurrentCall=null;
}
} }
} }

View file

@ -23,8 +23,7 @@ class LinphoneCallImpl implements LinphoneCall {
protected final long nativePtr; protected final long nativePtr;
boolean ownPtr = false; boolean ownPtr = false;
native private void ref(long ownPtr); native private void finalize(long nativePtr);
native private void unref(long ownPtr);
native private long getCallLog(long nativePtr); native private long getCallLog(long nativePtr);
private native boolean isIncoming(long nativePtr); private native boolean isIncoming(long nativePtr);
native private long getRemoteAddress(long nativePtr); native private long getRemoteAddress(long nativePtr);
@ -46,10 +45,9 @@ class LinphoneCallImpl implements LinphoneCall {
protected LinphoneCallImpl(long aNativePtr) { protected LinphoneCallImpl(long aNativePtr) {
nativePtr = aNativePtr; nativePtr = aNativePtr;
ref(nativePtr);
} }
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
unref(nativePtr); finalize(nativePtr);
} }
public LinphoneCallLog getCallLog() { public LinphoneCallLog getCallLog() {
long lNativePtr = getCallLog(nativePtr); long lNativePtr = getCallLog(nativePtr);

View file

@ -65,7 +65,7 @@ class LinphoneCoreImpl implements LinphoneCore {
private native int enablePayloadType(long nativePtr, long payloadType, boolean enable); private native int enablePayloadType(long nativePtr, long payloadType, boolean enable);
private native void enableEchoCancellation(long nativePtr,boolean enable); private native void enableEchoCancellation(long nativePtr,boolean enable);
private native boolean isEchoCancellationEnabled(long nativePtr); private native boolean isEchoCancellationEnabled(long nativePtr);
private native long getCurrentCall(long nativePtr) ; private native Object getCurrentCall(long nativePtr) ;
private native void playDtmf(long nativePtr,char dtmf,int duration); private native void playDtmf(long nativePtr,char dtmf,int duration);
private native void stopDtmf(long nativePtr); private native void stopDtmf(long nativePtr);
private native void setVideoWindowId(long nativePtr, Object wid); private native void setVideoWindowId(long nativePtr, Object wid);
@ -285,12 +285,7 @@ class LinphoneCoreImpl implements LinphoneCore {
public synchronized LinphoneCall getCurrentCall() { public synchronized LinphoneCall getCurrentCall() {
isValid(); isValid();
long lNativePtr = getCurrentCall(nativePtr); return (LinphoneCall)getCurrentCall(nativePtr);
if (lNativePtr!=0) {
return new LinphoneCallImpl(lNativePtr);
} else {
return null;
}
} }
public int getPlayLevel() { public int getPlayLevel() {
@ -554,5 +549,4 @@ class LinphoneCoreImpl implements LinphoneCore {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

@ -1 +1 @@
Subproject commit ef7dc050f57967cb63a0b2e6a8d294ca504816b8 Subproject commit 776d58673a12ceb309ad0e0dc50857b82e3a5d87