pythondbuspulseaudiohfp

ofono dbus Introspection: method not found


According to the documentation of ofono 1.17:

https://github.com/rilmodem/ofono/tree/master/doc

There are two interfaces for handsfree:

I need to access them in order to get pulseaudio working. It returns this error:

E: [pulseaudio] backend-ofono.c: Failed to register as a handsfree audio agent with ofono: org.freedesktop.DBus.Error.UnknownMethod: Method "Register" with signature "oay" on interface "org.ofono.HandsfreeAudioManager" doesn't exist

But that method exists (according to the docs above) and has that signature: object path, array{byte}.

Thus I guess it's not accessible rather than does not exist. I wrote a simple Python script to list the available services and org.ofono is there.

Then I added the code to list the objects:

def list_obj(bus, service, object_path):
    print(object_path)
    obj = bus.get_object(service, object_path)
    iface = dbus.Interface(obj, 'org.freedesktop.DBus.Introspectable')
    xml_string = iface.Introspect()
    for child in ElementTree.fromstring(xml_string):
        if child.tag == 'node':
            if object_path == '/':
                object_path = ''
            new_path = '/'.join((object_path, child.attrib['name']))
            list_obj(bus, service, new_path)

bus = dbus.SystemBus()
list_obj(bus, 'org.ofono.HandsfreeAudioManager', '/')

But I get the following errors:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.ofono.HandsfreeAudioManager': no such name

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.ofono.HandsfreeAudioManager was not provided by any .service files

I also checked the user policies for dbus, in /etc/dbus-1/system.d/ofono.conf:

<policy user="user">
  <allow own="org.ofono"/>
  <allow send_destination="org.ofono"/>
  <allow send_interface="org.ofono.SimToolkitAgent"/>
  <allow send_interface="org.ofono.PushNotificationAgent"/>
  <allow send_interface="org.ofono.SmartMessagingAgent"/>
  <allow send_interface="org.ofono.PositioningRequestAgent"/>
  <allow send_interface="org.ofono.HandsfreeAudioManager"/>
  <allow send_interface="org.ofono.Handsfree"/>   
</policy>

<policy at_console="true">
 <allow send_destination="org.ofono"/>   
</policy>

<policy context="default">
  <deny send_destination="org.ofono"/>   
</policy>

Of course I run ofono and the code above as user "user". I'm running out of ideas... what should I do further to fix the problem?


Solution

  • list_obj

    https://github.com/rilmodem/ofono/blob/master/doc/handsfree-audio-api.txt describes the following interface:

    Service     org.ofono
    Interface   org.ofono.HandsfreeAudioManager
    Object path /
    

    and https://github.com/rilmodem/ofono/blob/master/doc/handsfree-api.txt describes this one:

    Service     org.ofono
    Interface   org.ofono.Handsfree
    Object path [variable prefix]/{modem0,modem1,...}
    

    This means that the service argument to the bus.get_object method has to be "org.ofono", and the object_path argument has to be / (for HandsfreeAudioManager) or [variable prefix]/{modem0,modem1,...} (for Handsfree).

    Therefore, you should use obj(bus, 'org.ofono', '/').

    Register

    I'm guessing that it's possible that your org.ofono / object does not implement the org.ofono.HandsfreeAudioManager interface, or Register's signature is different than the one described in the docs.

    You may want to try pydbus - https://github.com/LEW21/pydbus instead of the deprecated python-dbus bindings. It supports using Python's built-in help() function on the proxy objects, so that you'll be able to easily see all the supported interfaces, and the signatures of all their methods:

    from pydbus import SystemBus
    bus = SystemBus()
    ofono = bus.get("org.ofono", "/")
    help(ofono)
    

    The returned ofono object exposes all the implemented interfaces at once, so it might be confusing if the object implements lots of interfaces. In that case, you can get a proxy object supporting only a single interface (like with python-dbus's dbus.Interface):

    manager = ofono["org.ofono.HandsfreeAudioManager"]
    help(manager)
    

    However, unlike dbus.Interface (which fails silently), it'll throw a KeyError if the object does not implement this interface.

    (Disclaimer: I'm the autor of pydbus)