sipswitch
sipswitch copied to clipboard
Enable / disable 'receive incoming calls'
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.
The Android API unfortunately doesn't support this at the moment.
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 .
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
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.
Just tried it with SDK 22, it worked for me:
Settings.System.putInt(getApplicationContext().getContentResolver(), "sip_receive_calls", 1);
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.
Ah, OK. I didnt test, if it really works :), just, as you said, that the settings checkbox changed the state.
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
I actually tried this some time ago, but maybe I was too impatient. I think this should be investigated further.
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
See my MR #16 which should triage this
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.