Added USB device filter

This commit is contained in:
Mark Qvist 2023-10-15 01:10:10 +02:00
parent a68a882fca
commit ceeec1fd41
2 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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)