Key rights to remember
You have a right to remain silent (Charter section 7, 11(c)).
You have a right to consult a lawyer without delay on arrest or detention (section 10(b)).
You can decline to provide your passcode unless a court orders you to.
What police can do without a warrant
The Supreme Court in R. v. Fearon (2014) allowed limited search of a phone incident to arrest, but only where: (a) the arrest was lawful, (b) the search is truly incident to arrest, (c) the nature and extent are tailored to the purpose, and (d) detailed notes are taken. Courts have been increasingly critical of broad searches.
What to do
A person who is detained has the right to remain silent beyond identifying themselves and the right to speak with a lawyer (Charter ss.7, 10(b)). Physically resisting a search is an offence; stating clearly that consent to the search is not given preserves the s.8 argument for later.