actions.app_manager.showFullUI(args)
elif args.action == "status":
actions.status.print_status(args)
+ elif args.action == "adb":
+ if args.subaction == "connect":
+ helpers.net.adb_connect(args)
+ elif args.subaction == "disconnect":
+ helpers.net.adb_disconnect(args)
+ else:
+ logging.info("Run waydroid {} -h for usage information.".format(args.action))
elif args.action == "log":
if args.clear_log:
helpers.run.user(args, ["truncate", "-s", "0", args.log])
ret = subparser.add_parser("logcat", help="show android logcat")
return ret
+def arguments_adb(subparser):
+ ret = subparser.add_parser("adb", help="manage adb connection")
+ sub = ret.add_subparsers(title="subaction", dest="subaction")
+ sub.add_parser("connect", help="connect adb to the Android container")
+ sub.add_parser("disconnect", help="disconnect adb from the Android container")
+ return ret
+
def arguments():
parser = argparse.ArgumentParser(prog="waydroid")
arguments_firstLaunch(sub)
arguments_shell(sub)
arguments_logcat(sub)
+ arguments_adb(sub)
if argcomplete:
argcomplete.autocomplete(parser, always_complete_options="long")
"""
# 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"
logging.info("Android with user {} is ready".format(uid))
if cfg["waydroid"]["auto_adb"] == "True":
- tools.helpers.net.adb_connect(args)
+ try:
+ tools.helpers.net.adb_connect(args)
+ except:
+ pass
platformService = IPlatform.get_service(args)
if platformService: