Had the same issue and this thread helped find the solution. Running 4.0.4 there is a calibration for the g-gensor.
Settings> Display> Als_ps calibration.
I had to put my hand directly on the phone where the sensor is (close to ear/phone call speaker) and it sets the sensor that locks out...