]> glassweightruler.freedombox.rocks Git - waydroid.git/blobdiff - tools/helpers/net.py
debian/control: add Depends on pipewire-pulse | pulseaudio
[waydroid.git] / tools / helpers / net.py
index c20a95bc5566f2660fa30799147b62120cb76cd7..13723f3ebcc2f2b1eb7257e5e8273cde59ca3855 100644 (file)
@@ -13,24 +13,34 @@ def adb_connect(args):
     """
     # Check if adb exists on the system.
     if not which("adb"):
-        return
+        raise RuntimeError("Could not find adb")
 
     # Start and 'warm up' the adb server
     tools.helpers.run.user(args, ["adb", "start-server"])
 
     ip = get_device_ip_address()
     if not ip:
-        return
+        raise RuntimeError("Unknown container IP address. Is Waydroid running?")
 
     tools.helpers.run.user(args, ["adb", "connect", ip])
     logging.info("Established ADB connection to Waydroid device at {}.".format(ip))
 
+def adb_disconnect(args):
+    if not which("adb"):
+        raise RuntimeError("Could not find adb")
+
+    ip = get_device_ip_address()
+    if not ip:
+        raise RuntimeError("Unknown container IP address. Was Waydroid ever running?")
+
+    tools.helpers.run.user(args, ["adb", "disconnect", ip])
+
 def get_device_ip_address():
     # The IP address is queried from the DHCP lease file.
     lease_file = "/var/lib/misc/dnsmasq.waydroid0.leases"
 
     try:
         with open(lease_file) as f:
-            return re.search("(\d{1,3}\.){3}\d{1,3}\s", f.read()).group().strip()
+            return re.search(r"(\d{1,3}\.){3}\d{1,3}\s", f.read()).group().strip()
     except:
-        pass
\ No newline at end of file
+        pass