From 1b5480a5aeecf63b22509510f7365bbfcf55253c Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 12 Oct 2022 18:55:08 +0200 Subject: [PATCH] Added RNode hotplug support on Android --- sbapp/sideband/core.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 65ee159..41cdd0a 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -946,11 +946,25 @@ class SidebandCore(): def _service_jobs(self): if self.is_service: + last_usb_discovery = time.time() while True: time.sleep(SidebandCore.SERVICE_JOB_INTERVAL) + now = time.time() if self.getstate("wants.announce"): self.lxmf_announce() + if (now - last_usb_discovery > 5): + if self.interface_rnode != None and not self.interface_rnode.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_rnode.port != target_device["port"]: + RNS.log("Updating RNode device to "+str(target_device)) + self.interface_rnode.port = target_device["port"] + def _periodic_jobs(self): if self.is_service or self.is_standalone: while True: