'Could adb command disable/turn off a display screen of android phone while it is still working as normal?

I am wondering if adb command could disable/turn off a display screen of android phone while it is still working as normal. I see the scrcpy tool (scrcpy -S) can do that it shows and allows interacting with a working screen of the phone on PC while disabling/turning off the screen of the physical phone. Thanks,



Solution 1:[1]

As I found that there is no adb command for this. Fortunately, thanks for guideline of scrcpy developer (@rom1v), I have successfully made it work with java code in instead. https://github.com/Genymobile/scrcpy/issues/2888

Demo video: https://www.youtube.com/watch?v=uMXGYrTn11E

Solution 2:[2]

yes, you can turn off the display screen of an Android phone by using the following commands (assuming you can use grep on your terminal):

if adb shell dumpsys power | grep -q 'Display Power: state=ON'; then
     adb shell input keyevent 26
fi

The if statement will check whether the phone has the display on (based on the result provided by dumpsys) and the adb command within the if block will actually turn off the display.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Lino