A "persistent offender" who struck a police officer in the head with a brick as he resisted arrest has been jailed for two years.