I know, regarding luggage one can't decline at all
My opinion was about smartphones, they can detain or threat for refusing entry (or even refuse it in some cases) which is kinda like forcing people who are desperate to enter the US to just let immigration officers invade their privacy.
But they can't actually force you to unlock the phone without your consent if it unlocks by a pin/password (something you know)
Neither they can arrest you (but they can detain you) for not unlocking it unless they already have linked you to some case or crime.
In case the device unlocks by biometrics (something you are) then they are allowed to go through contents as if u presented them an unlocked device.
Again that's if officers are following the law.
If they already have received specific instructions (regarding against an individual or against flights coming from specific geographic area) or decide to abuse their powers then who is stopping them for such behavior against citizens of countries like ours.