The proximity sensor turns the screen off when the phone is at your ear. When it fails, your cheek presses buttons, or the screen stays black after the call.
1. Clean the top of the screen near the earpiece.
2. Remove the screen protector, especially dark or privacy ones that cover the sensor.
3. Restart the phone and test with the phone's test menu if it has one.
4. After a screen replacement, check the sensor's small holder and rubber were moved to the new screen.
5. Some copy screens are not clear enough above the sensor. Try another screen.
6. If none of this helps, replace the sensor flex.
Many phones use the screen itself as the sensor, so calibration in settings can help there.