"Set Speakerphone State: On" makes flow fail

Post your questions and help other users.

Moderator: Martin

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

"Set Speakerphone State: On" makes flow fail

Post by bobeurone » 19 Jul 2020 22:00

I have a simple flow made of 3 steps to answer a phone call.
- Trigger on MYNAME
- Sleep 5sec
- Answer ringing call

When I add a fourth step at the end to turn speaker on, then the whole flow fails: the trigger does not work, neither answering the call.

If I suppress the SpeakerPhone step then flow works again.

Why a failing step would make the whole flow fail?

I am getting lost with Automagic, flows seems to randomly work without changing anything.
Deleting all flows seems to clean runtime but after a few attempts a working flow will start failing even without changing anything to the flow.

Code: Select all

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<data version="1.37.0">
  <trigger type="notification_status_bar_displayed">
    <useDefaultName>false</useDefaultName>
    <name>Notification on Statusbar Displayed: PhoneText contains text MYNAME</name>
    <enabled>false</enabled>
    <packageNameFilter>com.android.incallui</packageNameFilter>
    <textMatchField>TEXT</textMatchField>
    <textMatchType>CONTAINS_TEXT</textMatchType>
    <textFilter>MYNAME</textFilter>
    <ignoreRegular>false</ignoreRegular>
    <ignoreOngoing>false</ignoreOngoing>
  </trigger>
  <action type="answer_ringing_call">
    <useDefaultName>false</useDefaultName>
    <name>Answer Ringing Call</name>
    <method>TELECOM_MANAGER</method>
  </action>
  <action type="set_speakerphone_state">
    <useDefaultName>true</useDefaultName>
    <name>Set Speakerphone State: On</name>
    <enable>true</enable>
  </action>
  <action type="sleep">
    <useDefaultName>true</useDefaultName>
    <name>Sleep: 5s (keep device awake)</name>
    <duration>5s</duration>
    <keepDeviceAwake>true</keepDeviceAwake>
    <allowWakeupFromDeviceIdle>false</allowWakeupFromDeviceIdle>
  </action>
  <flow type="flow">
    <name>Flow1 copy</name>
    <enabled>false</enabled>
    <executionPolicy>PARALLEL</executionPolicy>
    <triggercontainer id="t1" x="70.0" y="-122.5">
      <trigger>Notification on Statusbar Displayed: Phone Text contains text MYNAME</trigger>
    </triggercontainer>
    <actioncontainer id="t2" x="70.0" y="87.5">Sleep: 5s (keep device awake)</actioncontainer>
    <actioncontainer id="t3" x="70.0" y="297.5">Answer Ringing Call</actioncontainer>
    <actioncontainer id="t4" x="70.0" y="507.5">Set Speakerphone State: On</actioncontainer>
    <connection from="t1" to="t2" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
    <connection from="t2" to="t3" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
    <connection from="t3" to="t4" type="NORMAL" sourcePosition="SOUTH" targetPosition="NORTH" />
  </flow>
</data>

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

Re: "Set Speakerphone State: On" makes flow fail

Post by Desmanto » 20 Jul 2020 07:00

Speakerphone sometimes doesn't work in certain ROM/Devices. In that case, you need to use Control UI to toggle the speakerphone. Look at my thread, viewtopic.php?t=6962 and scroll down to post 4 for Bluescre flow sharing. He modify it and use CUI instead.
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.

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

Re: "Set Speakerphone State: On" makes flow fail

Post by bobeurone » 20 Jul 2020 16:36

@Desmanto I tried the flow with an exception on

Code: Select all

Set Speakerphone State: On
but I checked there is no exception and Audio does not turn on.

If I connect directly answer call to action on audioButton it does not work either.

Code: Select all

checkById("com.android.dialer:id/audioButton")
Is the id of audio button independant on language setting ? (I guess yes)

Is there any other way to act on the Audio button?
I also tried Control UI without any success using various button labels (Audio, Speaker and translated variants).
What is the English label name of this loud speaker button?

Code: Select all

Control UI: click("Audio")

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: "Set Speakerphone State: On" makes flow fail

Post by Micky Micky » 20 Jul 2020 19:52

Hello

I don't know what phone you have, but this is for the Samsung S10

clickById("com.samsung.android.incallui:id/fourth_button");

Or

Click ("Speaker")

Speaker is the button's label.

Set Speakerphone State works fine. However, I'm ringing out and not receiving in my test.


Hope this is of some help

Micky
Crude but it works.

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

Re: "Set Speakerphone State: On" makes flow fail

Post by bobeurone » 20 Jul 2020 20:25

@Micky Micky my phone is a Huawei Y5 2019 with Android 9.x
Where can I find the right path and Id for this button? I mean the equivalent to your "com.samsung.android.incallui:id/fourth_button"
I tried variations on this theme "com.huawei.android.incallui:id/ninth_button" (on my device Speaker is the bottom right button of the 3x3 buttons)

Obviously "Speaker" would work only for english setting. I tried all possible variations of translations of click label without any success.

Is there any trace capability on Android that would allow capturing exact UI actions and controls with their labels so that they could be easily incorporated later in magic flows. Typically here I am struggling to identify which button needs to be clicked to activate the speaker.

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

Re: "Set Speakerphone State: On" makes flow fail

Post by bobeurone » 21 Jul 2020 21:30

@Desmanto, I can't get the Speaker activated after phone call is answered. It seems that Answer Call is blocking any further Action in the flow so you are unable to click any button on the phone screen during communication. I tried a parallel flow with two branches but it does not work either:
- Answer call in // with Sleep (2s) followed by Click

My phone is Huawei Y5 2019 with Android 9.x

I also tried the Auto Speaker app without any success.

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

Re: "Set Speakerphone State: On" makes flow fail

Post by Desmanto » 22 Jul 2020 15:59

@bobeurone : You can find the button element id using Control UI Overlay. The tutorial is here : viewtopic.php?f=6&t=7320
However to test it, you need to make a phone call. So preferably call to toll free number and you can test as long as you want.

Even if the answer call is blocking further element, you can still parallel the Control UI to the answer phone. Just need extra sleep (2 seconds is enough) to ensure action answer call has executed completely.
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.

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

Re: "Set Speakerphone State: On" makes flow fail

Post by bobeurone » 22 Jul 2020 20:09

@Desmonto. Thanks a lot. I am going to study all this carefully.

bobeurone
Posts: 18
Joined: 15 Jul 2020 15:09

Re: "Set Speakerphone State: On" makes flow fail

Post by bobeurone » 07 Aug 2020 20:29

@Desmonto I follow steps mentionned

Code: Select all

Requirement
Control UI require Accessibility services. You can turn in on from Automagic settings : Hamburger menu > Settings > Features & Permissions > Accessibility service > check > and you will be brought to android accessibility settings > Enable/activate it. 
When I select Accessibility Service I get a page of Android settings with accesibility sections where there is no one single but multiple buttons on the page:
Audio
Vocal synthesis
Visual
Switch Access

At this point it is unclear what should be Enabled/Activated here as mentionned above in your tutorial.
The checkbox stays unchecked whatever selection I make in the Accessibility settings.

Does this work with the evaluation version or the full version?

Even if Switch Access is enabled the Show Overlay Control button does not work when doing the Airplane mode flow.

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

Re: "Set Speakerphone State: On" makes flow fail

Post by Desmanto » 08 Aug 2020 05:44

Your phone might put accessibility services in different location. In usual AOSP android based ROM, the location is as follow
Enable AM Accessibility services.png
Enable AM Accessibility services.png (197.98 KiB) Viewed 29455 times
This works with all AM version, evaluation and EAP.
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.

Post Reply