Unregister when task is killed and push is disabled and when device shuts down
This commit is contained in:
parent
839353de7a
commit
c58e24aaed
3 changed files with 24 additions and 10 deletions
|
@ -189,6 +189,7 @@
|
|||
|
||||
<receiver android:name="org.linphone.BootReceiver">
|
||||
<intent-filter><action android:name="android.intent.action.BOOT_COMPLETED"></action></intent-filter>
|
||||
<intent-filter><action android:name="android.intent.action.ACTION_SHUTDOWN"></action></intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name="org.linphone.PhoneStateChangedReceiver">
|
||||
|
@ -244,8 +245,8 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="org.linphone.tutorials.TutorialCardDavSync"
|
||||
android:theme="@style/NoTitle">
|
||||
<activity android:name="org.linphone.tutorials.TutorialCardDavSync"
|
||||
android:theme="@style/NoTitle">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
|
|
|
@ -18,8 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
package org.linphone;
|
||||
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LpConfig;
|
||||
import org.linphone.mediastream.Log;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
@ -29,13 +31,20 @@ public class BootReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
|
||||
LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
|
||||
if (lpConfig.getBool("app", "auto_start", false)) {
|
||||
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
||||
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
|
||||
context.startService(lLinphoneServiceIntent);
|
||||
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_SHUTDOWN)) {
|
||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
if (lc != null) {
|
||||
Log.w("Device is shutting down, destroying LinphoneCore to unregister");
|
||||
lc.destroy();
|
||||
}
|
||||
} else {
|
||||
String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
|
||||
LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
|
||||
if (lpConfig.getBool("app", "auto_start", false)) {
|
||||
Intent lLinphoneServiceIntent = new Intent(Intent.ACTION_MAIN);
|
||||
lLinphoneServiceIntent.setClass(context, LinphoneService.class);
|
||||
context.startService(lLinphoneServiceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -539,7 +539,11 @@ public final class LinphoneService extends Service {
|
|||
public void onTaskRemoved(Intent rootIntent) {
|
||||
if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) {
|
||||
Log.d("Task removed, stop service");
|
||||
LinphoneManager.getLc().setNetworkReachable(false);
|
||||
|
||||
// If push is enabled, don't unregister account, otherwise do unregister
|
||||
if (LinphonePreferences.instance().isPushNotificationEnabled()) {
|
||||
LinphoneManager.getLc().setNetworkReachable(false);
|
||||
}
|
||||
stopSelf();
|
||||
}
|
||||
super.onTaskRemoved(rootIntent);
|
||||
|
|
Loading…
Reference in a new issue