OTOH, why does china even allow Apple or Google devices today? Because Chinese people want to purchase these products and at this point there would be pushback if they were suddenly banned.
China doesn't allow Google devices today, Android the open source operating system is allowed but the Google services that make up Google devices are not. China allows Apple devices because Apple collaborates with the CCP, as do all businesses who operate in China.
Again why does china even bother to play ball with Apple? They could just have Xiaomi phones, not worry about apple holding up their own end of their bargain, and ensure they have total control entirely. The answer is because the Chinese consumer today might want to purchase an apple iphone over a xiaomi phone, and it would be unpopular for the regime to crack down on a freedom seen as established in the Chinese nation today.
Just like it would have been unpopular for the regime to ban the most popular search and services company in the world?
I don't know why you think China needs to worry about Apple, Apple has been a faithful and lucrative partner to them. They don't just faithfully collaborate on censorship and cede control of encrypted Chinese iCloud data directly to a state-owned cloud provider, we now know that Apple has signed a $275B omnibus deal with China that includes Chinese startup investments, Chinese worker training, and R&D collaboration with Chinese tech firms. There is no government that Apple invests more into or collaborates more closely with than China's.
Why not just have Xiaomi phones where you have total control? Well, because you can have that and total control over a global tech giant that pours foreign money and technology into your regime. Why not have both?