This can be done using the following command:
adb shell dumpsys | grep 'SurfaceOrientation' | awk '{ print $2 }'
The output will be an integer from 0 to 3 for each of the four possible orientations. 0 and 2 are landscapes, and 1 and 3 are portraits. Since the output is dumpsysvery large, the command may take a few seconds.
Update: Perhaps dgmltn change is much faster:
adb shell dumpsys input | grep 'SurfaceOrientation' | awk '{ print $2 }'
source
share