Xiaomi, a China-based smartphone manufacturer, has overtaken Samsung to sell the most devices in China's second quarter.