Backlight turns on and off on its own

Problem: I encountered this problem on HTC One X, HTC Desire Z and HTC Desire S. I suppose this doesn't concern HTC phones only. This is not the most serious problem in the world but it can be a bit annoying when your phone, out of the blue, turns the screen on in the middle of the night just to turn it off in a few seconds. I guess it can also significantly reduce the battery life.
Solution: In one phone this Android problem disappeared on its own  as suddenly as it appeared.  In HTC Desire S it was enough to restart the phone (hold the power button for a few seconds and then tap  Restart).

However, in my HTC One X  the problem didn't disappear until  I restored factory settings. To do that,  go to Settings > Backup & reset > Reset Phone. Remember about backup.