Toggle Receive Incoming Calls (SIP Receive Calls)

Create task to toggle Receive Incoming Calls and effectively use AutoTools Read Custom Settings

  1. autormali
    Below is working with Android 6.0 and above.

    Requirements: AutoInput, AutoShare, set and active SIP account. Optionally AutoTools.

    Import Calling Accounts Settings intent to AutoShare. It opens Calling Accounts and SIP settings.
    Code (Text):
    {"target":"Activity","appname":"Phone","name":"Calling Accounts Settings","package":"com.android.phone","action":"android.telecom.action.CHANGE_PHONE_ACCOUNTS","categories":[{"category":"android.intent.category.DEFAULT","name":"Default"}],"class":"com.android.phone.settings.PhoneAccountSettingsActivity","id":"PHONE_CALLING_ACCOUNTS_SETTINGS"}

    STEP 1 - CREATE TOGGLE ACTIONS


    • Create New Tasker Task, call it Toggle Receive Incoming Calls.
    • Add AutoShare action. In configuration App set to Phone and Action to Calling Account Settings.
    • Run the task from Tasker. Check if intent is working.
    • Add AutoInput Action.
    • Click Easy Setup.
    • Go to Calling Accounts.
    • Tap Add on AutoInput notification.
    • Tap checkbox next to Receive incoming calls.
    • On AutoInput notification tap Accept and go to Tasker
    • In Select Element Field tap Element Text: Receive incoming calls.
    • Action to perform set to Click.
    • Run the task a few times. Check if checkbox is enabling and disabling.
    • Add AutoInput Global Action Back.
    (i)We created toggle task. The next steps of this tutorial are optional.
    We dont't know what is the status of Receive Incoming Calls before and after toggling. Please go to the next steps if you want to find out how to get the status of Receive Incoming Calls.​

    STEP 2 - CREATE TOAST ACTIONS


    • Add AutoTools Secure Settings action.
    • Tap Custom Setting.
    • Choose Setting Type to System.
    • In Name enter sip_receive_calls.
    • Input Type set to Int.
    • Enable Read Setting option.
    • Add If action with condition %sip_receive_calls~1.
    • Create Flash action: Receive incoming calls enabled.
    • Add Else action with condition %sip_receive_calls~0.
    • Create Flash action: Receive incoming calls disabled.
    • Add End If action.
    (i)Android System Settings constant sip_receive_calls can have only two values: 0 - when Receive Incoming Calls is disabled and 1 if it's enabled. We are reading the constant value with AutoTools Secure Settings and giving the toasts informing us what is the state of Receive Incoming Calls after it's toggled.​

    STEP 3 - CREATE DIALOG


    • Copy AutoTools Secure Settings, If, Else And End If actions created in step 2.
    • Create New Tasker Task, call it Dialog Receive Incoming Calls.
    • Paste coppied acctions.
    • Between If and Else actions create two Variable Set actions: %titlestatus set to enabled, %choicestatus set to disable.
    • Between Else and End if actions create two Variable Set actions: %titlestatus set to disabled, %choicestatus set to enable.
    • Add AutoTools 2 Choices Dialog action.
    • In Title enter: Receive Incoming Calls is %titlestatus.
    • In Choice One and Choice One Command enter: %choicestatus.
    • Choice Two set to OK.
    • For the Icon assign this.
    • Tap Advanced and disable Cancelable option.
    • Set Timeout to Never for this action.
    • Add If action with condition %atcommand~%choicestatus.
    • Add Perform Task action and choose task Toggle Receive Incoming Calls.
    • Add Else action.
    • Create Flash action: Receive incoming calls remains %titlestatus
    • Add End If action.
    (i)Here we used again AutoTools Secure Settings to get status of Receive Incoming Calls before toggling. Dialog settings (disablie Cancelable and Timeout set to Never) allows you to toggle it manually later, after the task was triggered.​

    STEP 4 - TEST THE TASKS


    Instead of flash and dialog actions you can use notifications... Possibilities are endless ;)