You Can Keep Your Phone Locked And Refuse To Unlock It
It is your right to keep your phone locked and for you to refuse to unlock it. Doing this means they will not be able to look through your phone without your permission, should you be handcuffed or the phone is taken away from you etc.
If You Are Not Arrested, You Do Not Have To Consent To A Phone Search
It is illegal for the police to search your phone if they do not have a warrant and you are not under arrest. Although see the ‘Depending On The Scenario’ point below
If The Police Officer Proceeds Anyway, Do Not Get Physical
This is the last thing you should do as things could quickly escalate. Instead, repeat the words – “I do not consent to this phone search”. If there are others around say it loudly so everyone hears, so there is no ambiguity. Additionally, nothing found on an illegal phone search can be used in evidence.
Depending On The Scenario, Consider Giving Consent
This might surprise some people, but there are many scenarios when it might be easier or better to give consent for a police officer to use or search your phone. For example, you may have inadvertently captured something important in a photo or video. Additionally, a police officer may need the use of your phone to ring something through in an emergency.
Another important point to make is that it is lawful for a police officer to search your phone without a warrant, if a child has been abducted or if they believe someone is in imminent harm, or they believe there is the possibility of evidence on the phone being destroyed. They should clearly state the phone search is related to these issues though.
This is obviously a very basic guide, for a full breakdown of the law and your rights, see this EFF guide and this ACLU guide