Automatically Enable/Disable native SIP client

3,328 views
Skip to first unread message

Odd_Sam

unread,
Jun 1, 2012, 12:18:58 AM6/1/12
to Tasker
Here's a setup I'm using to Enable and Disable the native SIP client.

Requirements:
- You must have a working SIP account
- If you use multiple accounts you want to disable or enable all of
them.
- You have root access
- Busybox is installed - required commands: am, iptables, su

Premise:
- I have a Cyanogen Based rom (HTC Desire CDMA Android 4.0.4) which
enables modifies the following value in /system/framework/framework-
res.apk/res/values/bools.xml
- - <bool name="config_sip_wifi_only">false</bool>
- I have noticed a significant drop in battery as well as my phone
heating up (which is due to an significant use of the 3G connection).
My home is outside of cell service and I use Google Voice and SIP to
allow all calls and text messages to be received over a WiFi
connection. I want the SIP Client to be enabled when I'm connected to
my home wireless network but turned off when I enter cell service. I
have created a tasker profile to do so.

Explaination:
- Basically I use iptables to drop all outbound packets destined for
my sip provider's IP address. And I use tasker to automate the
manipulation of the firewall. I'm unaware how long it takes the SIP
Client to notice the newly opened/lack of a connection to the SIP
provider so I use a work around which implies opening the "Internet
calling (SIP) accounts" settings page will force a refresh of the
Client's connection. (Or at least remind it to check again)

Profile (I'm not sure how best to deliver the format for this so I've
posted the content from the userbackup.xml file relating to this
profile.):

Task: Enable SIP (23)
A1: Run Shell [ Command:iptables -F Timeout (Seconds):0 Use
Root:On ]
A2: Run Shell [ Command:am start -n
com.android.phone/.sip.SipSettings Timeout (Seconds):0 Use Root:Off ]
A3: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]
A4: Go Home [ Page:0 ]

Task: Disable SIP (24)
A1: Run Shell [ Command:iptables -A OUTPUT -d 204.155.28.10 -j DROP
Timeout (Seconds):0 Use Root:On ]
A2: Run Shell [ Command:am start -n
com.android.phone/.sip.SipSettings Timeout (Seconds):0 Use Root:Off ]
A3: Wait [ MS:0 Seconds:3 Minutes:0 Hours:0 Days:0 ]
A4: Go Home [ Page:0 ]

Notes: My sip provider is SIPGate (204.155.28.10) you would want to
change this IP address to the address of your provider. I also just
drop all outbound packets to that address so for example the website
would not be accessible from the phone's web browser.

I hope this helps anyone who's also been searching for this type of
automation.

Sean Leonard

unread,
Jun 4, 2012, 11:02:10 AM6/4/12
to tas...@googlegroups.com
Wow, great workaround!  Thanks for sharing, Sam.

Soon, you may have a better solution:  I posted in the Secure Settings app/plugin thread on XDA Developers, and the dev responded saying it would be easy to toggle the receive calls setting and set the outgoing calls setting, but not easy to change the "primary account", as that data is stored as binary somewhere, either in the record for the account details, or elsewhere.  They said they would look into implementing for their next release.  Post: http://forum.xda-developers.com/showpost.php?p=26807215&postcount=336

Cheers,
Sean

BossMan

unread,
Jul 12, 2012, 2:05:34 PM7/12/12
to tas...@googlegroups.com
I think the latest version of Secure Settings plugin allows toggling of the built-in SIP client as well.

BR,
A.

Sean Leonard

unread,
Jul 19, 2012, 7:38:54 PM7/19/12
to tas...@googlegroups.com
On Thursday, July 12, 2012 11:05:34 AM UTC-7, BossMan wrote:
I think the latest version of Secure Settings plugin allows toggling of the built-in SIP client as well.

Indeed, it does!

However: Having the "Receive calls..." option unchecked does not actually /prevent/ you from receiving SIP calls.  It's more accurate to say that having the option checked ensures the phone's client stays awake enough to receive them.  As i'm using Google Voice (SIP through an intermediary), incoming calls try to come to me both over my cell number and my SIP client.  I've been having the frustrating experience of the phone ringing for the SIP incoming and not the cell incoming...haven't done any debugging as to why.  Since the call quality over the cell data network is spotty at best, I'm using a combination of using Secure Settings to toggle the options and iptables to block the traffic.

Task description (indentation mine, for readability):
Task: Internet calling (7)
    A1: If [ %par1 ! Set ]
    A2: Variable Set [ Name:%par1 To:ON Do Maths:Off Append:Off ] If [ %VOIP ~ 0 ]
    A3: Variable Set [ Name:%par1 To:OFF Do Maths:Off Append:Off ] If [ %VOIP ~ 1 ]
    A4: End If
    A5: If [ %par1 ~ ON ]
    A6: Secure Settings [ Configuration:SIP: Call Options/For all calls when data is available ]
    A7: Secure Settings [ Configuration:SIP: Receive Calls Enabled ]
    A8: Run Shell [ Command:iptables -D OUTPUT -p tcp --dport 5060:5061 -j DROP; iptables -D OUTPUT -p udp --dport 5060 -j DROP; iptables -D INPUT -p tcp --dport 5060:5061 -j DROP; iptables -D INPUT -p udp --dport 5060 -j DROP; Timeout (Seconds):0 Use Root:On ]
    A9: Variable Set [ Name:%VOIP To:1 Do Maths:Off Append:Off ]
    A10: Else If [ %par1 ~ OFF ]
    A11: Secure Settings [ Configuration:SIP: Receive Calls Disabled ]
    A12: Secure Settings [ Configuration:SIP: Call Options/Only for Internet calls ]
    A13: Run Shell [ Command:iptables -A OUTPUT -p tcp --dport 5060:5061 -j DROP; iptables -A OUTPUT -p udp --dport 5060 -j DROP; iptables -A INPUT -p tcp --dport 5060:5061 -j DROP; iptables -A INPUT -p udp --dport 5060 -j DROP; Timeout (Seconds):0 Use Root:On Continue Task After Error:On ]
    A14: Variable Set [ Name:%VOIP To:0 Do Maths:Off Append:Off ]
    A15: End If
    A16: Perform Task [ Name:MT Refresh Stop:Off Priority:1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]

"MT Refresh" is a task to set all Minimalistic Text variables i'm using; in this case, a string i display on my Widget Locker: "Calls:%CallRoute", with %CallRoute being "VZW" or "VoIP".

Hope that helps someone.

Cheers.


Petr Klus

unread,
Jan 8, 2016, 8:50:12 AM1/8/16
to Tasker
Hello!

Sorry for resurrecting this topic but I am facing exactly the same problem - I am using the native SIP client for my work phone. However, I do not want the work phone to ring outside of business hours. I've set up Tasker to edit the "Recieve SIP calls" checkbox but as you note, this does not actually prevent incoming calls.

Is there any way to block incoming SIP calls based on a schedule? I would like to add that I am on a non-rooted phone nor I want to root one.

Thank you!

Nicholas Vilppu

unread,
Mar 8, 2016, 12:00:15 AM3/8/16
to Tasker
Were you able to find a solution?

Petr Klus

unread,
Mar 8, 2016, 3:11:58 AM3/8/16
to tas...@googlegroups.com
No, there does not seem to be an easy way ..

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/KVYCN1xcoA4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages