Distance measuring
Using ultrasound
Using the loudspeaker and the microphone send out a ping and measure the time until it returns. See http://www.parallax.com/dl/docs/prod/audiovis/Distance28015.pdf
This might also be used for measuring the distance to the head: If the distance is very short then you are probably speaking and the display can be turned off.
Using accelerometer
An accelerometer can very precisely compute short distances. Using an accelerometer you can mark a start position and an end position and get the distance between the two. You can even mark several positions, have the positions roughly displayed on the screen with the distanced on each line segment.
Unfortunately, without any orientation reference, an accellerometer is largely useless for this task, as you don't know in which direction the accelleration is happening, or if the phone is changing orientation.
It would need integrated gyros too.
This is possible, (maybe $30 total in volume) but even with these, the drift in the accellerometers and gyros mean that the position you have _rapidly_ degrades - after a minute it's unlikely to be within a dozen meters.
There are better accellerometers and gyros avaialble, but they are in the $several K range, and will not fit in a phone.