Don't be fooled, Canadian border patrol proudly engages in this as well. I was recently driving across the border to Montreal on vacation when Canadian border agents, in addition to searching my car and personal belongings, demanded to see my cell phone and turn over the password. I simply asked why, since I didn't think I was doing anything suspicious, at which point the agent angrily responded "because I can and now I'm going to search it extra thoroughly." I asked what would happen if I didn't turn the password over and just went back home to the US, they told me they'd seize the device and put me in prison until they break into it. So, I gave the password, 3 agents took it in the back for 45 minutes, came back and questioned me about some texts I had with a friend from months ago who was talking about marijuana, and eventually let me pass to Canada. Hopefully they didn't hold on to all my personal data or install backdoors but just in case I wiped the phone and reinstalled from a backup.
In any case, this was extremely intrusive and I couldn't stop thinking about it the whole trip. I wondered what would happen if I had actually forgotten my phone password - just weeks before I changed from a 6 digit numeric code to a longer alphanumeric and almost forgot it since it had been a while since the last time I restarted my phone requiring password entry. I had a lot of very private photos and conversations on there with my SO. Definitely ruined my whole vacation.
Edit: Also, they didn't just stick to private photos and messages, they even opened up dating apps checking for messages there, opened up unread snap and kik messages too.