On Fri, May 23, 2025 at 01:17:22PM +0200, Frédéric Danis wrote: > Hi Andrew, > > On 23/05/2025 12:33, Andrew Sayers wrote: > > > On Thu, May 22, 2025 at 04:55:22PM +0200, Frédéric Danis wrote: > > > Hi Andrew, > > > > > > On 30/04/2025 15:14, Andrew Sayers wrote: > > > > > > > Obexd is usually run as a user service, and can exhibit surprising > > > > behaviour if two users are logged in at the same time. > > > > > > > > Unregister profiles when the user is detected to be off-seat. > > > > > > > > It may be impossible to detect whether a user is on-seat in some cases. > > > > For example, a version of obexd compiled with systemd support might be > > > > run outside of a systemd environment. Warn and leave services > > > > registered if that happens. > > > > > > > > Obexd can be run as a system service, in which case this check makes no > > > > sense. Disable this check when called with `--system-bus`. > > > > > > > > Obexd can also be run by a user that does not have an active session. > > > > For example, someone could use `ssh` to access the system. There might > > > > be a use case where someone needs Bluetooth access but can't log in with > > > > a keyboard, or there might be a security issue with doing so. This isn't > > > > handled explicitly by this patch, but a future patch could add support > > > > by calling `logind_set(FALSE)` in the same way as is currently done > > > > with `--system-bus`. > > > > > > > > Unregister profiles by closing private connections instead of sending > > > > UnregisterProfile on the shared connection. Pipewire has apparently > > > > found the latter to cause long shutdown delays, because bluetoothd > > > > may be shutting down and unable to handle this message. > > > > > > > > Based in large part on the wireplumber code mentioned by Pauli Virtanen: > > > > https://gitlab.freedesktop.org/pipewire/wireplumber/-/blob/master/modules/module-logind.c#L52 > > > > > > > > Other services are likely to need similar functionality, > > > > so I have created a gist to demonstrate the basic technique: > > > > https://gist.github.com/andrew-sayers/1c4a24f86a9a4c1b1e38d109f1bd1d1e > > > > > > > > Suggested-by: Pauli Virtanen <pav@xxxxxx> > > > > Signed-off-by: Andrew Sayers <kernel.org@xxxxxxxxxxxxxxx> > > > I have a problem to connect PBAP profile using obexctl, using upstream > > > bluetoothd and obexd built on Ubuntu 24.04, the org.bluez.obex.PhonebookAccess1 > > > interface doesn't appear. > > > > > > After bisecting I found that this commit cause this issue. > > Hmm, my guess is that seat detection isn't working properly. > > Could you try this gist? You should get "Active: 1" when it starts, > > "Active: 0" when you switch away from your current screen, and "Active: 1" > > when you switch back. > > > > https://gist.github.com/andrew-sayers/1c4a24f86a9a4c1b1e38d109f1bd1d1e > > > It seems to work: > $ ./user-on-seat > Active: 1 > Active: 0 > Active: 1 > > But the problem occurred while I didn't try any "seat" change. Yeah, I was hoping you'd get e.g. 0 / 0 / 1 as output, suggesting it was inactive at first but changing seats worked around the problem. Sorry, but this means it'll be harder to debug. Can you... 1. Check whether PBAP is registered with bluetoothctl: bluetoothctl show | grep 0000112e-0000-1000-8000-00805f9b34fb You should see one line, like: UUID: Phonebook Access Client (0000112e-0000-1000-8000-00805f9b34fb) 2. Tail the bluetooth and obex logs in another terminal: sudo journalctl -f SYSLOG_IDENTIFIER=bluetoothd SYSLOG_IDENTIFIER=obexd Steps below will ask you to "make a note" in the log (e.g. append "about to do XYZ" to the file) - this will tell me which messages were triggered by which events. 3. Make a note in the log, then stop the obex service: systemctl --user stop obex.service 4. Check PBAP again: bluetoothctl show | grep 0000112e-0000-1000-8000-00805f9b34fb You should not see any output. 5. Make another note in the log, then start the obex service: systemctl --user start obex.service 6. Check PBAP again: bluetoothctl show | grep 0000112e-0000-1000-8000-00805f9b34fb You should see the same as in step 1. 8. Make a final note in the log, then try ctrl+alt+F{7,8}. 9. Send me the full log with notes, or at least anything that jumps out at you Note: the instructions above only print things that are likely to show problems, and unlikely to contain anything that can't go in an e-mail. You're welcome to do `sudo journalctl -f` and or `bluetoothctl show` in another terminal and go looking for trouble :) > I just started bluetoothd, obexd and obexctl, then tried to connect to my phone and got: > > connect 24:24:B7:11:82:6C pbap > Attempting to connect to 24:24:B7:11:82:6C > [NEW] Session /org/bluez/obex/client/session0 [default] > [24:24:B7:11:82:6C]# Connection successful > > While I'm expecting: > > connect 24:24:B7:11:82:6C pbap > Attempting to connect to 24:24:B7:11:82:6C > [NEW] Session /org/bluez/obex/client/session0 [default] > [24:24:B7:11:82:6C]# [NEW] PhonebookAccess /org/bluez/obex/client/session0 > [24:24:B7:11:82:6C]# Connection successful > > -- > Frédéric Danis > Senior Software Engineer > > Collabora Ltd. > Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, United Kingdom > Registered in England & Wales, no. 5513718 > >