]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/actions/initializer.py
debian: Use new polkitd package
[waydroid.git] / tools / actions / initializer.py
index 31b4fc90253ca720b6a0440b3e1b426540e049a0..8f6c2c3be1ccfde46c725a227240de2027f3fa67 100644 (file)
@@ -23,6 +23,8 @@ def get_vendor_type(args):
     ret = "MAINLINE"
     if vndk_str != "":
         vndk = int(vndk_str)
     ret = "MAINLINE"
     if vndk_str != "":
         vndk = int(vndk_str)
+        if vndk > 31:
+            vndk -= 1 # 12L -> Halium 12
         if vndk > 19:
             ret = "HALIUM_" + str(vndk - 19)
 
         if vndk > 19:
             ret = "HALIUM_" + str(vndk - 19)
 
@@ -57,6 +59,10 @@ def setup_config(args):
     if not args.system_type:
         args.system_type = channels_cfg["channels"]["system_type"]
 
     if not args.system_type:
         args.system_type = channels_cfg["channels"]["system_type"]
 
+    if not args.system_channel or not args.vendor_channel:
+        logging.error("ERROR: You must provide 'System OTA' and 'Vendor OTA' URLs.")
+        return False
+
     args.system_ota = args.system_channel + "/" + args.rom_type + \
         "/waydroid_" + args.arch + "/" + args.system_type + ".json"
     system_request = helpers.http.retrieve(args.system_ota)
     args.system_ota = args.system_channel + "/" + args.rom_type + \
         "/waydroid_" + args.arch + "/" + args.system_type + ".json"
     system_request = helpers.http.retrieve(args.system_ota)
@@ -99,6 +105,7 @@ def setup_config(args):
     cfg["waydroid"]["vndbinder"] = args.VNDBINDER_DRIVER
     cfg["waydroid"]["hwbinder"] = args.HWBINDER_DRIVER
     tools.config.save(args, cfg)
     cfg["waydroid"]["vndbinder"] = args.VNDBINDER_DRIVER
     cfg["waydroid"]["hwbinder"] = args.HWBINDER_DRIVER
     tools.config.save(args, cfg)
+    return True
 
 def init(args):
     if not is_initialized(args) or args.force:
 
 def init(args):
     if not is_initialized(args) or args.force:
@@ -107,16 +114,24 @@ def init(args):
             initializer_service = tools.helpers.ipc.DBusContainerService("/Initializer", "id.waydro.Initializer")
         except dbus.DBusException:
             pass
             initializer_service = tools.helpers.ipc.DBusContainerService("/Initializer", "id.waydro.Initializer")
         except dbus.DBusException:
             pass
-        setup_config(args)
+        if not setup_config(args):
+            return
         status = "STOPPED"
         if os.path.exists(tools.config.defaults["lxc"] + "/waydroid"):
             status = helpers.lxc.status(args)
         if status != "STOPPED":
             logging.info("Stopping container")
         status = "STOPPED"
         if os.path.exists(tools.config.defaults["lxc"] + "/waydroid"):
             status = helpers.lxc.status(args)
         if status != "STOPPED":
             logging.info("Stopping container")
-            helpers.lxc.stop(args)
-        helpers.images.umount_rootfs(args)
+            try:
+                container = tools.helpers.ipc.DBusContainerService()
+                args.session = container.GetSession()
+                container.Stop(False)
+            except Exception as e:
+                logging.debug(e)
+                tools.actions.container_manager.stop(args)
         if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
         if args.images_path not in tools.config.defaults["preinstalled_images_paths"]:
             helpers.images.get(args)
+        else:
+            helpers.images.remove_overlay(args)
         if not os.path.isdir(tools.config.defaults["rootfs"]):
             os.mkdir(tools.config.defaults["rootfs"])
         if not os.path.isdir(tools.config.defaults["overlay"]):
         if not os.path.isdir(tools.config.defaults["rootfs"]):
             os.mkdir(tools.config.defaults["rootfs"])
         if not os.path.isdir(tools.config.defaults["overlay"]):
@@ -126,13 +141,17 @@ def init(args):
             os.mkdir(tools.config.defaults["overlay_rw"])
             os.mkdir(tools.config.defaults["overlay_rw"]+"/system")
             os.mkdir(tools.config.defaults["overlay_rw"]+"/vendor")
             os.mkdir(tools.config.defaults["overlay_rw"])
             os.mkdir(tools.config.defaults["overlay_rw"]+"/system")
             os.mkdir(tools.config.defaults["overlay_rw"]+"/vendor")
+        helpers.drivers.probeAshmemDriver(args)
         helpers.lxc.setup_host_perms(args)
         helpers.lxc.set_lxc_config(args)
         helpers.lxc.make_base_props(args)
         if status != "STOPPED":
             logging.info("Starting container")
         helpers.lxc.setup_host_perms(args)
         helpers.lxc.set_lxc_config(args)
         helpers.lxc.make_base_props(args)
         if status != "STOPPED":
             logging.info("Starting container")
-            helpers.images.mount_rootfs(args, args.images_path)
-            helpers.lxc.start(args)
+            try:
+                container.Start(args.session)
+            except Exception as e:
+                logging.debug(e)
+                logging.error("Failed to restart container. Please do so manually.")
 
         if "running_init_in_service" not in args or not args.running_init_in_service:
             try:
 
         if "running_init_in_service" not in args or not args.running_init_in_service:
             try:
@@ -282,7 +301,7 @@ def remote_init_client(args):
             channels_cfg = tools.config.load_channels()
 
             self.set_default_size(600, 250)
             channels_cfg = tools.config.load_channels()
 
             self.set_default_size(600, 250)
-            self.set_icon_from_file(tools.config.tools_src + "/data/AppIcon.png")
+            self.set_icon_name("waydroid")
 
             grid = Gtk.Grid(row_spacing=6, column_spacing=6, margin=10, column_homogeneous=True)
             grid.set_hexpand(True)
 
             grid = Gtk.Grid(row_spacing=6, column_spacing=6, margin=10, column_homogeneous=True)
             grid.set_hexpand(True)