The way the proximity sensor works is that it emits ifrared light, which bounces off something nearby (like a face) and is detected by the other side of the sensor (that's why there is a dividing line down the middle). Unfortunately, sunlight also contains infrared light, which is why it is triggering the sensor. Same thing with a lamp. This is an inherent flaw in any infrared proximity sensor, and not a software or hardware problem. Replacing it will probably not fix anything.