While you are legally required to hand over the passcode, they can confiscate the device for two weeks or more, which is probably a large deterrent for most people.
> Officers routinely ask travellers to provide their passcode or password to devices so they can be examined, but they do not have the power to compel passengers to hand over their passcodes,
... and they're doing it for purely punitive reasons. We all know they're not "examining" the phones in any meaningful way. It's too expensive and failure-prone.