Hongkong's takeover by the British has been a humiliation for China and the Chinese people, which has been provoking strong feelings on their part since well before the Communist Party was even founded.
That China must get Hongkong back is a highly consensual opinion among the Chinese. This was a policy of the Communist Party because that really is something that every Chinese strongly wanted.
There are elements of wanting independence for Hongkong in the current protests and of foreign interference (whether it is true or not, this is how it looks). This is an absolute red flag for Chinese. In fact if TVs were showing everything we are shown in the West the government would have to act more strongly against the protesters by popular demand.
The Chinese government may not be democratic but that does not mean that it can ignore public opinion or that its policies never align with what the people want.
Campaigning for democracy was always going to be a uphill struggle in Hongkong, but these violent protests (which can be qualified of 'riots') have been highly counterproductive.