Your definition of "gratuity" would be very helpful here. If by gratuity, you mean taking something extra (like money) at the end of performing a service, then I agree that this borders on bribery, which is unlawful.
On the other hand, many Starbucks, for example, have the policy to serve free coffee to anyone in uniform. I understand it was a managerial decision unique to each store, but this was certainly the case at the two Starbucks in Waco, TX. If this is what you mean, then I do not see anything wrong with this. In fact, it is a win-win for both the company and the officer. Officers get free coffee, and Starbucks has a consistent and regular police presence. This sends a message to the neighborhood that Starbucks is attempting to promote safety as well as thank services that largely go underpaid. (I used to constantly ask for a teacher discount to no avail...)