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">
|
<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.BOOT_COMPLETED"></action></intent-filter>
|
||||||
|
<intent-filter><action android:name="android.intent.action.ACTION_SHUTDOWN"></action></intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<receiver android:name="org.linphone.PhoneStateChangedReceiver">
|
<receiver android:name="org.linphone.PhoneStateChangedReceiver">
|
||||||
|
|
|
@ -18,8 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -29,7 +31,13 @@ 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)) {
|
||||||
|
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";
|
String path = context.getFilesDir().getAbsolutePath() + "/.linphonerc";
|
||||||
LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
|
LpConfig lpConfig = LinphoneCoreFactory.instance().createLpConfig(path);
|
||||||
if (lpConfig.getBool("app", "auto_start", false)) {
|
if (lpConfig.getBool("app", "auto_start", false)) {
|
||||||
|
@ -39,3 +47,4 @@ public class BootReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -539,7 +539,11 @@ public final class LinphoneService extends Service {
|
||||||
public void onTaskRemoved(Intent rootIntent) {
|
public void onTaskRemoved(Intent rootIntent) {
|
||||||
if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) {
|
if (getResources().getBoolean(R.bool.kill_service_with_task_manager)) {
|
||||||
Log.d("Task removed, stop service");
|
Log.d("Task removed, stop service");
|
||||||
|
|
||||||
|
// If push is enabled, don't unregister account, otherwise do unregister
|
||||||
|
if (LinphonePreferences.instance().isPushNotificationEnabled()) {
|
||||||
LinphoneManager.getLc().setNetworkReachable(false);
|
LinphoneManager.getLc().setNetworkReachable(false);
|
||||||
|
}
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}
|
}
|
||||||
super.onTaskRemoved(rootIntent);
|
super.onTaskRemoved(rootIntent);
|
||||||
|
|
Loading…
Reference in a new issue