Auto Call Speakerphone

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Auto Call Speakerphone

Post by Desmanto » 12 Sep 2017 15:22

This set of flow is created based on this thread : AutoSpeakerphone during Call with Proximity & Control UI
This require accessibility (Control UI), so make sure you have turn it on for automagic.
Auto Speakerphone

The usage of these 2 flows is to automatically turn on/off speakerphone when proximity is detected near or far during call. To preserve battery life, proximity detection will only be enabled during call, thus requires another separate flow to enable/disable it.

Proximity Auto Speakerphone
This flow consist of two triggers, Proximity near and Proximity far (you maybe need to adjust the value for your phone).

The next expression after the trigger is to split the trigger event, so that we can put 2 triggers into single flow. We use condition expression because it is faster and accurate. At some phone condition Proximity sensor sometimes takes 100-300 ms to complete the checking. While we need our flow to execute as fast as possible. (we are racing with the default built-in screen off)

If proximity is near, for example we put the phone near to our ear; Control UI will turn off the Speakerphone. If proximity is far, for example we put on the table or hold it on our hand; Control UI will turn on the Speakerphone. You must change the Control UI script to match the one in your phone. You phone maybe use another dialer, with another elementId for the SpeakerPhone.

Pro Tips : For those phones with the Action Speakerphone can work properly (as at mine), you can replace the Control UI with Set Speakerphone State On and Off. It works more reliable and don't require accessibility.

Call Auto Speakerphone
This flow consist of 4 triggers (yes, four). They are
1. Incoming Call. State: Off-hook, Numbers: All
2. Outgoing Call: all, Off-hook

3. Incoming Call. State: Ended, Numbers: All
4. Outgoing Call: all, Ended


1 & 2 are used to detect any off-hook (active call), whether it is incoming or outgoing. 3 & 4 to detect ended call. So it covers all scenario. You can delete some of the triggers if you need it only at certain event (example only for incoming).

Next check is expression. Since we have 4 triggers in two pairs, we have to use two expressions. First expression is to check if it is triggered from Off-hook pair, another expression for ended-pair. If it is off-hook, enable the Proximity flow; if ended, disable proximity flow. This way, proximity flow will never consume any battery outside of a call. (where it also serve no use outside of call). You only need to enable this flow to use this 2 flows. Since Proximity flow will be enabled/disabled from this flow.

Testing
You can try it by making a phone call to free of charge number, or just call your nearby person and tell them not to answer the phone. Cover the proximity, you should have nothing (since it is the first trigger after enabled). Uncover it, your speakerphone should be on. Cover it again and speakerphone should be off. This flow won't impact the battery life much, since the proximity is only enabled during call.

Further Modification
Remember this only works on regular phone call. For other VoIP/messenger call, you have to checked on how they give the status of calling. For example, whatsapp will have ongoing notification with text "Ongoing Voice Call", which can be detected using Notification on Status bar trigger. The speakerphone button also must be adjusted to match the app's element.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: Auto Call Speakerphone

Post by Bluscre » 12 Sep 2017 18:53

why not use a exception line to use control ui when toggle speakerphone isn't available?
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Call Speakerphone

Post by Desmanto » 13 Sep 2017 02:11

For example?

Maybe need to add some if() to check the state. Actually it only need one control Ui. But i make it using expression because someone can use set speakerphone state.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: Auto Call Speakerphone

Post by Bluscre » 13 Sep 2017 02:26

Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Call Speakerphone

Post by Desmanto » 13 Sep 2017 02:43

Yeah. That will work too if the action set speakerphone gives error. My phone speakerphone action works, so I can't check what happen if the action fail. Thanks for the addition.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
Bluscre
Posts: 145
Joined: 31 Aug 2017 13:58
Location: Germany
Contact:

Re: Auto Call Speakerphone

Post by Bluscre » 13 Sep 2017 02:58

No problemo ^^ i use the same thing in my API for the screenshot stuff
Unofficial AutoMagic Telegram Group: https://t.me/automagicforandroid
Check out my other flows here: https://github.com/Bluscream/AutoMagicFlows or here.

Post Reply