mUsbManager = (UsbManager) getSystemService( Context.USB_SERVICE ); HashMap< String, UsbDevice > stringDeviceMap = mUsbManager.getDeviceList(); Collection< UsbDevice > usbDevices = stringDeviceMap.values(); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent( ACTION_USB_PERMISSION ), 0 ); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); registerReceiver( mUsbReceiver, filter ); Iterator< UsbDevice > usbDeviceIter = usbDevices.iterator(); while( usbDeviceIter.hasNext() ) { if ( USBDeviceValid( usbDevice ) ) { // Request permission to access the device. mUsbManager.requestPermission( usbDevice, mPermissionIntent ); // Open the device. UsbDeviceConnection connection = mUsbManager.openDevice( usbDevice ); int fd = connection.getFileDescriptor(); // Now pass the file descriptor to libusb through a native call. } }
public UsbDeviceConnectionAssert hasFileDescriptor(int descriptor) { isNotNull(); int actualDescriptor = actual.getFileDescriptor(); assertThat(actualDescriptor) // .overridingErrorMessage("Expected file descriptor <%s> but was <%s>.", descriptor, actualDescriptor) // .isEqualTo(descriptor); return this; }
public static int GetFD() { return usb_con.getFileDescriptor(); }
public UsbDeviceConnectionAssert hasFileDescriptor(int descriptor) { isNotNull(); int actualDescriptor = actual.getFileDescriptor(); assertThat(actualDescriptor) // .overridingErrorMessage("Expected file descriptor <%s> but was <%s>.", descriptor, actualDescriptor) // .isEqualTo(descriptor); return this; }
Log.d(TAG, "inserting device with id: " + device.getDeviceId() + " and file descriptor: " + connection.getFileDescriptor()); connectedDevices.put(device.getDeviceId(), connection.getFileDescriptor()); return connection.getFileDescriptor();
@Override public RemoteClockInfo syncClock() throws IOException { if (!isConnected()) { throw new IOException("Not connected to WALT"); } try { int fd = usbConnection.getFileDescriptor(); int ep_out = endpointOut.getAddress(); int ep_in = endpointIn.getAddress(); remoteClock.baseTime = syncClock(fd, ep_out, ep_in); remoteClock.minLag = 0; remoteClock.maxLag = getMaxE(); } catch (Exception e) { logger.log("Exception while syncing clocks: " + e.getStackTrace()); } logger.log("Synced clocks, maxE=" + remoteClock.maxLag + "us"); Log.i(TAG, remoteClock.toString()); return remoteClock; }
switch (nativeTriggerExploit(conn.getFileDescriptor(), 0x7000)) { case 0: Logger.log(context, "[+] Exploit triggered!");
public static boolean OpenAdapter() if (usb_con != null && usb_con.getFileDescriptor() != -1) return true;