Xiaomi was once the darling of the smartphone world. But it has been struggling in the past two years.