]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
session_manager: Stop the container on logout
authorAlessandro Astone <ales.astone@gmail.com>
Tue, 26 Aug 2025 13:48:34 +0000 (15:48 +0200)
committerAlessandro Astone <ales.astone@gmail.com>
Tue, 26 Aug 2025 13:58:25 +0000 (15:58 +0200)
On logout, the session dbus process is killed.

The default behaviour for libdbus is to exit(1) on bus disconnect, which would
leave the container running in the background with Android bootlooping while
trying to establish a Wayland connection again.

Intercept the disconnect signal and gracefully stop the container instead.

tools/actions/session_manager.py

index 51d9d4cb9fceb647dff2b6492ec7f8c64d7c3bc5..e128c9d0df7fe08bd257245bc27649540c025d18 100644 (file)
@@ -24,7 +24,16 @@ class DbusSessionManager(dbus.service.Object):
         do_stop(self.args, self.looper)
         stop_container(quit_session=False)
 
         do_stop(self.args, self.looper)
         stop_container(quit_session=False)
 
+def handle_disconnect(args, looper):
+    do_stop(args, looper)
+    stop_container(quit_session=False)
+
 def service(args, looper):
 def service(args, looper):
+    bus = dbus.SessionBus()
+    bus.set_exit_on_disconnect(False)
+    bus.add_signal_receiver(lambda: handle_disconnect(args, looper),
+                            signal_name='Disconnected',
+                            dbus_interface='org.freedesktop.DBus.Local')
     dbus_obj = DbusSessionManager(looper, dbus.SessionBus(), '/SessionManager', args)
     looper.run()
 
     dbus_obj = DbusSessionManager(looper, dbus.SessionBus(), '/SessionManager', args)
     looper.run()