sipswitch icon indicating copy to clipboard operation
sipswitch copied to clipboard

Enable / disable 'receive incoming calls'

Open joost opened this issue 11 years ago • 12 comments

More a feature request.

Would be great if the widget had an easy one click button to enable / disable 'receive incoming calls'. IMHO the 'settings shortcut' button could be used for that.

joost avatar Oct 11 '13 08:10 joost

The Android API unfortunately doesn't support this at the moment.

robert7k avatar Oct 13 '13 19:10 robert7k

Bummer. Thx for the reply! On 13 Oct 2013 21:16, "Robert" [email protected] wrote:

The Android API unfortunately doesn't support this at the moment.

— Reply to this email directly or view it on GitHubhttps://github.com/robert7k/sipswitch/issues/4#issuecomment-26224672 .

joost avatar Oct 13 '13 19:10 joost

Seems to be possible now? There seems to be a setter method for that:

https://android.googlesource.com/platform/packages/apps/Phone/+/650fe766347b4a896085ce8924ace69c029e49d9/src/com/android/phone/sip/SipSharedPreferences.java

scheich avatar Jul 21 '16 16:07 scheich

This class has been there for some time, but it's part of the phone app and thus cannot be called from an outside app.

robert7k avatar Jul 21 '16 17:07 robert7k

Just tried it with SDK 22, it worked for me:

Settings.System.putInt(getApplicationContext().getContentResolver(), "sip_receive_calls", 1);

scheich avatar Jul 21 '16 18:07 scheich

The last time I tried this, only the settings dialog reflected the change. The behavior of the phone was unaffected, i.e. incoming SIP calls would not be received.

robert7k avatar Jul 21 '16 20:07 robert7k

Ah, OK. I didnt test, if it really works :), just, as you said, that the settings checkbox changed the state.

scheich avatar Jul 21 '16 20:07 scheich

Ok, tested. :-P

I could see the changed settings immediately with:

Settings.System.getInt(getApplicationContext().getContentResolver(), "sip_receive_calls");

But I had to send the notify broadcast com.android.phone.SIP_CALL_OPTION_CHANGED, like you do, otherwise it wont worked for me.

If I set it to 0, there was no delay, I didn't receive calls anymore. But if I set to 1, the call is only incoming after a period of time. For me it was 30-60 seconds. I think this has something to do with the sip registration. Perhaps you can force an registration, theres a method for that, but I couldn't find out yet, how to parse through the already defined profiles to get the profile uris.

Tested with CM12 nightly. SIP Provider is Telekom Germany.

EDIT: Perhaps you can get the profiles with the SipSession.Listener

scheich avatar Jul 21 '16 21:07 scheich

I actually tried this some time ago, but maybe I was too impatient. I think this should be investigated further.

robert7k avatar Jul 24 '16 10:07 robert7k

I do really need this, therefore I wrote a small app which works for me very well since months (but requires "root"): https://bitbucket.org/wolfgang/wifisiptoggle

wolfgangasdf avatar Jun 10 '17 11:06 wolfgangasdf

See my MR #16 which should triage this

madmuffin1 avatar Oct 17 '17 19:10 madmuffin1

But I had to send the notify broadcast com.android.phone.SIP_CALL_OPTION_CHANGED, like you do, otherwise it wont worked for me.

Just for reference if someone arrives here googling around, like I did: it seems to me that at a certain point the API was changed. At least on Android 11 (Evolution-X on Poco X3, specifically) the intent to broadcast is now "android.net.sip.action.SIP_CALL_OPTION_CHANGED" . I'm absolutely no Android nor Java expert, so take this with caution, but it works for me.

lx1 avatar Oct 03 '21 10:10 lx1