shadows/framework/src/main/java/org/robolectric/shadows/ShadowUsbManager.java
private static Object createUsbPortStatus(
      int currentMode,
      int currentPowerRole,
      int currentDataRole,
      int supportedRoleCombinations) {
    if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.Q) {
      return new UsbPortStatus(
          currentMode,
          currentPowerRole,
          currentDataRole,
          supportedRoleCombinations,
          0,
          0
      );
    }
    return callConstructor(UsbPortStatus.class,
        from(int.class, currentMode),
        from(int.class, currentPowerRole),
        from(int.class, currentDataRole),
        from(int.class, supportedRoleCombinations));

  }
private static Object createUsbPortStatus(
      int currentMode,
      int currentPowerRole,
      int currentDataRole,
      int supportedRoleCombinations) {
    if (RuntimeEnvironment.getApiLevel() >= Build.VERSION_CODES.Q) {
      return new UsbPortStatus(
          currentMode,
          currentPowerRole,
          currentDataRole,
          supportedRoleCombinations,
          0,
          0
      );
    }
    return callConstructor(UsbPortStatus.class,
        from(int.class, currentMode),
        from(int.class, currentPowerRole),
        from(int.class, currentDataRole),
        from(int.class, supportedRoleCombinations));

  }
Helper method for creating a {@link UsbPortStatus}.

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