I've heard that they collect the IMEI number. Can you refuse consent to this and what happens if you don't unlock it? Further, are they allowed to look into your messages? Further what happens if they open it for one purpose and then catch notice incidentally of some incriminating information? Can that be used against one?
They can do it before you are arrested and without a warrant
They have this power under the Investigatory Powers Act 2016.
The IMEI can get accessed without getting into your phone OS or it even being on because it has to be physically written onto it or a sticker in it. iPhones have it in the SIM tray and on the backside. And Apple will gleefully tell you the SN in exchange for the IMEI and vice versa.
They gave the right to get the IMEI to identify if a phone is reported stolen and to make sure you get back your own phone when released from custody. They may also find a lack of a SN or IMEI highly suspect and warent further and deeper investigation if this is a stolen property.