Dual SIM card - change "mobile data" provider based on location

2,643 views
Skip to first unread message

Janez Kranjski

unread,
Jul 5, 2018, 3:30:22 AM7/5/18
to Tasker
I use two SIM cards (different providers) in my OnePlus 5.
I can change which provider will be used for mobile data in "Sim & Networks -> Mobile data" and it works as it should.
But it is annoying to do this many times a day because each provider has its pros and cons locations
How can I automate this based on location? I spend some minutes in Tasker, but I didn't find mentioned setting.  

joaomgcd

unread,
Jul 6, 2018, 4:44:39 AM7/6/18
to Tasker
Did you try using the Custom Setting action and try to find the setting automatically? Maybe that works. Thanks!

Janez Kranjski

unread,
Jul 6, 2018, 5:20:40 AM7/6/18
to Tasker
Thank you. Your suggestion helped a lot :-) 

João Dias

unread,
Jul 6, 2018, 5:31:48 AM7/6/18
to tas...@googlegroups.com
So it worked? :) Great!

Janez Kranjski

unread,
Jul 6, 2018, 5:36:35 AM7/6/18
to Tasker
I'm not sure yet. I prepared task and will see on my way home :-) 

João Dias

unread,
Jul 6, 2018, 6:01:51 AM7/6/18
to tas...@googlegroups.com
Ok. Hope it works! Some settings simply can't be changed this way, but if you're lucky it'll work!

Janez Kranjski

unread,
Jul 7, 2018, 3:47:26 AM7/7/18
to Tasker
Report:
Both tasks (task itself and exit task) work in that way that they change what is written in "Sim & Networks -> Mobile data". So, it changes to expected/wanted provider. 
BUT - this only disconnects the active one but not connect to the wanted provider. As I said, the setting has a new provider selected, an old provider is disconnected, but there is no signal with a new provider.
Well signal is, but there is no 4G sign near signal indicator.

Any idea? Can I restart network or do something additional after changing settings?

Message has been deleted

Janez Kranjski

unread,
Jul 9, 2018, 2:54:53 AM7/9/18
to Tasker
Can this be a "Custom Settings" feature bug?
I read about similar problems here on the forum. It looks like it changes the desired setting, but phone doesn't react to this (well at least in some cases).

João Dias

unread,
Jul 9, 2018, 4:42:22 AM7/9/18
to tas...@googlegroups.com
Yes, unfortunately not all settings will work this way. Sorry! Does it work if you reboot after changing the setting? 

Janez Kranjski

unread,
Jul 9, 2018, 4:53:59 AM7/9/18
to Tasker
Tnx.
No, it doesn't work even after rebooting the phone.
Short conclusion:
1. Task (with Custom settings) changes selected mobile data provider - for example from SIM2 to SIM1 (I can see it).
2. Even if SIM1 is shown in a dialog, the phone still uses SIM2 provider for mobile data. But if I click with a finger to SIM1, then phone will change to SIM1 as it should.
3. After reboot, SIM2 is selected again (if this was changed from Tasker, otherwise it works as expected). 

BTW - Do you think that this will work next versions?

João Dias

unread,
Jul 9, 2018, 5:23:08 AM7/9/18
to tas...@googlegroups.com
No, sorry, some settings simply aren't prepared to be controlled from the background like this.. Maybe you can work around it using AutoInput

Janez Kranjski

unread,
Jul 9, 2018, 5:29:34 AM7/9/18
to Tasker
I tried yesterday, but without success. 
As a newbie to AutoInput, I tried many times, but task simply didn't open the right menu. 
Is there any way to find Android IDs of the menu? I'm not sure which way is the best. In many attempts, I was not successful. Is maybe better working with screen position or some other idea?

João Dias

unread,
Jul 9, 2018, 5:33:06 AM7/9/18
to tas...@googlegroups.com
Usually what works best in Android menus is to simply use the text :) Did you try that?

Janez Kranjski

unread,
Jul 9, 2018, 5:48:51 AM7/9/18
to Tasker
Yes, I did.
But in page "SIM & network" there are two same strings "Mobile data" and I want to change the second one and Tasker want to change the first one :-)

João Dias

unread,
Jul 9, 2018, 6:18:36 AM7/9/18
to tas...@googlegroups.com
Can you please show me a screenshot of that? Thanks!

Janez Kranjski

unread,
Jul 9, 2018, 6:31:49 AM7/9/18
to Tasker
Of course ... Attachment.
Screenshot_20180709-122849.jpg

João Dias

unread,
Jul 9, 2018, 10:56:03 AM7/9/18
to tas...@googlegroups.com
Did you try clicking on the text "Mobitel"? :)

Janez Kranjski

unread,
Jul 9, 2018, 11:35:54 PM7/9/18
to Tasker
I tried many times, so I'm not sure. But yesterday I tried with a combination of "text" and "number in the menu" with AutoInput. I also noticed that wait 300-500 milliseconds between each action is very helpful.
Now it works, but only from time to time, to be honest. 
This morning I found "Accessibility service not running" (in attachment). I'm new to Tasker but I'm sure that I get this error before. When I check this in Android settings, it is enabled. Then I have to disable/enable it and it starts working. 

Any idea about this?

And not to forget - otherwise, I'm an experienced Android user but until now, I didn't use Tasker. So, I'm new to Tasker and I was really surprised how powerful this application is. I bought it and I'm sure that my friends will also be keen on it. 
Screenshot_20180710-052025.jpg

João Dias

unread,
Jul 10, 2018, 4:35:11 AM7/10/18
to tas...@googlegroups.com
Do you think that AutoInput crashed before that error appeared? If not, something on your system is probably killing AutoInput in the background. Make sure the option for it to run in the foreground is selected in the main app and that no third-party app is killing it.

Janez Kranjski

unread,
Jul 10, 2018, 4:45:12 AM7/10/18
to Tasker
I disabled Battery optimization for AutoInput. Maybe this will help. 
Tasker battery optimization was disabled before.

Janez Kranjski

unread,
Jul 10, 2018, 11:43:05 AM7/10/18
to Tasker
Now I found something strange:
1. If I run Task manually, everything works fine.
2. If Task is triggered by profile, the task starts but then stops. 

I enable logging and maybe someone can comment this:

20180710 16.18.39 P Active   ID2 Home

20180710 16.18.40 E Start    ID0:0.0 TaskService

20180710 16.18.40 T Running  ID12 M

20180710 16.18.40 A OK       ID12.1 M.Launch App

20180710 16.18.40 A OK       ID12.2 M.Wait

20180710 16.18.40 A OK       ID12.3 M.com.joaomgcd.autoinput\n***\n*!&$*;com.joaomgcd.autoinput.activity.ActivityConfigPerformAction

20180710 16.19.00 T ExitErr  ID12 M

20180710 16.19.00 E Stop     ID0:0.0 TaskService

20180710 16.19.01 E Start    ID0:0.0 TaskService

20180710 16.19.02 E Stop     ID0:0.0 TaskService


20180710 16.41.10 E Start    ID0:0.0 TaskService

20180710 16.41.10 T Running  ID12 M

20180710 16.41.10 A OK       ID12.1 M.Launch App

20180710 16.41.11 A OK       ID12.2 M.Wait

20180710 16.41.11 A OK       ID12.3 M.com.joaomgcd.autoinput\n***\n*!&$*;com.joaomgcd.autoinput.activity.ActivityConfigPerformAction

20180710 16.41.12 A OK       ID12.4 M.Wait

20180710 16.41.12 A OK       ID12.5 M.com.joaomgcd.autoinput\n***\n*!&$*;com.joaomgcd.autoinput.activity.ActivityConfigPerformAction

20180710 16.41.13 A OK       ID12.6 M.Wait

20180710 16.41.13 A OK       ID12.7 M.com.joaomgcd.autoinput\n***\n*!&$*;com.joaomgcd.autoinput.activity.ActivityConfigPerformAction

20180710 16.41.13 T ExitOK   ID12 M

20180710 16.41.13 E Stop     ID0:0.0 TaskService


Any idea?

João Dias

unread,
Jul 11, 2018, 9:26:15 AM7/11/18
to tas...@googlegroups.com
Can you please export your profile's description (not xml) so I can take a look? Long-click the profile in Tasker->export description Thanks in advance

Janez Kranjski

unread,
Jul 11, 2018, 1:00:13 PM7/11/18
to Tasker
Yes. Here is it:

Profile: Tunjice (2)
Location: 46.2463493347168 / 14.580606460571289 / 2000.0m
Enter: M (12)
A1: Launch App [ App:Settings
Settings Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]
A2: Wait [ MS:609 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A3: AutoInput Action [ Configuration:Type: Text
Value: SIM & network
Action : Click Timeout (Seconds):20 ]
A4: Wait [ MS:877 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A5: AutoInput Action [ Configuration:Type: List
Value: 12
Action : Click Timeout (Seconds):20 ]
A6: Wait [ MS:797 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A7: AutoInput Action [ Configuration:Type: Text
Value: SIM 2  (Mobitel)
Action : Click Timeout (Seconds):20 ]

Exit: T (4)
A1: Launch App [ App:Settings
Settings Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]
A2: Wait [ MS:383 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A3: AutoInput Action [ Configuration:Type: Text
Value: SIM & network
Action : Click Timeout (Seconds):8 ]
A4: Wait [ MS:846 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A5: AutoInput Action [ Configuration:Type: List
Value: 12
Action : Click Timeout (Seconds):20 ]
A6: Wait [ MS:896 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A7: AutoInput Action [ Configuration:Type: Text
Value: SIM 1  (TELEMACH)
Action : Click Timeout (Seconds):20 ]
 


And there is also one more issue which is maybe connected with this - I'm often getting errors. Please see the attachment. 

Thank you for your great support.

Screenshot_20180711-124209.jpg

João Dias

unread,
Jul 12, 2018, 5:01:21 AM7/12/18
to tas...@googlegroups.com
Is the screen off when that happens? The screen must be on and unlocked for AutoInput to do its thing...

Janez Kranjski

unread,
Jul 12, 2018, 5:06:27 AM7/12/18
to Tasker
Yes, the screen was off. 
My idea was that task is triggered when I come to my valley. And if I drive then the screen is normally off.
Should I add a task on beginning to switch the screen on? Is that possible?

João Dias

unread,
Jul 12, 2018, 5:08:14 AM7/12/18
to tas...@googlegroups.com
Yes, but only if your screen lock allows it. If you have to unlock it manually it won't work, sorry!

Jimmy Jimmy

unread,
Jul 12, 2018, 11:36:50 PM7/12/18
to Tasker
Yes, when the profile triggers and if the screen is off, you can add a few actions to turn screen on, and enter the pin to unlock your phone with AutoInput. Then run your other SIM switching actions.

Janez Kranjski

unread,
Jul 12, 2018, 11:50:41 PM7/12/18
to Tasker
I added a "Screen On" at the beginning of an action. My phone use fingerprint for unlocking the phone. 
It looks that profile is started but is waiting until I press on the fingerprint scanner. After that, action works.
This isn't perfect, but it is quite usable. It needs more test to be sure if everything is ok.

João Dias

unread,
Jul 13, 2018, 3:54:53 AM7/13/18
to tas...@googlegroups.com
Great :)

--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Janez Kranjski

unread,
Jul 17, 2018, 1:01:49 PM7/17/18
to Tasker
After some days, I can say that the solution isn't perfect :-(
So I'm looking forward.

Can Tasker get an information (to a variable) which SIM card (SIM1 or SIM2) is selected for data?

João Dias

unread,
Jul 17, 2018, 1:02:52 PM7/17/18
to tas...@googlegroups.com
Maybe try with the Custom Settings action?

--

Jimmy Jimmy

unread,
Jul 17, 2018, 9:54:06 PM7/17/18
to Tasker
After a screen on action, you can use AI to unlock your phone using PIN. I believe even though you have fingerprint enabled, you always have a PIN. This will then work automatically.
Reply all
Reply to author
Forward
0 new messages