Bypass android usb host permission confirmation dialog on Android 9

We can solve it by entering: adb shell su settings put global hidden_api_policy_pre_p_apps 1 settings put global hidden_api_policy_p_apps 1 Restrictions on non-SDK interfaces (Android 9): https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces And then grantDevicePermission method will be available again through reflection on Android 9: public static boolean grantAutomaticUsbPermissionRoot(Context context, UsbDevice usbDevice) { try { PackageManager pkgManager = context.getPackageManager(); ApplicationInfo appInfo … Read more

How do I read input from a USB HID device?

I did this successfully before using a “Raw Input” implementation on CodeProject: Raw Input It allows you to receive both the input (what “keys” are pressed if it mimics a “keyboard”) as well distinguish which device it came from.

USB Device Connected

//using System.Management public bool IsUsbDeviceConnected(string pid, string vid) { using (var searcher = new ManagementObjectSearcher(@”Select * From Win32_USBControllerDevice”)) { using (var collection = searcher.Get()) { foreach (var device in collection) { var usbDevice = Convert.ToString(device); if (usbDevice.Contains(pid) && usbDevice.Contains(vid)) return true; } } } return false; }

Mocking USB input

Mocking usb devices using umockdev Umockdev is a linux based application which record the behaviour as well as properties of hardware and run the software independent of actual hardware it is running on. Hardware devices can be simulated in virtual environments without disturbing the whole system.It currently supports sysfs, uevents, basic support for /dev devices, … Read more

How to emulate USB devices?

Edit: Proof of concept here I strongly recommend this project, USB IP. It is a way of connecting USB devices over the network. There is a Windows client. What this means is, you install the client on your Windows computer. This device then expects to talk to a USB device connected to a Linux computer, … Read more

Sign PDF with iTextSharp 5.3.3 and USB token

This approach works fine for us (iTextSharp 5.3.3). We use smart-card and USB-token (vendor – www.author.kiev.ua): X509Store store = new X509Store(StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection sel = X509Certificate2UI.SelectFromCollection(store.Certificates, null, null, X509SelectionFlag.SingleSelection); X509Certificate2 cert = sel[0]; Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser(); Org.BouncyCastle.X509.X509Certificate[] chain = new Org.BouncyCastle.X509.X509Certificate[] { cp.ReadCertificate(cert.RawData)}; IExternalSignature externalSignature = new X509Certificate2Signature(cert, “SHA-1”); PdfReader pdfReader = new … Read more