China's Huawei Technologies and South Korea's Samsung Electronics have agreed to settle a two-year old patent dispute in the United States, court documents show.