Bug 445376

Summary: The state of the Bluetooth adapter is not restored after logout/login
Product: [Applications] systemsettings Reporter: popov895 <popov895>
Component: kcm_bluetoothAssignee: David Rosca <nowrep>
Status: RESOLVED FIXED    
Severity: normal CC: nate, plasma-bugs, popov895
Priority: NOR    
Version: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=440493
Latest Commit: Version Fixed In: 5.23.5
Attachments: Patch

Description popov895 2021-11-12 13:47:14 UTC
SUMMARY

If "Remember previous status" option is checked, the state of the Bluetooth adapter is not restored after logout/login. Most likely, the problem is that saveState () is only called on shutdown and sleep, but not on logout.

STEPS TO REPRODUCE

1. Open Bluetooth settings (System Settings > Bluetooth > Settings)
2. Select "Remember previous status" option
3. Disable Bluetooth adapter
4. Logout and login

OBSERVED RESULT

Bluetooth adapter in enabled.

EXPECTED RESULT

Bluetooth adapter in disabled.

SOFTWARE/OS VERSIONS

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.88.0
Qt Version: 5.15.3
Graphics Platform: X11
Comment 1 Nate Graham 2021-11-12 15:08:08 UTC
Confirmed. The problem is that saveState() is only called on shutdown and sleep, but not on logout. We accomplish this by connecting to the "PrepareForShutdown" and "PrepareForSleep" methods, but there's nothing about logout that I can see. Still investigating.
Comment 2 Bug Janitor Service 2021-11-20 02:43:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/bluedevil/-/merge_requests/54
Comment 3 Nate Graham 2021-12-03 16:31:24 UTC
Git commit e57bb7580251f38e798bea21cdad43a3f90f2568 by Nate Graham.
Committed on 03/12/2021 at 16:23.
Pushed by ngraham into branch 'master'.

Save bluetooth status on teardown

Instead of watching for the shutdown and restart signals, just save
status anytime kded quits, which automatically covers those use cases as
well as when logging out. This is what the code was already halfway
doing; let's go all the way.
FIXED-IN: 5.23.5

M  +3    -26   src/kded/devicemonitor.cpp
M  +0    -1    src/kded/devicemonitor.h

https://invent.kde.org/plasma/bluedevil/commit/e57bb7580251f38e798bea21cdad43a3f90f2568
Comment 4 Nate Graham 2021-12-03 16:32:40 UTC
Git commit daaa18920ae93b482585eb3df790a6d5a647b6db by Nate Graham.
Committed on 03/12/2021 at 16:32.
Pushed by ngraham into branch 'Plasma/5.23'.

Save bluetooth status on teardown

Instead of watching for the shutdown and restart signals, just save
status anytime kded quits, which automatically covers those use cases as
well as when logging out. This is what the code was already halfway
doing; let's go all the way.
FIXED-IN: 5.23.5
(cherry picked from commit e57bb7580251f38e798bea21cdad43a3f90f2568)

M  +3    -26   src/kded/devicemonitor.cpp
M  +0    -1    src/kded/devicemonitor.h

https://invent.kde.org/plasma/bluedevil/commit/daaa18920ae93b482585eb3df790a6d5a647b6db
Comment 5 popov895 2022-01-04 12:36:50 UTC
Just checked and it's still not fixed. The ~/.config/bluedevilglobalrc file is still empty.

SOFTWARE/OS VERSIONS

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.3
Graphics Platform: X11
Comment 6 Nate Graham 2022-01-04 15:51:53 UTC
Well I don't know then. :(
Comment 7 popov895 2022-01-04 18:26:16 UTC
Does it work for you?
Comment 8 Nate Graham 2022-01-04 18:35:41 UTC
Yes.
Comment 9 popov895 2022-01-05 12:32:25 UTC
In my case, the destructor of the BlueDevilDaemon is not called, so the saveState is not called either. Does BlueDevil get killed on logout?
Comment 10 Nate Graham 2022-01-05 19:56:09 UTC
Yes, sometimes that can happen. I see this with other apps too; they act like they killed or were crashed when logging out. I would suggest that the code here is working, but there is an issue in Plasma or ksmserver. Can you file a new bug report for that?
Comment 11 popov895 2022-01-06 15:42:20 UTC
Created attachment 145164 [details]
Patch

What about something like this?

> Can you file a new bug report for that?

I think you describe this issue better.
Comment 12 Nate Graham 2022-01-06 16:01:46 UTC
Sure, go ahead and submit that patch and let's see what comes out of it. I can see the value because it can be desirable to save incrementally so we don't lose state when there's a crash.
Comment 13 popov895 2022-01-09 11:24:24 UTC
I found that it works well if I manually kill the plasma_session process. Also, I have [startplasma-x11: Could not fully finish the process "/usr/bin/plasma_session"] message in the journalctl on logout. Is this all somehow related?
Comment 14 Nate Graham 2022-01-10 16:27:59 UTC
That does seem related, yeah.

A