The app uses a NotificationListenerService to check for the presence of the "USB debugging connected" or "Wireless debugging connected" notification. When an ADB connection is detected this way, a WakeLock is acquired to prevent the screen from turning off. The WakeLock is released when the screen is manually turned off and re-acquired when the screen is turned back on.
The feature request (from 2016) to include this functionality in Android can be found here:
Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.