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
Stay calm, decline to answer questions beyond identifying yourself, and ask for a lawyer. Do not physically resist, but make it clear you do not consent to any search.