Bug 85305

Summary: Accuracy not changed when inserting GSM/3G modem
Product: GeoClue Reporter: Laurent Bigonville <bigon>
Component: GeneralAssignee: Geoclue Bugs <geoclue-bugs>
Status: RESOLVED FIXED QA Contact: Geoclue Bugs <geoclue-bugs>
Severity: normal    
Priority: medium CC: aleksander, zeenix
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: modem-manager: Don't enable the modem
modem-manager: Wait for modem to be enabled

Description Laurent Bigonville 2014-10-21 21:58:54 UTC
Hi,

If I'm inserting a 3G USB modem while geoclue is already running, geoclue is detecting the modem (even before the pin is introduced) but the accuracy is never updated (stays to 0):

(geoclue:1572): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/2'

(and nothing else)

On the other hand, if the modem is present when before geoclue is started, the accuracy is properly set (and the modem is used). If the modem is unpluged, geoclue set it back to 0:

(geoclue:1572): Geoclue-DEBUG: Available accuracy level from GClueWifi: 4
(geoclue:1572): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/3'
(geoclue:1572): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/3' has location capabilities
(geoclue:1572): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
(geoclue:1572): Geoclue-DEBUG: New agent for user ID '1000'
(geoclue:1572): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/3' removed.
(geoclue:1572): Geoclue-DEBUG: Available accuracy level from GClue3G: 0
Comment 1 Laurent Bigonville 2014-10-21 21:59:23 UTC
geoclue 2.1.10
Comment 2 Zeeshan Ali 2015-03-03 16:18:38 UTC
Weird, works fine here:

(geoclue:10599): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/0'
(geoclue:10599): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
(geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
(geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClueModemGPS: 8

Which modem is this?
Comment 3 Bastien Nocera 2015-03-03 18:01:31 UTC
(In reply to Zeeshan Ali from comment #2)
> Weird, works fine here:
> 
> (geoclue:10599): Geoclue-DEBUG: New modem
> '/org/freedesktop/ModemManager1/Modem/0'
> (geoclue:10599): Geoclue-DEBUG: Modem
> '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
> (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
> (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClueModemGPS:
> 8
> 
> Which modem is this?

Either 1) that modem doesn't have location capabilities (which probably should be logged in the debug output), or 2) it fails to respond because the SIM is locked (?).
Comment 4 Zeeshan Ali 2015-03-03 18:22:01 UTC
(In reply to Bastien Nocera from comment #3)
> (In reply to Zeeshan Ali from comment #2)
> > Weird, works fine here:
> > 
> > (geoclue:10599): Geoclue-DEBUG: New modem
> > '/org/freedesktop/ModemManager1/Modem/0'
> > (geoclue:10599): Geoclue-DEBUG: Modem
> > '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
> > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
> > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClueModemGPS:
> > 8
> > 
> > Which modem is this?
> 
> Either 1) that modem doesn't have location capabilities (which probably
> should be logged in the debug output), or 2) it fails to respond because the
> SIM is locked (?).

I'd be surprised if either is true since Laurent says that everything works fine if he starts geoclue after inserting the modem.
Comment 5 Bastien Nocera 2015-03-03 18:23:18 UTC
(In reply to Zeeshan Ali from comment #4)
> (In reply to Bastien Nocera from comment #3)
> > (In reply to Zeeshan Ali from comment #2)
> > > Weird, works fine here:
> > > 
> > > (geoclue:10599): Geoclue-DEBUG: New modem
> > > '/org/freedesktop/ModemManager1/Modem/0'
> > > (geoclue:10599): Geoclue-DEBUG: Modem
> > > '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
> > > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
> > > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClueModemGPS:
> > > 8
> > > 
> > > Which modem is this?
> > 
> > Either 1) that modem doesn't have location capabilities (which probably
> > should be logged in the debug output), or 2) it fails to respond because the
> > SIM is locked (?).
> 
> I'd be surprised if either is true since Laurent says that everything works
> fine if he starts geoclue after inserting the modem.

"Inserting the modem", or "inserting the modem and unlocking the SIM card"?
Comment 6 Zeeshan Ali 2015-03-03 18:33:32 UTC
(In reply to Bastien Nocera from comment #5)
> (In reply to Zeeshan Ali from comment #4)
> > (In reply to Bastien Nocera from comment #3)
> > > (In reply to Zeeshan Ali from comment #2)
> > > > Weird, works fine here:
> > > > 
> > > > (geoclue:10599): Geoclue-DEBUG: New modem
> > > > '/org/freedesktop/ModemManager1/Modem/0'
> > > > (geoclue:10599): Geoclue-DEBUG: Modem
> > > > '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
> > > > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
> > > > (geoclue:10599): Geoclue-DEBUG: Available accuracy level from GClueModemGPS:
> > > > 8
> > > > 
> > > > Which modem is this?
> > > 
> > > Either 1) that modem doesn't have location capabilities (which probably
> > > should be logged in the debug output), or 2) it fails to respond because the
> > > SIM is locked (?).
> > 
> > I'd be surprised if either is true since Laurent says that everything works
> > fine if he starts geoclue after inserting the modem.
> 
> "Inserting the modem", or "inserting the modem and unlocking the SIM card"?

I guess only Laurent can answer that.
Comment 7 Laurent Bigonville 2015-03-07 11:03:12 UTC
Hello,

According to lsusb, the modem is:
Bus 007 Device 011: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem

When I was talking about inserting the modem, it was inserting + SIM unlocking.

Note that in the following scenario I'm using a simcard that is not in service anymore because I'm current active one has not the proper form factor for the modem...

Case 1:

0) Modem unplugged
1) Start Modemmanager
2) Insert the USB modem
3) Modemmanager asks for PIN, I enter PIN
4) Modemmanager: "state changed (enabling -> enabled)" and displays signal strength
5) Start geoclue-2.0:

$ G_MESSAGES_DEBUG=all /usr/lib/geoclue-2.0/geoclue 
(geoclue:30013): Geoclue-DEBUG: Available accuracy level from GClueWifi: 4
(geoclue:30013): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/0'
(geoclue:30013): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/0' has location capabilities
(geoclue:30013): Geoclue-DEBUG: Available accuracy level from GClue3G: 5
(geoclue:30013): Geoclue-DEBUG: New agent for user ID '1000'

6) Run where-am-i demo:

(geoclue:30013): Geoclue-DEBUG: Number of connected clients: 1
(geoclue:30013): Geoclue-DEBUG: 'geoclue-where-am-i' not in configuration
(geoclue:30013): Geoclue-DEBUG: requested accuracy level: 8. Accuracy level allowed by agent: 8
(geoclue:30013): Geoclue-DEBUG: GClueLocator now active
(geoclue:30013): Geoclue-DEBUG: GClue3G now active
(geoclue:30013): Geoclue-DEBUG: Not starting GClueCDMA (accuracy level: 0). Requested accuracy level: 8.
(geoclue:30013): Geoclue-DEBUG: GClueWifi now active
(geoclue:30013): Geoclue-DEBUG: Not starting GClueModemGPS (accuracy level: 0). Requested accuracy level: 8.
(geoclue:30013): Geoclue-DEBUG: 'geoclue-where-am-i' started.
(geoclue:30013): Geoclue-DEBUG: manager '/org/freedesktop/ModemManager1/Modem/0' enabled.
(geoclue:30013): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/0' setup.
(geoclue:30013): Geoclue-DEBUG: No 3GPP
(geoclue:30013): Geoclue-DEBUG: Network available

7) where-am-i displays a location

(geoclue:30013): Geoclue-WARNING **: Failed to create query: 3GPP cell tower info unavailable
(geoclue:30013): Geoclue-DEBUG: Network available
(geoclue:30013): Geoclue-DEBUG: Sending following request to 'https://location.services.mozilla.com/v1/geolocate?key=geoclue':
{}
(geoclue:30013): Geoclue-DEBUG: Got following response from 'https://location.services.mozilla.com/v1/geolocate?key=geoclue':
{"location": {"lat": 50.8333, "lng": 4.3333}, "accuracy": 50000.0}
(geoclue:30013): Geoclue-DEBUG: New location available

8) Now I'm unplugging the USB modem

(geoclue:30013): Geoclue-DEBUG: Modem '/org/freedesktop/ModemManager1/Modem/0' removed.
(geoclue:30013): Geoclue-DEBUG: Available accuracy level from GClue3G: 0

9) Repluging the modem after a few sec
10) modemmanager asks for PIN
11) geoclue displays: "(geoclue:30013): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/1'"
12) I'm running the where-am-i demo again:

(geoclue:30013): Geoclue-DEBUG: Number of connected clients: 1
(geoclue:30013): Geoclue-DEBUG: 'geoclue-where-am-i' not in configuration
(geoclue:30013): Geoclue-DEBUG: requested accuracy level: 8. Accuracy level allowed by agent: 8
(geoclue:30013): Geoclue-DEBUG: GClueLocator now active
(geoclue:30013): Geoclue-DEBUG: Not starting GClue3G (accuracy level: 0). Requested accuracy level: 8.
(geoclue:30013): Geoclue-DEBUG: Not starting GClueCDMA (accuracy level: 0). Requested accuracy level: 8.
(geoclue:30013): Geoclue-DEBUG: GClueWifi now active
(geoclue:30013): Geoclue-DEBUG: Not starting GClueModemGPS (accuracy level: 0). Requested accuracy level: 8.
(geoclue:30013): Geoclue-DEBUG: 'geoclue-where-am-i' started.

13) where-am-i demo returns no location:

(geoclue:30013): Geoclue-DEBUG: GClueLocator now inactive
(geoclue:30013): Geoclue-DEBUG: GClueWifi now inactive
(geoclue:30013): Geoclue-DEBUG: Requested GClueWifi to stop
(geoclue:30013): Geoclue-DEBUG: Number of connected clients: 0
Comment 8 Zeeshan Ali 2015-03-07 20:35:21 UTC
(In reply to Laurent Bigonville from comment #7)

Thanks for providing so many details! I have one question:

> 9) Repluging the modem after a few sec
> 10) modemmanager asks for PIN

Does this imply that you provide the pin?
Comment 9 Laurent Bigonville 2015-03-08 00:27:47 UTC
(In reply to Zeeshan Ali from comment #8)
> (In reply to Laurent Bigonville from comment #7)
> 
> Thanks for providing so many details! I have one question:
> 
> > 9) Repluging the modem after a few sec
> > 10) modemmanager asks for PIN
> 
> Does this imply that you provide the pin?

Yes. And to be complete:

- (geoclue:8789): Geoclue-DEBUG: New modem '/org/freedesktop/ModemManager1/Modem/1' appears before I even enter the PIN

- I can confirm that ModemManager displays "state changed (enabling -> enabled)"

I could try with another SIM card (provider) which is active, but I'm hit by bug #89482 (In that bug you have the full debug log of ModemManager is you want)
Comment 10 Zeeshan Ali 2015-03-08 15:11:48 UTC
(In reply to Laurent Bigonville from comment #9)
> (In reply to Zeeshan Ali from comment #8)
> > (In reply to Laurent Bigonville from comment #7)
> > 
> > Thanks for providing so many details! I have one question:
> > 
> > > 9) Repluging the modem after a few sec
> > > 10) modemmanager asks for PIN
> > 
> > Does this imply that you provide the pin?
> 
> Yes. And to be complete:
> 
> - (geoclue:8789): Geoclue-DEBUG: New modem
> '/org/freedesktop/ModemManager1/Modem/1' appears before I even enter the PIN
> 
> - I can confirm that ModemManager displays "state changed (enabling ->
> enabled)"

Ok, thanks. I think I now have all the needed info to try to fix this bug. I hope ModemManager already has the API for geoclue to detect and wait for modem to be enabled.
Comment 11 Aleksander Morgado 2015-03-28 18:15:04 UTC
(In reply to Zeeshan Ali from comment #10)
> (In reply to Laurent Bigonville from comment #9)
> > (In reply to Zeeshan Ali from comment #8)
> > > (In reply to Laurent Bigonville from comment #7)
> > > 
> > > Thanks for providing so many details! I have one question:
> > > 
> > > > 9) Repluging the modem after a few sec
> > > > 10) modemmanager asks for PIN
> > > 
> > > Does this imply that you provide the pin?
> > 
> > Yes. And to be complete:
> > 
> > - (geoclue:8789): Geoclue-DEBUG: New modem
> > '/org/freedesktop/ModemManager1/Modem/1' appears before I even enter the PIN
> > 
> > - I can confirm that ModemManager displays "state changed (enabling ->
> > enabled)"
> 
> Ok, thanks. I think I now have all the needed info to try to fix this bug. I
> hope ModemManager already has the API for geoclue to detect and wait for
> modem to be enabled.

You can either watch the StateChanged signal, waiting for a state >= Enabled:
http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-signal-org-freedesktop-ModemManager1-Modem.StateChanged

Or otherwise, if you're not interested in the old state, you can just follow changes in the "State" property:
http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-property-org-freedesktop-ModemManager1-Modem.State

The location capabilities will only be reported by ModemManager once the Location interface has been exposed. If you're interested just in checking the capabilities, you can also just monitor for the presence of the Location interface. If you just want to check for the existence of that interface one, then you should do it when the Enabled state (or >) is reached; if at that point there is no Location interface, there are no location capabilities.
Comment 12 Aleksander Morgado 2015-03-28 18:16:02 UTC
> If you just want to check for the existence of that interface one
*once
Comment 13 Zeeshan Ali 2015-04-02 10:52:17 UTC
(In reply to Aleksander Morgado from comment #11)
> (In reply to Zeeshan Ali from comment #10)
> > (In reply to Laurent Bigonville from comment #9)
> > > (In reply to Zeeshan Ali from comment #8)
> > > > (In reply to Laurent Bigonville from comment #7)
> > > > 
> > > > Thanks for providing so many details! I have one question:
> > > > 
> > > > > 9) Repluging the modem after a few sec
> > > > > 10) modemmanager asks for PIN
> > > > 
> > > > Does this imply that you provide the pin?
> > > 
> > > Yes. And to be complete:
> > > 
> > > - (geoclue:8789): Geoclue-DEBUG: New modem
> > > '/org/freedesktop/ModemManager1/Modem/1' appears before I even enter the PIN
> > > 
> > > - I can confirm that ModemManager displays "state changed (enabling ->
> > > enabled)"
> > 
> > Ok, thanks. I think I now have all the needed info to try to fix this bug. I
> > hope ModemManager already has the API for geoclue to detect and wait for
> > modem to be enabled.
> 
> You can either watch the StateChanged signal, waiting for a state >= Enabled:
> http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.
> freedesktop.ModemManager1.Modem.html#gdbus-signal-org-freedesktop-
> ModemManager1-Modem.StateChanged
> 
> Or otherwise, if you're not interested in the old state, you can just follow
> changes in the "State" property:
> http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.
> freedesktop.ModemManager1.Modem.html#gdbus-property-org-freedesktop-
> ModemManager1-Modem.State
> 
> The location capabilities will only be reported by ModemManager once the
> Location interface has been exposed. If you're interested just in checking
> the capabilities, you can also just monitor for the presence of the Location
> interface. If you just want to check for the existence of that interface
> one, then you should do it when the Enabled state (or >) is reached; if at
> that point there is no Location interface, there are no location
> capabilities.

I implemented this yesterday and ended up breaking geoclue even more. (As we discussed on IM) The issue is that geoclue has to enable the modem itself (due to bug#730131) and it only does that when location interface is actually needed. This combined with the fact that geoclue is only interested in one modem (it currently picks up the first one it finds location caps on) makes solving this bug a bit difficult.
Comment 14 Zeeshan Ali 2015-04-02 17:42:53 UTC
(In reply to Zeeshan Ali from comment #13)
>
> I implemented this yesterday and ended up breaking geoclue even more. (As we
> discussed on IM) The issue is that geoclue has to enable the modem itself
> (due to bug#730131)

I quoted a GNOME bug. :) The bug was moved to fdo as bug#85040.
Comment 15 Zeeshan Ali 2015-04-08 15:13:21 UTC
Created attachment 114961 [details] [review]
modem-manager: Don't enable the modem

Seems at least GNOME takes care of modem enabling for us and besides
this shouldn't be done by geoclue anyway (see bug#85040).
Comment 16 Zeeshan Ali 2015-04-08 15:13:25 UTC
Created attachment 114962 [details] [review]
modem-manager: Wait for modem to be enabled

Modem's location capabilities won't be known until its enabled.
Comment 17 Zeeshan Ali 2015-04-09 15:56:07 UTC
Attachment 114961 [details] pushed as fe79da7 - modem-manager: Don't enable the modem
Attachment 114962 [details] pushed as 9206839 - modem-manager: Wait for modem to be enabled

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.