shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbManager.java
private static Object createUsbPort(
      UsbManager usbManager,
      String id,
      int supportedModes) {
    if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.Q) {
      return new UsbPort(
          usbManager,
          id,
          supportedModes,
          0,
          false,
          false
      );
    }
    return callConstructor(UsbPort.class,
        from(UsbManager.class, usbManager),
        from(String.class, id),
        from(int.class, supportedModes));
  }
private static Object createUsbPort(
      UsbManager usbManager,
      String id,
      int supportedModes) {
    if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.Q) {
      return new UsbPort(
          usbManager,
          id,
          supportedModes,
          0,
          false,
          false
      );
    }
    return callConstructor(UsbPort.class,
        from(UsbManager.class, usbManager),
        from(String.class, id),
        from(int.class, supportedModes));
  }
Helper method for creating a {@link UsbPort}.

Returns Object to avoid referencing the API M+ UsbPort when running on older platforms.