Page 1 of 2

AutoSpeakerphone during Call with Proximity & Control UI

Posted: 09 Sep 2017 18:23
by pickone
Hi guys!

I have an OnePlus 5 smartphone and the speakerphone setting is not working with automagic, and with no other software which I tried. Now, I try to do this automatic speakerphone during call with proximity condition and triggering a control ui Click but I dont know exactly how to do it because the loop is always clicking the button of speakerphone. This is what I tried till now:

- TRIGGER - IF phone is on CALL (with Incoming/Outgoing call OFF-HOOK ---->
- CONDITION, if CALL STATE (OFF HOOK) ---->
- IF CONDITION FALSE (Loop to check OFF HOOK).
- IF CONDITION TRUE:
-- CONDITION PROXIMITY OVER 2.5cm
-- IF CONDITION FALSE (Loop to check OFF HOOK) @
-- IF CONDITION TRUE:
--- CONTROL UI: checking = check(Speaker); If (checking == FALSE){ Click(Speaker);}
--- Loop to check OFF HOOK
@ CONDITION FALSE it the same thing like the TRUE one but instead checking the proximity over, it is checking the proximity under and is doing the same thing (checking the speaker button if is NOT checked and so on to make it clicked to turn off the speaker phone)

I hope that you understand what I wroted here, the problem is that the speaker phone it is clicked continuous infinite times ... How can I do this AutoSpeaker phone with proximity during call, but from only a SINGLE FLOW ?

Thank you in advance!

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 04:39
by Desmanto
If I understand clearly, what you want is to automatically turn on speakerphone when the phone is not near your ear; AND when you pick it up and put it to ear, the speakerphone automatically turn off?
If it is so, then this flow won't work for you, as action speakerphone doesn't work at your phone.

It is working fine when turning on speakerphone using Control UI. But when you put it to ear, the proximity sensor will turn off the screen, so Control UI won't work anymore, there is no way to use Control UI to turn off speakerphone when the screen is off. So it is one way turn on speakerphone, no way to turn it off back using proximity.

However there is another way to do it, but under certain condition. You have to use your speakerphone only when the phone is facing up properly at flat surface (table or something like that). You can use Trigger Device Orientation Face up to turn on the speakerphone and Device Orientaion Not(Face Up) to turn it off. Then use Control UI to turn on/off accordingly, this is phone I assume you know how to do it already.do it already.

Device Orientation trigger will consume more battery, so you don't want it enabled all the time. At your Call trigger Off-Hook, you need to add action to enable these 2 flow. Then create another flow to Call Trigger Ended to disable them. You don't need any looping in the call trigger flow, only need single action to enable/disable the flow.

Total, you will have 4 flows, One pair for call Off-Hook and Ended to enable/disable the device orientation flow, another pair for Face Up and Not(Face Up). After you have tested them successfully, you can combine the call trigger pair to single flow using single expression checking; and the device orientation flow also into single flow. In the end, you have 2 flows only, one is enabled all the time to check for call; another only enabled when in call.

The usage will be : when you have outgoing/incoming call, the device orientation flow will be enabled and check if the phone is Facing Up properly. You might need to lift up the phone and put if facing up again to make sure the flow got triggered for the first time. As soon as you pick up the phone, before you put it near to ear, the Not(Face Up) will be triggered and set the speakerphone to off before the proximity sensor turn off the screen (when it is near your ear). So you have to give some time for the trigger to work (it should be not longer than a second). If you put down the phone, Face Up will be triggered and turn on speakerphone again.

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 09:15
by pickone
I made some tests, and... when the phone is near to the ear, till the screen goes off, the proximity sensor and control UI have enough time to execute. For real, I made this test and there is enough time to execut commands till the screen goes off, but like I said, my "code" was a mess, the speakerphone button was on/off all the time automatically :)) How can I do the flow with Control UI?

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 10:19
by Desmanto
So your phone delayed the screen off. If so, then just replace the trigger Device Orientation with proximity. The concept is still similiar, only different sensor.

I thought your messy toggle caused by the unnecessary loop. For Control UI, you don't have to query the checking = check(Speaker), since the different trigger will do different things.
Just simply check it, at my phone, proximity far it is

Code: Select all

checkById("com.android.dialer:id/audioButton"); //turn on speakerphone
For the proximity near, then the script will uncheck

Code: Select all

uncheckById("com.android.dialer:id/audioButton"); //turn off speakerphone
Of coz, the UI is probably different at your phone. Use the Overlay Control to get the correct element.

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 10:27
by pickone
Sure, I will try it and I will post the screenshot of the flow. Thank you, brb

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 11:00
by pickone
Look what I've done, but.. the flow it is automatically disables it self... Image

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 12:17
by pickone
I think that I managed how to do it... but not from a single flow (which i'm dissapointed because i like loops, but i think that loop are draining the battery more by checking something very fast per infinite time)... So, I made two flows
first flow: if proximity >2.5cm & screen on & in call = control UI checkbyid
second flow: .................................... uncheckById....

Thats it... but if you have a solution for doing this only from a single flow, please share with me. Thank you

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 12:30
by pickone
still not working, not even with two flows... It is working for just first call, second call the functions are inverted and so on... the checking becomes unchecked and viceversa, first call is with speaker on far from ear, next call is with speaker off far form ear and speaker on near ear... :)))))))

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 16:50
by Desmanto
I think I have replied your post, but my comment somehow disappeared :( (Or maybe network error, not posted)

If you want to do it in single flow, it will be too busy there. Consider per loop you have 4 elements. Each element takes 4 ms, additional 200 ms sleep and let say 100 ms for proximity. So total perloop is about 316 ms, or around 3 loops per second, which total to 12 elements execution per second. Within 5 seconds, you will hit Automagic emergency stop and have your flow disabled. You can increase the emergency stop to 12 x 60 = 720, but I am sure you don't wanna do that.

You can increase the sleep to 500 ms atau 1000 ms, but that will delay the proximity detection and probably your screen will be off first before the sleep. So, the best to do it is stilll the same as I posted at 2nd post; separate the trigger to different flows, one pair for outgoing/incoming to disable/enable the another pair of proximity sensor near/far to turn on/off the speakerphone. Total 4 flows, test it first, make sure it is working. Then you can combine both off-hook and ended flow to one; and the proximity near/far to another one. At last you have only 2 flows with 2 triggers each.

Re: AutoSpeakerphone during Call with Proximity & Control UI

Posted: 10 Sep 2017 21:47
by pickone
... I think that the probem is me because I dont understand exactly what I have to do... :(