@mcp.tool()
def rotate_screen(orientation: str = "portrait", device_serial: str | None = None) -> str:
"""
Rotate screen orientation.
orientation: 'portrait', 'landscape', 'reverse_portrait', 'reverse_landscape', or 'auto'
"""
orientations = {
'auto': ('0', 'user'),
'portrait': ('1', '0'),
'landscape': ('1', '1'),
'reverse_portrait': ('1', '2'),
'reverse_landscape': ('1', '3')
}
if orientation not in orientations:
return f"Invalid orientation. Use: {list(orientations.keys())}"
accel_rotation, user_rotation = orientations[orientation]
if orientation == 'auto':
run_adb(["shell", "settings", "put", "system", "accelerometer_rotation", "1"], device_serial)
else:
run_adb(["shell", "settings", "put", "system", "accelerometer_rotation", "0"], device_serial)
run_adb(["shell", "settings", "put", "system", "user_rotation", user_rotation], device_serial)
return f"Screen rotation set to {orientation}"