This is a technical problem, not a legal one. Don't take your phone.
That’s a misattribution. Not bringing your phone means you are choosing not to do something perfectly legal due to abuse of power — and doing so is likely to encourage further abuse because the culprits know they are less likely to be recorded.
I'd disagree, you taking your phone through customs is indeed legal, and the border goon's seizure of you phone (by force if they prefer) and demands for your password on penalty of imprisonment is also legal. So this is not a legal issue, everyone is acting within the law. One could argue that it is a political issue, that the law should be changed (and I'd agree), but that's a different question.
If you’re really lucky, you can convince them that whatever they’re looking for doesn’t exist but consider how hard it is to prove a negative like that. In most cases, that devolves to the second outcome above, possibly with some destruction of evidence charge.