Whenever i connect to any device via ADB, the screen orientation is set to auto rotate.
adb = Client(host="127.0.0.1", port=5037)
devices = adb.devices()
adb.remote_connect("192.168.178.31", 5555)
device = adb.device("192.168.178.31:5555")
device.shell('input touchscreen tap 537 869')
So as soon as i would run the shell command, the device would be set to auto rotate. How would i either set the default device orientation to portrait, or fix the problem otherwise?
CodePudding user response:
device.shell('settings put system user_rotation 0')
device.shell('settings put system accelerometer_rotation 0')
You can choose the value that corresponds to the desired orientation by user_rotation
(0 for portrait, 1 for landscape)
Instead of you can change accelerometer_rotation
for disable or enable rotation (0 stay current, 1 rotate screen)
CodePudding user response:
Disable auto rotation
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
Force landscape
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
Rotate back to portrait
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
Upside down
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:2
Rotate to landscape, right
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:3
This is how it works in setup wizard in android. Auto rotate is set to disable(0) during the setup until we press "Finish" then autorotate is set to active again. adb shell settings
wont work on the "fly" so it's better to use adb shell content
for doing such things:
Utils : backupDefaultScreenOrientation, set auto rotate 0
07-16 13:28:36:953 Utils : restoreDefaultScreenOrientation, set auto rotate 1