I have the exact opposite issue with the proximity sensor on my Samsung S20 plus running Android 10 - i.e. it works well by turning the screen off when my ear/cheek/face is very close to the proximity sensor during phone calls; whereas, when the phone's screen is locked and turned off, the proximity sensor is turned off as well. Control by hardware? Software/firmware? Don't know?! To turn the screen on without using the Power hardware button, I had to enable the "Double Tap" feature in Settings.
On earlier/other Android mobile devices - Samsung included - the proximity sensor is always on - whether the screen is on, off, or currently locked. When it's always on, you can be innovative and build a widget, for instance, to turn the screen on by "waving" your hand above the proximity sensor to interrupt the laser. I suspect new(er) Samsung mobile devices like S20 and Note20 variants might be using a "virtual" proximity sensor setup/combo for controlling the device's screen - and that really sucks!
To test if the proximity sensor is always activated on Samsung S20 and Note20 variants, I type *#77692# - which displayed a hardware screen to test proximity and light sensors. Note: if you type *#0*#, the proximity and light sensor options are absent from the hardware test screen.
Has anyone found any method - via codes even - to permanently turn on the proximity sensor, even when the screen is locked and turned off?
I searched through AOSP framework vanilla codes and couldn't see anything out of the ordinary regarding control of the proximity sensor. Samsung might be doing something dubious with their firmwares/hardwares though - well, at least, the S20 and Note20 variants are having issues with the proximity sensor setup.
P.S: Not sure if you guys are aware, but Samsung mobile devices with odd designation tends to be more problematic than their even-designated counterparts, like screen's burn-ins/shadows on Samsung S3 devices, light sensor fluctuation (which affects screen brightness control) on Samsung S5s, and now proximity problems with the S20s and Note20. Samsung S20 variants are in fact "S11" variants renamed. So the trend continues with Samsung always stuffing up their odd-designated device releases.