Multi-SIM target number identification

Post your questions and help other users.

Moderator: Martin

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification

Post by drboa » 28 Jul 2020 21:46

Dear Desmanto,

Thank you for your suggestions. I am trying to migrate to total telephone control by Automagic (together with my smart house) so just hardcore setting different ringtones on different SIM-cards is currently not an option.

I will try to reach out to Martin to see if he can implement this variable in one of his modules - maybe you can support me with an additional message to him? ;)

One thing that really kills me is displayed on the newly attached photos below. The android system very well recognizes which SIM that has been targeted, and displays it as an icon up on the top left notification pane (handset with a number 1 or 2 for the corresponding SIM).
My issue is - this icon is somehow (and extremely unfortunately) INVISIBLE to Automagic. No matter how I look for it, it never shows up in any debug dialogues - even though the trigger (incoming call) activates... ...definitively by another criteria than notification recognition. How can I read this extra info and utilise it in my flows?

It feels like I can touch the solution... ...and yet it is still out of reach...

Thankful for any and all help I can get in this matter! Cheers / B-O

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification

Post by drboa » 28 Jul 2020 21:50

20200728_232702.jpg
Photo1
20200728_232702.jpg (129.19 KiB) Viewed 19600 times
Attachments
20200728_232723.jpg
Photo2
20200728_232723.jpg (382.07 KiB) Viewed 19600 times

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification

Post by drboa » 29 Jul 2020 10:29

Dear all,

Anyone who finds this interesting and useful, please add a "me too"-bump on the following future features request:

viewtopic.php?f=4&t=8780

Many thanks for your support! / B-O

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

Re: Multi-SIM target number identification

Post by Desmanto » 29 Jul 2020 11:20

Martin usually look at all thread when he come back to the forum. He surely will reply when he has time, especially with thread that has ongoing unsolved discussion like this. And you also already made the request, it might take a while for him to find the solution.

I see similar icons too on Xiaomi Phone with MIUI ROM, there is no indication though on the notification on statusbar except that icon 1 / 2. I tried logcat and also can't find any pattern that denotes the source of SIM being called. So if your notification doesn't give you any info on this, it seems there is no direct way to detect it.

Maybe if someone know about java telephony manager, can query the info when there is incoming call, to know which SIM is active.
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.

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification

Post by drboa » 30 Jul 2020 11:33

Dear Desmanto and all,

I found by coincidence the following thread in Internet;

https://stackoverflow.com/questions/213 ... -for-sim-2

It suggests that you can actually probe the incoming target SIM-card-info by ”listening” to a standardised Android broadcast via the following code:

___________________Quote

Please add below codes in your BroadcastReceiver class:

public class IncomingCallInterceptor extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String callingSIM = "";
Bundle bundle = intent.getExtras();
callingSIM =String.valueOf(bundle.getInt("simId", -1));
if(callingSIM == "0"){
// Incoming call from SIM1
}
else if(callingSIM =="1"){
// Incoming call from SIM2
}
}
}

Unquote___________________

Unfortunately I have never worked with such code before... ...does anyone have an idea how to utilise this info in Automagic?

Many thanks in advance to all! / B-O

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

Re: Multi-SIM target number identification

Post by Desmanto » 31 Jul 2020 18:40

I use dumpsys to check the broadcast during call, there is no indication on the SIM source. i don't know much how to use the java code. Maybe if @anuraag is around, he can help to translate this into Automagic scripting version.

I will still recommend using custom ringtone sound. There is a theoritical way to detect the source by using custom ringtone. When there is incoming call, enable another flow which use file observer trigger. This will detect which ringtone is being read, and set the target source sim based on the ringtone to a glovar; which can be used in your other flow.
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.

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification

Post by drboa » 01 Aug 2020 08:36

Dear Desmanto,

I'll take your suggestion under consideration. I'll make two silent ringtones, name them sim1.ogg and sim2.ogg and associate them to their corresponding physical SIM-cards.

Since I want Automagic to control all tones in my phone, they must be silent... If the trigger you suggested works, it is a plausible workaround. Still - I would be positively surprised and thankful if the java code above could be put in an ordinary script OR if this functionality was added to the incoming call trigger as a native output variable.

I'll try the workaround tonight and post my observations.
Cheers / B-O

drboa
Posts: 27
Joined: 01 Dec 2016 07:24

Re: Multi-SIM target number identification (case solved)

Post by drboa » 05 Aug 2020 07:45

Dear Desmanto and all,

I promised to return with my observations regarding the incoming call target-SIM identification "work-around" sketched by Desmanto.

In my case; I wish to mute android sounds, and tailor them for my purposes in Automagic i.e. warning sound for calls to roaming SIM-cards and special ringtones during all hours of the day (usually keeping my phone silent during the night) for a selection of whitelisted contacts.

Solution:
Record a low resolution, mono .mp3 audio file with 2 minutes of silence. Duplicate it and rename the files "SIM1.mp3" and "SIM2.mp3". In your android settings; affiliate them with your corresponding SIM-cards.
Create a flow with a "file monitor" trigger, targeting previously mentioned files and with the attribute "file was opened". In its output variable "registered_path" you will read the file path and can easily identify the name of the silent ringtone that fired off with a simple expression "contains(registered_path,"SIM1");".

If you (like me) want to use that info, to do some Automagic post- processing, call another flow passing on the info to that/them. Usually you would want to collect info about WHO is calling you as well, but that's another flow and another trigger...

The suggested method is rather blunt - I hope to see a target-SIM output variable in the incoming calls-trigger in a future update of Automagic...

Cheers / B-O

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

Re: Multi-SIM target number identification

Post by Desmanto » 05 Aug 2020 17:34

Since you want to have the SIM 1 - 2 source, current workaround seems to be the best solution; until you can find other way to do it. Or maybe you have changed the phone to the one which provide SIM source for the caller in the notification.

For whitelist contact during slient, AFAIK, android already have the exception contact list in the "do not disturb" mode. Their call will pass-thru the DND and still ring as usual. You can still combine it with your special ringtone to detect the SIM Source
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