Proximity Service app
Minimal service for turning off the screen using the proximity sensor
Proximity Service uses your device's proximity sensor to control the screen on/off state. Simply covering the sensor will turn the screen off whilst keeping the device awake - perfect for games that need to be running in the foreground but don't need your continuous attention. Flip your phone on a table, place it in your pocket, or use any other means to cover the proximity sensor. As soon as the sensor is uncovered, the screen will come back on.
This app is open source - follow the website link at the bottom of this Play Store listing for the GitHub repo.