Running this from the command-line worked for me:
bash
adb shell "dumpsys input | grep SurfaceOrientation | awk '{print $2}' | head -n 1"
If it returns 0 or 2 the device is in portrait. If it returns 1 or 3 the device is in landscape.
Note: I am on a rooted device and have busybox with grep, awk, and head applets. You may need to parse the output of dumpsys elsewhere.