]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/actions/upgrader.py
Move session IPC to dbus
[waydroid.git] / tools / actions / upgrader.py
index 2acf464fa918c6a754c688234be50cec71873574..21819717b8a09f16a3939a8d5599ab48d6adbd0d 100644 (file)
@@ -4,7 +4,7 @@ import logging
 import os
 from tools import helpers
 import tools.config
-
+import dbus
 
 def get_config(args):
     cfg = tools.config.load(args)
@@ -13,6 +13,7 @@ def get_config(args):
     args.vendor_type = cfg["waydroid"]["vendor_type"]
     args.system_ota = cfg["waydroid"]["system_ota"]
     args.vendor_ota = cfg["waydroid"]["vendor_ota"]
+    args.session = None
 
 def upgrade(args):
     get_config(args)
@@ -22,19 +23,22 @@ def upgrade(args):
     if status != "STOPPED":
         logging.info("Stopping container")
         helpers.lxc.stop(args)
+        try:
+            args.session = tools.helpers.ipc.DBusContainerService().GetSession()
+        except dbus.DBusException:
+            pass
     helpers.images.umount_rootfs(args)
     helpers.drivers.loadBinderNodes(args)
     if not args.offline:
-        preinstalled_images_path = tools.config.defaults["preinstalled_images_path"]
-        if args.images_path != preinstalled_images_path:
+        if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
         else:
-            logging.info("Upgrade refused because a pre-installed image is detected at {}.".format(preinstalled_images_path))
+            logging.info("Upgrade refused because a pre-installed image is detected at {}.".format(args.images_path))
     helpers.lxc.setup_host_perms(args)
     helpers.lxc.set_lxc_config(args)
     helpers.lxc.make_base_props(args)
-    if status != "STOPPED":
+    if status != "STOPPED" and args.session:
         logging.info("Starting container")
-        helpers.images.mount_rootfs(args, args.images_path)
+        helpers.images.mount_rootfs(args, args.images_path, args.session)
         helpers.protocol.set_aidl_version(args)
         helpers.lxc.start(args)