Which sim card is making the call ?

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Which sim card is making the call ?

Post by bogdyro » 28 Nov 2016 18:44

Hello. I have a dualsim phone. One of the sim cards is roaming. Every time I make a phone call I have to choose between the 2 sim cards. The problem is that if i'm not careful I end up making an international phone call which as you can imagine isn't very cheap. So I want to make some kind of warning\protection system that avoids this mistake.
I guess trigger Outgoing phone call is the way to go. However I can't get any additional info about which sim is dialing out. Maybe this could be included in a following update Martin, if the info is readily available. Until then maybe someone knows of a SHELL command that I can use to find out which sim card is making the phone call and based on the number and some filters to end the phone call immediately and throw a error message. Could this be possible ?
Thanks

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Which sim card is making the call ?

Post by Martin » 29 Nov 2016 13:59

Hi,

It seems that no information is available from official APIs to determine the SIM. You could try to extract the information from the dialer screen with action Control UI in case the dialer shows this information at all.

Following might work on some newer multi-sim phones in an action Script:

Code: Select all

telephonyManager=callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "phone");
state=callJavaMethod(telephonyManager, "android.telephony.TelephonyManager", "getCallState(int)", 2);
The variable state will contain value 0 (idle), 1 (ringing) or 2 (off-hook). The number 2 in the script specifies the subscription ID of the sim which is likely a number like 1, 2 or 3. There's currently no easy way to query this ID from Automagic and using Java is a bit complicated.

Regards,
Martin

Post Reply