Skip to content

mm-iface-location: allow enabling without SIM

When the modem is in a failed state because of a SIM-related error, like a missing SIM, or if the modem is SIM-locked, allow the Location interface to initialize and be enabled anyway.

This allows someone without a SIM to the GPS, which does not particularly require a phone subscription. It also allows someone with a SIM to use the GPS even if the SIM is still locked.

Fixes #183 (closed)


I propose this fix that does not introduce too many changes in the hope it can be accepted more easily, and also because I'm quite new to this code base.

Now, I know having an enabling step in the initialization phase does not look great and adding such a special case is not ideal. However, I think the location interface is a special case, not needing the network at all. Architecturally, I could imagine the GPS being in its own device and not in the modem. The GPS being in the same chip as the modem seems accidental to me.

For this reason, it occurred to me that a cleaner solution could be to have the Location interface, or at least the GPS part, handled separately from the normal modem initialization / enabling step.

Another possible solution that had in mind while working on this is that we are in this perfectly correct state in which there is no SIM card but Location (and maybe other things?) can work, but that state is still called FAILED. It seems to me FAILED should only be reached when something really wrong happened (not having a SIM card is not something wrong that happened). Maybe we could have an extra state that reflects SIM "errors", in which parts of the modem are still allowed to be enabled (which calls for an extra enabling phase for these parts). This state would also be less scaring than FAILED when getting the state of the modem from e.g. mmcli, which would be more user friendly. However, I'm afraid changing this would break compatibility with a lot of stuff.

For all these reasons, I opted for an extra step that actually enables the Location interface in the initializing phase if there is a SIM-related error / in the FAILED(-because-of-SIM-a-error) state, and still kept the normal enabling step for location in the regular enabling phase that happens when there is no error.

I also removed the < ENABLED check for the modem state for Location operations, since:

  • now, the location interface can be working even if the modem is not ENABLED
  • they still check that the location is actually present

I guess this check might have been there to avoid displaying a wrong message "has no location capabilities" to the user when really it's a modem state issue, but the information is actually not there in the ENABLED state anymore. Again, a specific state ENABLED-in-a-limited-way would be neat, but then you would have to update every location in the code where ENABLED (or some other state) is used. Fundamentally, I believe the root issue here is that a mere enum cannot really represent the real state of the modem because it has several (at least two) (somewhat) independent component whose state don't need to be tied together and it's not entirely desirable to tie them because it causes issues like #183 (closed). I can see how it's still desirable to have a coarse representation of a global state though, but that seems to imply having local exceptions to this global representation. Which may be fine in the end. I didn't change the message displaying "this modem has no location capabilities", I don't expect it to be displayed in normal conditions on a modem that does have location, but we can change it too.

Anyway. I successfully tested this change (and could retrieve my GPS location using GeoClue and mmcli) on the PinePhone Pro under Mobian with the latest modem firmware from Biktorgj

  • without any SIM card
  • with a SIM card, but locked
  • with a SIM card, unlocked

I also tried and managed to send myself a SMS and access the internet from a 4G connection with this change. I haven't checked phone calls.

I have not tested this change on a modem that would require a phone subscription for the GPS. Does it exists though?

Edited by Raphaël Jakse

Merge request reports