Kill service when task manager kills UI and restart it when receiving push notification
This commit is contained in:
parent
1bea88a3d0
commit
a49cf71f54
5 changed files with 21 additions and 2 deletions
|
@ -14,6 +14,7 @@ size=vga
|
||||||
[app]
|
[app]
|
||||||
sharing_server=https://www.linphone.org:444/lft.php
|
sharing_server=https://www.linphone.org:444/lft.php
|
||||||
tunnel=disabled
|
tunnel=disabled
|
||||||
|
push_notification=1
|
||||||
|
|
||||||
[tunnel]
|
[tunnel]
|
||||||
host=
|
host=
|
||||||
|
|
|
@ -14,6 +14,7 @@ size=qvga
|
||||||
[app]
|
[app]
|
||||||
sharing_server=https://www.linphone.org:444/lft.php
|
sharing_server=https://www.linphone.org:444/lft.php
|
||||||
tunnel=disabled
|
tunnel=disabled
|
||||||
|
push_notification=1
|
||||||
|
|
||||||
[tunnel]
|
[tunnel]
|
||||||
host=
|
host=
|
||||||
|
|
|
@ -73,7 +73,6 @@
|
||||||
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
<bool name="intercept_outgoing_gsm_calls">false</bool>
|
||||||
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
<bool name="automatically_start_intercepted_outgoing_gsm_call">true</bool>
|
||||||
<bool name="use_linphonecore_ringing">false</bool>
|
<bool name="use_linphonecore_ringing">false</bool>
|
||||||
|
|
||||||
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
<!-- This settings handle the behavior of the view waiting for the remote provisioning configuration to be done -->
|
||||||
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
<bool name="display_sms_remote_provisioning_activity">false</bool>
|
||||||
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
<bool name="forbid_app_usage_until_remote_provisioning_completed">false</bool>
|
||||||
|
@ -91,5 +90,6 @@
|
||||||
<string name="temp_photo_name_with_date">linphone-android-photo-%s.jpg</string>
|
<string name="temp_photo_name_with_date">linphone-android-photo-%s.jpg</string>
|
||||||
|
|
||||||
<bool name="enable_call_notification">true</bool>
|
<bool name="enable_call_notification">true</bool>
|
||||||
|
<bool name="kill_service_with_task_manager">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
@ -554,6 +555,17 @@ public final class LinphoneService extends Service {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
super.onTaskRemoved(rootIntent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onDestroy() {
|
public synchronized void onDestroy() {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
|
|
@ -18,8 +18,11 @@ along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import static android.content.Intent.ACTION_MAIN;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.UIThreadDispatcher;
|
import org.linphone.UIThreadDispatcher;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -47,7 +50,9 @@ public class GCMService extends GCMBaseIntentService {
|
||||||
@Override
|
@Override
|
||||||
protected void onMessage(Context context, Intent intent) {
|
protected void onMessage(Context context, Intent intent) {
|
||||||
Log.d("Push notification received");
|
Log.d("Push notification received");
|
||||||
if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
if (!LinphoneService.isReady()) {
|
||||||
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
|
} else if (LinphoneManager.isInstanciated() && LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
UIThreadDispatcher.dispatch(new Runnable(){
|
UIThreadDispatcher.dispatch(new Runnable(){
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
Loading…
Reference in a new issue