[Dual sim] Outgoing call OFFHOOK

Post your questions and help other users.

Moderator: Martin

Post Reply
anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

[Dual sim] Outgoing call OFFHOOK

Post by anuraag » 01 Nov 2017 04:36

Hey martin
Outgoing call OFFHOOK gets instantly triggered on dual sim phones. It doesn't wait for selection of sim.

Can you look into this and make it wait for sim selection before it get triggered on dual sim phones.

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

Re: [Dual sim] Outgoing call OFFHOOK

Post by Desmanto » 01 Nov 2017 09:56

It seems to be phone specific problem, as a lot of vendor implement dual SIM differently. It is usually quite difficult to make it works properly if it deviates too much from the standard. Mine (LP 5.1) doesn't trigger when SIM selection pop up. Only after SIM is selected, the flow will be triggered. You need to tell us your phone model and android version.

The workaround is to use Control UI after the trigger, to loop wait before the Call UI appear. Use the Overlay Control, make a call. When choosing the SIM, tap on the "Info" and see if there is any unique element that only appear in this SIM selection. Usually it is the SIM 1 and SIM 2 element. Tap and choose the value = existElementById() to copy it to clipboard (so you can paste the Id later). After the SIM was selected, find another unique element that only appear after call is made (most likely end button call). Use that element as the identifier. So we have 2 identifier, 1 for SIM selection and another for after SIM selection

Example at my phone, SIM selection identified as "com.android.contacts:id/detail_card1_view" (for SIM1, or can use SIM2 as well; just need one of them), and the end call button identified from the overlay control as "com.android.dialer:id/floating_end_call_action_button" So I will loop the sleep timer after the flow is triggered, as long as the SIM selection exists. After it no longer exists, I will check for the End call button. Control UI :

Code: Select all

while(existsElementById("com.android.contacts:id/detail_card1_view"))
  sleep(200); //sleep as long as the SIM selection opened
sleep(100);

call = false;
if(existsElementById(com.android.dialer:id/floating_end_call_action_button)
  call = true; //if end call button detected, call is in progress.
After this Control UI, put condition expression to check the call value.

Code: Select all

call
Just that, since we have set the value to either true or false. If true, call is in progress, continue to your main flow. If false (end call button is not detected), then do nothing. Maybe during the SIM selection, you change your mind and press back button. So the End call button won't be detected, the flow still got triggered, but won't continue to the main flow because of this expression. That End button call button can't be checked using expression, as function existsElementById() only works in Control UI script. That's why we have to set the result to another variable, the {call}.

So your flow from
Trigger >> Main flow
changed to
Trigger >> Control UI >> Expression >> (True) Main flow

This is a very spesific workaround for certain phone. The element Id is probably different on each phone. You gotta find it out by yourself using the overlay control from Control UI. The same Script won't work at mine, as the Outgoing offhook at my phone, only triggered after the SIM selection is done.

PS: Control UI need Accessibility service to be turned on. Make sure you have enable it for Automagic.
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.

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: [Dual sim] Outgoing call OFFHOOK

Post by anuraag » 02 Nov 2017 00:35

Thanks for control ui idea

Detection of sim selection part worked fine

Code: Select all

 
while (existsElementById("com.android.dialer:id/select_account_list_item_view"))
{sleep(200);}//sleep as long as the SIM selection opened
sleep(100);
However control ui is unable to detect/perform any action on ongoing call. But instead of that i can use call state condition to get whether a call is ongoing.

Strange thing is tasker is able to properly perform off-hook event.

I have moto g5 plus with 7.0

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

Re: [Dual sim] Outgoing call OFFHOOK

Post by Desmanto » 02 Nov 2017 12:15

The control UI script above doesn't click on any element, we simply retrieve UI element, so it supposed to work properly. I ever try the Control UI during call, and it still works; including some crazy idea to replace the caller name by showing widget overlay over it (thus faking the name). Maybe the call process has been protected in Nougat, so no accessibility can work on it.

If tasker can do it, then Automagic probably can do it. But tasker sometimes hide what happen under the hood. Maybe it is implementing the same work around, but doesn't show it to user. There are several event and state which sometimes can behave unpredictable because it doesn't show us what really happens.
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