Fix possible crash in the onTaskRemoved() method of LinphoneService if the LinphoneManager has already been destroyed.

This commit is contained in:
Ghislain MARY 2017-08-02 12:44:07 +02:00
parent 29b2621dca
commit a3bbd0b5ef
2 changed files with 3 additions and 2 deletions

View file

@ -487,7 +487,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
if (sExited) {
throw new RuntimeException("Linphone Manager was already destroyed. "
+ "Better use getLcIfManagerNotDestroyed and check returned value");
+ "Better use getLcIfManagerNotDestroyedOrNull and check returned value");
}
throw new RuntimeException("Linphone Manager should be created before accessed");

View file

@ -801,7 +801,8 @@ public final class LinphoneService extends Service {
// If push is enabled, don't unregister account, otherwise do unregister
if (LinphonePreferences.instance().isPushNotificationEnabled()) {
LinphoneManager.getLc().setNetworkReachable(false);
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) lc.setNetworkReachable(false);
}
stopSelf();
}