SIM selection for mobile data is non-deterministic

Bug #1379412 reported by Tony Espy
36
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Incomplete
High
Unassigned
ofono (Ubuntu)
Confirmed
High
Unassigned
ubuntu-system-settings (Ubuntu)
Confirmed
High
Unassigned

Bug Description

Our current implementation of SIM selection for mobile data is currently ( as of RTM #94 ) non-deterministic.

If two SIMs are installed in the phone at first boot ofono will self-power the ConnectionManager interfaces for both modems which results in the 'Powered' property of both being set to 'true'. Only one of the two will attach to the network however, and if both SIMs are unlocked, this is usually the second slot.

Note, if the second SIM is locked, then the first SIM is used for mobile data.

The cellular system settings uses the 'Powered' property to choose which SIM is selected, so the current behavior is clearly broken.

<https://wiki.ubuntu.com/Networking#cellular-mobile>: "On a dual-SIM phone, “Cellular data:” should instead be radio options for “Off” and each SIM. After first setup and SIM unlock prompt (if any), this setting should be set by default to the only unlocked SIM if there is only one, otherwise the only 4G SIM if there is only one, otherwise the only 3G SIM if there is only one, otherwise the first SIM."

Tags: rtm14
Tony Espy (awe)
tags: added: rtm14
description: updated
Changed in ofono (Ubuntu):
status: New → Incomplete
Revision history for this message
Tony Espy (awe) wrote :

FYI, I've marked the ofono task as Incomplete, as it's only required if we decide to add the new page.

Changed in ofono (Ubuntu):
status: Incomplete → Confirmed
status: Confirmed → Incomplete
Changed in ubuntu-system-settings (Ubuntu):
importance: Undecided → High
Changed in ofono (Ubuntu):
importance: Undecided → High
Changed in ubuntu-system-settings (Ubuntu):
assignee: nobody → Olga Kemmet (olga-kemmet)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

In case we decide to proceed with this the ofono change is rather easy:

https://github.com/rilmodem/ofono/pull/128

Changed in ubuntu-system-settings (Ubuntu):
assignee: Olga Kemmet (olga-kemmet) → nobody
Changed in ubuntu-ux:
assignee: nobody → Olga Kemmet (olga-kemmet)
status: New → Triaged
importance: Undecided → High
Revision history for this message
Olga Kemmet (olga-kemmet) wrote :

What would be the issue with hard code the selection always to the first SIM? In the end, the majority of users don't want to be bothered with this. They want it simply to work. And we are will ask users to unlock the SIM during the OOBE.

Revision history for this message
Tony Espy (awe) wrote :

Thanks for the feedback Olga. This bug was entered prior to the wizard ( or even the boot ) auto-unlock prompt. If the user is now required to always enter SIM PINs before further usage, then this changes things a bit.

As the current ofono code will auto-power both modem ConnectionManager interfaces prior to the system settings panel ever running, we still may need to fix ofono's default behavior with respect to the 'Powered' property.

I will make sure to review this bug during tomorrow's network/telephony meeting.

Revision history for this message
Tony Espy (awe) wrote :

After some discussion internally this morning, if one or both of the SIM was PIN or PUK-locked, the wizard page would require the wizard to store a temporary settings, and then attempt to apply the setting after the user had entered the required PINs/PUKs.

A simple implementation would be to have ofono's rilmodem continue to default to 'Powered' == True on first run, and then quirk the logic for MTK dual-sim such that it prevents the second modem from being 'Powered'. Our current mtk dual-SIM implementation as similar logic to ensure for instance that only one of the modem's is 'Attached' for instance. It's possible that this 'Attached' code could prove unnecessary altogther...

Revision history for this message
Olga Kemmet (olga-kemmet) wrote :

@Tony Just to understand, if the solution you propose will be implemented and work we I can mark this bug as "Invalid" from Ubuntu-UX perspective?

Revision history for this message
Tony Espy (awe) wrote :

@Olga

Yes, if we implement this solution then the Ubuntu-UX bug can be marked Invalid. I'll follow up on this today and try and get a final answer.

Revision history for this message
Tony Espy (awe) wrote :

@Oga

After discussing with Alfonso, we decided that the current logic we have in place although not perfect, works OK. If two SIMs are installed, both ConnectionManager 'Powered' properties will be set to True, however only one of them ( the first SIM ) will attach to the GPRS network and hence be available for NM to start a connection on. If/when a user goes to system settings and changes the selected modem for data, it will straight things out leaving one modem powered, and one not powered.

I've marked all the tasks as Invalid. If anyone has objection to this, please feel free to re-open with an explanation of why.

Changed in ubuntu-ux:
status: Triaged → Invalid
Changed in ofono (Ubuntu):
status: Incomplete → Invalid
Changed in ubuntu-system-settings (Ubuntu):
status: New → Invalid
Revision history for this message
Olga Kemmet (olga-kemmet) wrote :

@Tony, thanks for the follow up and this is ok with me.

Revision history for this message
Tony Espy (awe) wrote :

A more recent follow-up due to bug #1409694 ( reported by QA ). My comment #8 is incorrect, the original description is more accurate. The selection of which SIM is used for mobile-data is non-deterministic. If two SIMs are installed, sometimes SIM1 is selected, and sometimes SIM2.

As by default SIM2 is not enabled for 3G, if the second SIM is selected, this leads to a very poor user experience.

Note, the suggestion in comment #3, while at first glance a good idea, would be very difficult to implement due to the current intricacies of the MTK device plugin. As such, the original suggestion is still the best idea ( ie. change ofono to not self-power the ConnectionManager interface ).

Changed in ubuntu-ux:
status: Invalid → Confirmed
Changed in ubuntu-system-settings (Ubuntu):
status: Invalid → Confirmed
Changed in ofono (Ubuntu):
status: Invalid → Confirmed
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

This report and bug 1404179 are examples of why "should" or "need" in a bug summary is a warning sign. :-) When a report assumes a particular solution, multiple possible solutions may be reported separately, fragmenting discussion. And if a particular solution is rejected, its bug report may be closed without solving the underlying problem.

The problem here is "SIM selection for mobile data is non-deterministic". When we make it deterministic, what rules should we follow to make the right choice most often? Here's a straw-man proposal:

(1) If exactly one SIM is locked, choose the other one (bug 1409694). Otherwise:

(2) If exactly one SIM is roaming, and "Auto switch to avoid roaming" (once implemented) is on, choose the other one. Otherwise:

(3) If one SIM has a 4G connection right now and the other doesn't, choose the one that does. Otherwise:

(4) If one SIM has a 3G connection right now and the other doesn't, choose the one that does. Otherwise:

(5) Choose the one that has strongest signal right now. (It doesn't matter so much if the other one becomes stronger later on.)

Even if these steps need a little tweaking, one obvious consequence is that the algorithm should re-run whenever the result is likely to have changed: whenever (a) you turn on the phone, (b) you lock/unlock a SIM, (c) you toggle "Auto switch to avoid roaming", (d) you change the data technology setting for any SIM, (e) you turn on cellular data or exit Flight Mode, or (f) whenever a SIM switches to a different carrier, e.g. as you drive into another country. The last one is the only non-interactive case, which may result in a surprising break in data connection for a few seconds, but that will be both infrequent and important.

The variety of conditions that need testing might also help you decide what piece of code to implement the solution in.

summary: - [wizard] Need Mobile Data SIM selection page
+ SIM selection for mobile data is non-deterministic
Changed in ubuntu-ux:
assignee: Olga Kemmet (olga-kemmet) → Matthew Paul Thomas (mpt)
status: Confirmed → In Progress
Revision history for this message
Tony Espy (awe) wrote :
Download full text (4.2 KiB)

While your point about using "need" and "should" in a bug report is valid for most instances, this bug was originally created based upon a consensus in one of our network/telephony meetings as the only viable way to solve the underlying non-deterministic selection problem. Perhaps it should've have been created as wishlist bug to better align with the bug summary.

The bug was closed because Alfonso and I made an incorrect assumption in comment #10 that the first SIM would be selected. I'm not quite sure how we came to that conclusion as it doesn't match the original bug description, but clearly there wasn't enough testing to back this up...

As for your straw-man proposal, I think while some of your logic makes sense, the overall proposal is too complicated, especially given the time period we have in which to address the bug before the final image is released for krillin.

Some additional points:

1. As we don't prompt for SIM PINs during the wizard, one or both SIMs could be locked. This could leave us with no SIM selected, unless we run the algorithm everytime a SIM is unlocked as you suggest.

2. I honestly don't think roaming should be involved. It's pretty rare for someone to buy a phone somewhere that results in the phone roaming and if they do, the possibility that they have one SIM that roams and one that doesn't is also pretty low. I see this as an edge case ( which certainly could be useful to advanced users ), and thus fine for requiring manual settings changes.

3. The device in question doesn't support 4G. This is essentially the same as you're fourth point though, choose the one with the best possible network capability. This is essentially what Olga proposed when she said "can't we always just pick SIM1"?

4. Choosing based on signal quality isn't a good idea in my mind, as you still may get better data throughput with a 3G connection with a lower signal quality than with a 2G connection with a higher signal quality. Also, if I buy a 3g capable phone, I want to use 3g. I would be disappointed if it selected 2g as a default for any reason other than lack of a SIM in the 3g slot.

5. I also disagree with re-running the algorithm blindly in all the conditions you list.

 - "power on/reboot": when the phone boots, I expect the settings to stay static, not magically change.

 - "lock/unlock SIM": I think the case where a user ignores auto-prompting for a SIM PIN will be rare ( unless it's not the owner ), so I don't really see much value in covering this case.

 - "auto-switch when roaming": this is a great idea, please file a wishlist bug for system-settings, and add an ofono task.

 - changing data technology for a SIM: indeed this is a valid case, but as you're on the settings page when this change is made, I would argue that the user can just change it then and there. On krillin/Android, if the user changes which SIM is capable of 3g, they're auto-prompted to see if they'd like to use this SIM for data. We should consider such an enhancement for a future update.

 - "turn on mobile data" - again the user does this from the cellular settings page. If they want to change which SIM is used for mobile data, they...

Read more...

Revision history for this message
Tony Espy (awe) wrote :

Also as an aside, I find it curious that we allow a user to use a phone if they don't know the SIM PIN ( via the X on the PIN prompt dialog ). Seems like a security hole to me.

Changed in canonical-devices-system-image:
importance: Undecided → High
milestone: none → ww05-2015
status: New → Confirmed
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Although the proposal in comment #11 has merit, in the end what the user wants is *predictability*, not that some rules that he does not know about might be lucky and do what he wants. There are myriad of reasons that might make those rules fail and do not do what the user wants.

What does someone expect when buying a new phone? IMHO:

* One SIM inserted -> The user wants to have data activated

* Two SIMs inserted -> The user wants to have data activated for one SIM, but probably not for the other (the "secondary" SIM tends to be used just for calls/SMS). The problem is that we do not have a clue on which SIM does he want to use for data, as the reasons tend to be "main operator vs operator for doing some calls SIM" or "work vs personal SIM". Besides, we know which is the main slot, but that is not obvious at all looking at the phone, so the user might have inserted what he considers the "main" SIM in any slot. In this case, I would say that the right option is to let data off for both SIMs until we have a wizard that lets him select the SIM for data on first boot. The user that has inserted two SIMs on the phone is probably knowledgeable enough to go to system settings and choose the SIM he wants for data.

To summarize my proposal:

One SIM -> Data on for that SIM
Two SIMs -> Data off for both

Revision history for this message
Tony Espy (awe) wrote :

Regarding comment #14, we discussed your proposal. and both Mathew and myself both agreed that defaulting to non-selected also seems wrong.

As you point out, someone that's inserted two SIMs into the phone is probably advanced enough to go to the settings and change the setting if they don't like the initial choice.

One last comment... it'd be helpful if someone could check to see what the behavior of Android is with respect to SIM selection for mobile data.

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Letting you use a phone without unlocking the SIM(s) is deliberate, on the grounds that it is still as useful as an iPod Touch. If people expect locking the SIM(s) to lock the phone as a whole, that would be a security problem, but as far as I know we don't have any evidence of that.

Alfonso torpedoes my re-run proposal by pointing out that if you have chosen a data SIM manually, you don't want that choice to change without permission. When I designed (2) "Auto switch to avoid roaming", I did not assume that people ever "buy a phone somewhere that results in the phone roaming", but rather that a common use case for dual SIM will be when you travel frequently between two countries, with one SIM native to each. If *that* isn't common, I could remove it from the design. Meanwhile, though, it implies that the data SIM selection won't automatically change otherwise; if it did that would be surprising.

Nevertheless, If adding a step to the first-run setup isn't acceptable (I agree it isn't), and defaulting to no data isn't acceptable, then we still need some method of choosing the data SIM automatically in the first place. We still (1) shouldn't choose one that is locked, and (4) shouldn't choose one on 2G if the other is on 3G.

"As we don't prompt for SIM PINs during the wizard, one or both SIMs could be locked. This could leave us with no SIM selected, unless we run the algorithm everytime a SIM is unlocked as you suggest."

If one or both SIMs are locked, on first run you get the setup, then the greeter, then the SIM unlock prompt(s), then the tutorial. <http://goo.gl/6Y7Hxb> If both are locked, the algorithm doesn't need to run after each unlock prompt, just after they have both finished.

Changed in canonical-devices-system-image:
milestone: ww05-2015 → ww07-2015
Changed in ubuntu-system-settings (Ubuntu RTM):
status: New → Confirmed
importance: Undecided → High
Changed in canonical-devices-system-image:
milestone: ww07-2015 → ww11-2015
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

I am assuming this is a settings oriented fix? Its still unclear

Changed in canonical-devices-system-image:
assignee: nobody → Bill Filler (bfiller)
milestone: ww11-2015 → ww13-2015
assignee: Bill Filler (bfiller) → nobody
Changed in ofono (Ubuntu):
assignee: nobody → Canonical Phone Foundations (canonical-phonedations-team)
Changed in canonical-devices-system-image:
assignee: nobody → Michael Frey (mfrey)
Changed in ubuntu-ux:
status: In Progress → Confirmed
Changed in ubuntu-ux:
status: Confirmed → Triaged
Revision history for this message
Tony Espy (awe) wrote :

@Pat

The suggestion from Alfonso was to fix this via a new page in the first boot wizard which would ask the user which SIM they'd prefer to use for mobile data. This would only be displayed if the phone detected more then one inserted SIM.

The general consensus from design was that this was less than ideal and that we should figure out how to do this automatically.

Alfonso and I discussed this today, and it's my belief that we could do this by checking to see which SIM was inserted in the 3g capable slot and only setting the ConnectionManager's 'Powered' attribute to True for this modem. This would require us extending the GPRS interface to allow the ofono core to query the 3g capability of the modem slot, which is a very MTK-specific capability. If we implemented this, we'd need to figure out how to make this more generic.

Note, bug #1413672 is related, and has a fix currently in-review.

Finally, the fix for this bug cannot be deployed as an OTA update, it would require a factory image update, as this bug only occurs during first boot *if* the user had installed two SIMs before-hand. It also potentially could occur if the user resets the phone, but this scenario hasn't been verified.

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

I am not clear on the plan to address this or not

Changed in canonical-devices-system-image:
assignee: Michael Frey (mfrey) → Canonical Phone Foundations (canonical-phonedations-team)
milestone: ww13-2015 → ww17-2015
Changed in canonical-devices-system-image:
milestone: ww17-2015 → ww21-2015
status: Confirmed → Incomplete
Changed in canonical-devices-system-image:
milestone: ww21-2015 → none
Changed in ubuntu-ux:
status: Triaged → In Progress
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Specification updated. <https://wiki.ubuntu.com/Networking?action=diff&rev2=289&rev1=288> Following Alfonso's and Tony's feedback, the rule no longer includes signal strength, roaming, or recalculating. It still does include locked/unlocked and 4G/3G/worse.

Changed in ubuntu-ux:
status: In Progress → Fix Committed
description: updated
Changed in canonical-devices-system-image:
assignee: Canonical Phone Foundations (canonical-phonedations-team) → John McAleely (john.mcaleely)
Changed in ofono (Ubuntu):
assignee: Canonical Phone Foundations (canonical-phonedations-team) → nobody
no longer affects: ubuntu-system-settings (Ubuntu RTM)
Changed in canonical-devices-system-image:
assignee: John McAleely (john.mcaleely) → nobody
no longer affects: ubuntu-ux
Revision history for this message
Joshua Carter (foliver4) wrote :

Addressing the challenge of non-deterministic SIM selection for mobile data in your Ubuntu-based system, especially when managing calls and SMS with ofono for your home automation and alarm system, necessitates a multifaceted approach. Firstly, ensuring that your ofono installation and the WIKO Riff 3 Plus phones' firmware are up to date is crucial, as updates may enhance SIM management capabilities. Since ofono's primary focus is on voice and SMS services, with less emphasis on data connectivity, you might need to delve into its configuration or leverage its DBus API for explicit SIM selection. This could involve custom scripting to enforce a specific SIM for data connectivity, tailored to your requirements. Alternatively, exploring other software solutions more attuned to dual-SIM management might be necessary, although it could mean significant adjustments to your current setup. Moreover, engaging with online communities or forums related to ofono, Ubuntu, or your specific hardware might unearth valuable insights or solutions from individuals who have encountered and resolved similar issues. This composite strategy aims to bring predictability to your SIM selection process,for example to choose a prefix number to get good data service https://whatnetworkphl.com/0955-what-network-philippines-is-tm-or-globe-sim-or-smart/ enhancing the reliability of your home automation and alarm system's communication capabilities.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.