I've never had to do that, but I haven't flown since 2016. If I was asked, I'd refuse. If they wouldn't let me though, I'd walk away and eat the cost.
I'll remember this for next time though. I'll be sure to check my phone and laptop. I could always just buy a book and not have electronic devices .. or maybe take a cassette deck.
AIUI the unlocking is usually requested at the customs checkpoint, which is after you've retrieved your checked luggage, and if you say no, you don't get to just "walk away" -- you risk finding yourself detained in legal limbo with no recourse.
I've experienced an unlock demand immediately after passing through TSA to get on a domestic flight. Had I refused I surely would have missed my flight and probably the wedding I was trying to get to. Maybe the consequences would have been even worse than that, but that alone was enough to coerce my compliance.
I'll remember this for next time though. I'll be sure to check my phone and laptop. I could always just buy a book and not have electronic devices .. or maybe take a cassette deck.