They can't prevent you from entering the country. You do not have an unlimited right to bring items into the country with you, though. They can absolutely prevent you from bringing your phone across the border if you decline to unlock it
Under what grounds?
I'm not saying that I agree with it, it's just the way it is