http://stackoverflow.com/questions/25864385/changing-android-device-orientation-with-adb
You may first need to turn off the automatic rotation
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
rotate to landscape
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
rotate portrait
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
You can also use
2
and 3
for upside-down portrait and reverse landscape respectively
First you have to run
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
to turn off the automatic rotation