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) {
LinphoneCore lc = LinphoneManager.getLc();
if (lc==null) {
/* we are certainly exiting, ignore then.*/
return;
}
if (state == LinphoneCall.State.OutgoingInit) {
enterIncallMode(lc);
} else if (state == LinphoneCall.State.IncomingReceived) {

View file

@ -113,9 +113,11 @@ public final class LinphoneManager implements LinphoneCoreListener {
private static LinphonePreferenceManager lpm;
private String lastLcStatusMessage;
private String basePath;
private static boolean sExited;
private LinphoneManager(final Context c) {
sExited=false;
basePath = c.getFilesDir().getAbsolutePath();
linphoneInitialConfigFile = basePath + "/linphonerc";
linphoneConfigFile = basePath + "/.linphonerc";
@ -209,14 +211,16 @@ public final class LinphoneManager implements LinphoneCoreListener {
return instance;
}
public static final LinphoneManager getInstance() {
public static synchronized final LinphoneManager getInstance() {
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() {
return getInstance().mLc;
public static synchronized final LinphoneCore getLc() {
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) {
if (instance == null) return;
sExited=true;
try {
instance.mTimer.cancel();
instance.mLc.destroy();