fix exception at exit, when callState event is received.

This commit is contained in:
Simon Morlat 2011-08-16 16:13:22 +02:00
parent e0c3390938
commit b78cf07c2f
2 changed files with 13 additions and 5 deletions

View file

@ -386,6 +386,10 @@ public class DialerActivity extends SoftVolumeActivity implements LinphoneGuiLis
public void onCallStateChanged(LinphoneCall call, State state, String message) { public void onCallStateChanged(LinphoneCall call, State state, String message) {
LinphoneCore lc = LinphoneManager.getLc(); LinphoneCore lc = LinphoneManager.getLc();
if (lc==null) {
/* we are certainly exiting, ignore then.*/
return;
}
if (state == LinphoneCall.State.OutgoingInit) { if (state == LinphoneCall.State.OutgoingInit) {
enterIncallMode(lc); enterIncallMode(lc);
} else if (state == LinphoneCall.State.IncomingReceived) { } else if (state == LinphoneCall.State.IncomingReceived) {

View file

@ -113,9 +113,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
private static LinphonePreferenceManager lpm; private static LinphonePreferenceManager lpm;
private String lastLcStatusMessage; private String lastLcStatusMessage;
private String basePath; private String basePath;
private static boolean sExited;
private LinphoneManager(final Context c) { private LinphoneManager(final Context c) {
sExited=false;
basePath = c.getFilesDir().getAbsolutePath(); basePath = c.getFilesDir().getAbsolutePath();
linphoneInitialConfigFile = basePath + "/linphonerc"; linphoneInitialConfigFile = basePath + "/linphonerc";
linphoneConfigFile = basePath + "/.linphonerc"; linphoneConfigFile = basePath + "/.linphonerc";
@ -209,14 +211,16 @@ public final class LinphoneManager implements LinphoneCoreListener {
return instance; return instance;
} }
public static final LinphoneManager getInstance() { public static synchronized final LinphoneManager getInstance() {
if (instance != null) return instance; if (instance != null) return instance;
throw new RuntimeException("Linphone Manager should be created before accessed"); if (!sExited) throw new RuntimeException("Linphone Manager should be created before accessed");
return null;
} }
public static final LinphoneCore getLc() { public static synchronized final LinphoneCore getLc() {
return getInstance().mLc; LinphoneManager m=getInstance();
return m!=null ? m.mLc : null;
} }
@ -592,7 +596,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
public static synchronized void destroy(Context context) { public static synchronized void destroy(Context context) {
if (instance == null) return; if (instance == null) return;
sExited=true;
try { try {
instance.mTimer.cancel(); instance.mTimer.cancel();
instance.mLc.destroy(); instance.mLc.destroy();