[Google Pixel 2 XL Questions & Answers] Cdaddy002:
In my previous post I didn't mention that the fiswitch solution didn't work for my device (pixel 4). When googling for a way to switch SIMs without going through a hundred menus, this post is one of the first that always came up. My previous post had some issues, which I hope are cleaned up. If there are other ways to accomplish this, someone please reply and let me know where.

Disclaimer: I'm not a tasker expert. Just an old guy that enjoys making shtuff work. The tasker stuff is after the green text (if you just want to scroll).

I have Google fi and at&t. All I wanted was a quick tile to switch from one sim to the other and back. For my setup I primarily use Fi for phone and sms. I switch between Fi and at&t data depending on who's fastest.

Fi has 3 cellular providers, TMobile, Sprint and US cellular.

There are 9 options for providers in Android global settings:

mobile_data1, mobile_data2, ... mobile_data9 (might also be a mobile_data (with out a numerical suffix), can't remember lol).

Your sim will use one for each provider. So I would have 3 providers for Fi and 1 for at&t. You will need to figure out which of the 9 you are using. Easy way would be to use autotools and read the values of these settings then just "flash" the value on the screen. If you have a computer and can use adb, that works too. You can use fiswitch to change Fi providers, then use the flash method to figure out the provider number.

In my case it was mobile_data4 (TMobile), mobile_data5 (Sprint), mobile_data6 (US cellular), and mobile_data8 (at&t).

When switching SIMs the active sim has all of its providers disabled. The providers for the new sim are then enabled. After that you update a setting (multi_sim_data_call) to tell Android which provider to use for data. You will want to disable data, update this setting, then enable data. You will also need to stop and start ril-daemon using a shell command (toggling air plane mode works too, but I think restarting ril is faster).

Note: because I use the Fi sim for phone, I use the multi_sim_voice_call setting to figure out which provider (ex 4,5,6) to use when switching data to fi.

I used autotools to set the globals because that's where I started (it's working great so I don't want to mess with it). There are probably several ways to do it.

Here's what I did in tasker:

SIM Swap Example (18)

<get current data provider>

A1: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Read Setting: true Timeout (Seconds):60 ]

<get current phone provider>

A2: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_voice_call

Input Type: String

Read Setting: true Timeout (Seconds):60 ]

A3: [X] Flash [ Text:Data: %multi_sim_data_call Voice: %multi_sim_voice_call Long:eek:ff ]

<if att>

A4: If [ %multi_sim_data_call ~ 8 ]

<disable att>

A5: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data8

Input Type: Int

Value: 0 Timeout (Seconds):60 ]

<enable TMobile>

A6: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data4

Input Type: Int

Value: 1 Timeout (Seconds):60 ]

<enable sprint>

A7: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data5

Input Type: Int

Value: 1 Timeout (Seconds):60 ]

<enable us cellular>

A8: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data6

Input Type: Int

Value: 1 Timeout (Seconds):60 ]

<set data to fi phone provider>

A9: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Value: %multi_sim_voice_call Timeout (Seconds):60 ]

A10: Mobile Data [ Set:eek:ff ]

<stop ril-daemon>

A11: Run Shell [ Command:stop ril-daemon Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In: Store Result In: ]

<else fi selected>

A12: Else

<disable Fi (TMobile)>

A13: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data4

Input Type: Int

Value: 0 Timeout (Seconds):60 ]

<disable Sprint>

A14: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data5

Input Type: Int

Value: 0 Timeout (Seconds):60 ]

<disable us cellular>

A15: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data6

Input Type: Int

Value: 0 Timeout (Seconds):60 ]

<enable at&t>

A16: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: mobile_data8

Input Type: Int

Value: 1 Timeout (Seconds):60 ]

<set data to at&t>

A17: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Value: 8 Timeout (Seconds):60 ]

A18: Mobile Data [ Set:eek:ff ]

<stop ril-daemon>

A19: Run Shell [ Command:stop ril-daemon Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In: Store Result In: ]

A20: End If

A21: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]

<start ril-daemon>

A22: Run Shell [ Command:start ril-daemon Timeout (Seconds):0 Use Root:eek:n Store Output In: Store Errors In: Store Result In: ]

A23: Mobile Data [ Set:eek:n ]

A24: [X] AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Read Setting: true Timeout (Seconds):60 ]

A25: [X] Flash [ Text:Data: %multi_sim_data_call Voice: %multi_sim_voice_call Long:eek:ff ]

Hope this helps someone. You all have a great Christmas and New year!

I know this is old, but I was able to automate sim switching by disabling mobile data, then changing the multi_sim_data_call setting, then turning mobile data back on. In my case, my sim numbers are 4 and 8.

SIM Swap

A1: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Read Setting: true Timeout (Seconds):60 ]

A2: [X] Flash [ Text:%multi_sim_data_call Long:eek:ff ]

A3: Mobile Data [ Set:eek:ff ]

A4: If [ %multi_sim_data_call ~ 8 ]

A5: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Value: 4 Timeout (Seconds):60 ]

A6: Else

A7: AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Value: 8 Timeout (Seconds):60 ]

A8: End If

A9: Mobile Data [ Set:eek:n ]

A10: [X] AutoTools Secure Settings [ Configuration:Setting Type: Global

Name: multi_sim_data_call

Input Type: String

Read Setting: true Timeout (Seconds):60 ]

A11: [X] Flash [ Text:%multi_sim_data_call Long:eek:ff ]