Illegality....
You normally describe something as "illegal" when it is against the criminal law. Unlocking a phone or breaching a contract is absolutely NOT illegal. So dont worry about going to prison.
Not signing up to O2 *might* be a breach of contract, but:
- for CPWH to enforce, they woudl have to show loss, and I woudl expect this to be difficult as the benefit of the O2 contract would be for O2
- O2 *might* be able to enforce the contract, but that woudl rely on the Contracts (Rights of Third Parties) Act which might be expressly excluded from your sales agreement, and even if it isnt, doesnt necessarily give O2 to right to enforce
- all consumer contracts are subject to overriding principles of fairness anyway.
Easiest route does seem to be to avoid CPWH....