A former British immigration official and a retired Hong Kong police officer have been jailed for spying for China.