]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/helpers/net.py
1 # Copyright 2023 Maximilian Wende
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 from shutil
import which
4 import tools
.helpers
.run
10 Creates an android debugging connection from the host system to the
11 Waydroid device, if ADB is found on the host system and the device
14 # Check if adb exists on the system.
18 # Start and 'warm up' the adb server
19 tools
.helpers
.run
.user(args
, ["adb", "start-server"])
21 ip
= get_device_ip_address()
25 tools
.helpers
.run
.user(args
, ["adb", "connect", ip
])
26 logging
.info("Established ADB connection to Waydroid device at {}.".format(ip
))
28 def get_device_ip_address():
29 # The IP address is queried from the DHCP lease file.
30 lease_file
= "/var/lib/misc/dnsmasq.waydroid0.leases"
33 with open(lease_file
) as f
:
34 return re
.search(r
"(\d{1,3}\.){3}\d{1,3}\s", f
.read()).group().strip()