How to use location-observe interface?

Hi, One of my application uses geoclue 2.0 Library to get location data of user. I thought location-observe would be the interface i should use to allow geoclue get the location related data from system, but this seems to fail. When I tried to connect location-observe to core it refused to connect with the following error:

$ snap connect whatsie:location-observe
error: snap "core" has no "location-observe" interface slots

My questions:

  • If core has no location-observe interface, how and where this interface is used ?
  • What interface allows developers packaging their applications that uses geoclue library at runtime ?
    The apparmor denials can help, below is the denial error i got in terminal while initializing the library.

qt.positioning.geoclue2: Unable to obtain the client patch: "org.freedesktop.DBus.Error.AccessDeniedAn AppArmor policy prevents this sender from sending this message to this recipient; type=\"method_call\", sender=\":1.991\" (uid=1000 pid=21846 comm=\"whatsie \") interface=\"org.freedesktop.GeoClue2.Manager\" member=\"GetClient\" error name=\"(unset)\" requested_reply=\"0\" destination=\"org.freedesktop.GeoClue2\" (uid=127 pid=22162 comm=\"/usr/lib/geoclue-2.0/geoclue -t 5 \")" serialnmea: No serial ports found

1 Like

This might be a bug. The current definition is that only an app snap may provide the location-observe slot, which means that as it stands the core/snapd snaps are not allowed to supply the functionality. It might be a simple oversight, and the definition in snapd should be changed to:

const locationObserveBaseDeclarationSlots = `
        - app
        - core
    deny-connection: true
    deny-auto-connection: true

(This will require that snapd is rebuilt, so is not something you can fix yourself)

1 Like

The interface definition is correct, nothing in core can provide locations currently, you will need a snap providing a location through i.e. gpsd … there used to be a “locationd” snap (a leftover from the ubuntu phone) that has been put to rest though …


So there is currently no simple way for a snap app to act as a client to location services?

not unless you package some server that provides them to the client.

not unless you package some server that provides them to the client.

My app was using Qt Positioning module to get location information which uses Geoclue as backend.

According to Geoclue wiki:

Geoclue is a D-Bus service that provides location information.
The aim of project is to utilize all possible sources of geolocation to best find user’s location:

  • WiFi-based geolocation (accuracy: in meters)
  • GPS(A) receivers (accuracy: in centimeters)
  • GPS of other devices on the local network, e.g smartphones (accuracy: in centimeters)
  • 3G modems (accuracy: in kilometers, unless modem has GPS)
  • GeoIP (accuracy: city-level)

I don’t know where in this case I need to package a server ?

Could one open a portal to GeoClue like FlatPak does? We just need a way to allow dbus communication to the specific service.

1 Like

I think we’re talking about accessing geoclue from the classic host, via the core/snapd snap, not on an Ubuntu Core device - we need to allow the Dbus access through the confinement via the location-observe interface, but we cannot on a classic system because we’re not allowed to connect the interface without a third-party snap that slots the location-observe interface. Think of the access similar to how we allow Alsa access through the core/snapd snap on a classic host without requiring an alsa-slotting third-party snap.