Proximity Sensor Nexus S
I suspect it consists of an IR LED, and an IR phototransistor. When the IR LED's light reflects off your face, it is received by the phototransistor, which either generates an analog or digital (threshold-based) output.