@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) { UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); if (usbDevice != null) { // paranoia // We might get attachment notifications before the event loop is set up, so // we hold on to them and pass them along only when we're good and ready. if (receivedUsbAttachmentNotifications != null) { // *total* paranoia receivedUsbAttachmentNotifications.add(usbDevice); passReceivedUsbAttachmentsToEventLoop(); } } } }
private void requestRobotSetup() { if (controllerService == null) return; FileInputStream fis = fileSetup(); // if we can't find the file, don't try and build the robot. if (fis == null) { return; } HardwareFactory factory; // Modern Robotics Factory for use with Modern Robotics hardware HardwareFactory modernRoboticsFactory = new HardwareFactory(context); modernRoboticsFactory.setXmlInputStream(fis); factory = modernRoboticsFactory; eventLoop = new FtcEventLoop(factory, new FtcOpModeRegister(), callback, this); controllerService.setCallback(callback); controllerService.setupRobot(eventLoop); passReceivedUsbAttachmentsToEventLoop(); }