From 7820952d3331309a78f2aab1f6a70e0b16ddb639 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 15 Oct 2022 13:34:04 +0200 Subject: [PATCH] Add serial interface hotplug support on Android --- sbapp/sideband/core.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 6504a97..f318852 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -1034,6 +1034,28 @@ class SidebandCore(): RNS.log("Updating RNode device to "+str(target_device)) self.interface_rnode.port = target_device["port"] + if self.interface_serial != None and not self.interface_serial.online: + self.owner_app.discover_usb_devices() + last_usb_discovery = time.time() + + if hasattr(self.owner_app, "usb_devices") and self.owner_app.usb_devices != None: + if len(self.owner_app.usb_devices) > 0: + target_device = self.owner_app.usb_devices[0] + if self.interface_serial.port != target_device["port"]: + RNS.log("Updating serial device to "+str(target_device)) + self.interface_serial.port = target_device["port"] + + if self.interface_modem != None and not self.interface_modem.online: + self.owner_app.discover_usb_devices() + last_usb_discovery = time.time() + + if hasattr(self.owner_app, "usb_devices") and self.owner_app.usb_devices != None: + if len(self.owner_app.usb_devices) > 0: + target_device = self.owner_app.usb_devices[0] + if self.interface_modem.port != target_device["port"]: + RNS.log("Updating modem device to "+str(target_device)) + self.interface_modem.port = target_device["port"] + def _periodic_jobs(self): if self.is_service or self.is_standalone: while True: