With canbus wiring for the infotainment system I think the car only remembers the code for the original factory fitted radio unit
If that's correct, for a replacement radio, can you enter the code manually to unlock the safe mode default
Cheers Spike