Improved destruction of LinphoneCore when device shuts down

This commit is contained in:
Sylvain Berfini 2016-09-21 15:02:19 +02:00
parent ab306f06fd
commit 119a7fe7f4

View file

@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
package org.linphone; package org.linphone;
import org.linphone.core.LinphoneCore;
import org.linphone.core.LinphoneCoreFactory; import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LpConfig; import org.linphone.core.LpConfig;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
@ -32,11 +31,8 @@ public class BootReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SHUTDOWN)) { if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SHUTDOWN)) {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
Log.w("Device is shutting down, destroying LinphoneCore to unregister"); Log.w("Device is shutting down, destroying LinphoneCore to unregister");
lc.destroy(); LinphoneManager.destroy();
}
} else { } else {
String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc"; String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path); LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);