I managed to make it work by pressing the calibration button in the test screen. Be careful so as the sensor is not covered before starting and during calibration.[br]
For calibration:
# Go to service menu: call '''*#546368#*710#'''
# Device Test -> SAAT -> Auto Test
# Long press power button -> “Don’t touch proximity sensor” appears in red
# Press “PASS”
# You will reach the proximity and light sensor test screen
# Make sure the sensor is clear and not covered and press “Cal Start”
# After calibration is done the sensor should work OK