Fix crash on background

This commit is contained in:
Erwan Croze 2018-10-11 14:48:07 +02:00
parent c504653079
commit 488b4d10ee
5 changed files with 14 additions and 10 deletions

View file

@ -2,8 +2,8 @@
<manifest package="org.linphone"
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
android:versionCode="1460"
android:versionName="1.4.6">
android:versionCode="2000"
android:versionName="2.0.0">
<uses-sdk
android:minSdkVersion="26"
@ -199,7 +199,7 @@
<service
android:name=".LinphoneService"
android:label="@string/service_name"
android:stopWithTask="false"/>
/>
<service
android:name=".sync.SyncService"
android:exported="true">

View file

@ -46,7 +46,6 @@ activation_code_length=4
show_login_view=1
friendlist_subscription_enabled=1
debug_popup_magic=#1234
debug=1
[assistant]
password_max_length=-1

View file

@ -990,9 +990,10 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
public static synchronized void destroy() {
if (instance == null) return;
getInstance().changeStatusToOffline();
instance.changeStatusToOffline();
sExited = true;
instance.destroyCore();
instance = null;
}
private String getString(int key) {

View file

@ -84,7 +84,7 @@ import static org.linphone.LinphoneUtils.getZrtpStatus;
* Linphone service, reacting to Incoming calls, ...<br />
*
* Roles include:<ul>
* <li>Initializing LinphoneManager</li>
* <li>Initializing LinphoneManager</li>F
* <li>Starting C libLinphone through LinphoneManager</li>
* <li>Reacting to LinphoneManager state changes</li>
* <li>Delegating GUI state change actions to GUI listener</li>
@ -322,8 +322,12 @@ public final class LinphoneService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
if (!LinphoneManager.isInstanciated())
LinphoneManager.createAndStart(LinphoneService.this);
if (instance != null) {
Log.w("Attempt to start the LinphoneService but it is already running !");
return START_REDELIVER_INTENT;
}
LinphoneManager.createAndStart(LinphoneService.this);
instance = this; // instance is ready once linphone manager has been created
LinphoneManager.getLc().addListener(mListener = new CoreListenerStub() {
@ -438,7 +442,7 @@ public final class LinphoneService extends Service {
AlarmManager alarmManager = ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE));
Compatibility.scheduleAlarm(alarmManager, AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 600000, keepAlivePendingIntent);
return START_STICKY;
return START_REDELIVER_INTENT;
}
@SuppressWarnings("unchecked")

View file

@ -39,7 +39,7 @@ public class BootReceiver extends BroadcastReceiver {
} else {
boolean autostart = LinphonePreferences.instance().isAutoStartEnabled();
android.util.Log.i("LinphoneBootReceiver", "Device is starting, auto_start is " + autostart);
if (autostart) {
if (autostart && !LinphoneService.isReady()) {
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
lLinphoneServiceIntent.putExtra("ForceStartForeground", true);