]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
hardware-manager: Optionally stop the session on suspend
authorSebastian Krzyszkowiak <dos@dosowisko.net>
Fri, 30 Sep 2022 14:41:38 +0000 (16:41 +0200)
committerAlessandro Astone <ales.astone@gmail.com>
Fri, 11 Nov 2022 14:48:26 +0000 (15:48 +0100)
This allows to use persist.waydroid.suspend as a way to automatically
stop the session after an inactivity timeout, as opposed to merely
freezing the container. Freeze still remains the default action.

To use it this way, add to waydroid.cfg:

suspend_action = stop

tools/config/__init__.py
tools/services/hardware_manager.py

index e88998510054558d55912ace0629cbb3aed4f4e1..830dbb79f31936bcd750a1da228db5c3df55eca7 100644 (file)
@@ -20,7 +20,8 @@ config_keys = ["arch",
                "images_path",
                "vendor_type",
                "system_datetime",
-               "vendor_datetime"]
+               "vendor_datetime",
+               "suspend_action"]
 
 session_config_keys = ["user_name",
                        "user_id",
@@ -46,7 +47,8 @@ defaults = {
     "preinstalled_images_paths": [
         "/etc/waydroid-extra/images",
         "/usr/share/waydroid-extra/images",
-    ]
+    ],
+    "suspend_action": "freeze"
 }
 defaults["images_path"] = defaults["work"] + "/images"
 defaults["rootfs"] = defaults["work"] + "/rootfs"
index 45c51109a68e8fd17ba109098e716abfee7c7b4f..8d21dd04299e41bee979488a4dfb02d1e350adfb 100644 (file)
@@ -3,6 +3,8 @@
 import logging
 import threading
 import tools.actions.container_manager
+import tools.actions.session_manager
+import tools.config
 from tools import helpers
 from tools.interfaces import IHardware
 
@@ -16,7 +18,11 @@ def start(args):
         logging.debug("Function enableBluetooth not implemented")
 
     def suspend():
-        tools.actions.container_manager.freeze(args)
+        cfg = tools.config.load(args)
+        if cfg["waydroid"]["suspend_action"] == "stop":
+            tools.actions.session_manager.stop(args)
+        else:
+            tools.actions.container_manager.freeze(args)
 
     def reboot():
         helpers.lxc.stop(args)