And just to clarify another element of the story: there is a significant legal difference between pre-clearance in a Canadian airport and landing in the US and proceeding through customs on US soil. At a pre-clearance station, you are still on Canadian soil. I'm sure there are exceptions, but you generally can "withdraw your application to enter" and basically just turn around and walk away from the border. If you decide you don't want to unlock your phone for the CBP officer, you can walk away. At that point they've already seen your passport and you're going to be flagged and may never be approved for entry again, but you're not going to end up on a CBP facility. Once you're through, you'll need to clear Canadian customs to go back, but if something happens it will be Canadian police that arrest you.