Hello,
not all boats were fitted with a radar warning device, and almost never in time with the latest one detecting the most recent allied radar systems.
A lot of the warning devices failed now and then, they were added to a U-boat that had not been initially designed to carry the devices.
At the end of the war some U-boats did have several devices that would detect the full spread of radar wavelengths, but at that time they could hardly have surfaced without hearing one - allied ships and planes were almost everywhere then.
The "electronic" war (which is wrong there were only electrics, or, at least tubes, no transistors) is a chapter of its own.
But if you read the GWX manual chapter dealing with the antennas and detectors you will get an idea
Greetings,
Catfish