From ceeec1fd41063ca97e33c6e2de0a34bd7b821a37 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 15 Oct 2023 01:10:10 +0200 Subject: [PATCH] Added USB device filter --- sbapp/buildozer.spec | 2 +- sbapp/services/sidebandservice.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sbapp/buildozer.spec b/sbapp/buildozer.spec index a9ef6ac..2a30ff2 100644 --- a/sbapp/buildozer.spec +++ b/sbapp/buildozer.spec @@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements, version.regex = __version__ = ['"](.*)['"] version.filename = %(source.dir)s/main.py -android.numeric_version = 20231007 +android.numeric_version = 20231015 # Cryptography recipe is currently broken, using RNS-internal crypto for now requirements = kivy==2.2.1,libbz2,pillow,qrcode==7.3.1,usb4a,usbserial4a diff --git a/sbapp/services/sidebandservice.py b/sbapp/services/sidebandservice.py index 6bacded..92ccddc 100644 --- a/sbapp/services/sidebandservice.py +++ b/sbapp/services/sidebandservice.py @@ -37,6 +37,14 @@ else: from sbapp.sideband.core import SidebandCore class SidebandService(): + usb_device_filter = { + 0x0403: [0x6001, 0x6010, 0x6011, 0x6014, 0x6015], # FTDI + 0x10C4: [0xea60, 0xea70, 0xea71], # SiLabs + 0x067B: [0x2303, 0x23a3, 0x23b3, 0x23c3, 0x23d3, 0x23e3, 0x23f3], # Prolific + 0x1a86: [0x5523, 0x7523, 0x55D4], # Qinheng + 0x0483: [0x5740], # ST CDC + 0x2E8A: [0x0005, 0x000A], # Raspberry Pi Pico + } def android_notification(self, title="", content="", ticker="", group=None, context_id=None): if android_api_version < 26: return @@ -110,6 +118,7 @@ class SidebandService(): self.wifi_manager = None self.power_manager = None self.usb_devices = [] + self.usb_device_filter = SidebandService.usb_device_filter self.notification_service = None self.notification_channel = None @@ -152,7 +161,9 @@ class SidebandService(): "manufacturer": device.getManufacturerName(), "productname": device.getProductName(), } - self.usb_devices.append(device_entry) + if device_entry["vid"] in self.usb_device_filter: + if device_entry["pid"] in self.usb_device_filter[device_entry["vid"]]: + self.usb_devices.append(device_entry) except Exception as e: RNS.log("Could not list USB devices. The contained exception was: "+str(e), RNS.LOG_ERROR)