Skip to content

Commit

Permalink
Add android support for setting orientation
Browse files Browse the repository at this point in the history
I do not have an android setup and have not tested this yet. This implementation is based off conventions in `AndroidDriver.kt` for interacting with `adb` and this reference for what commands should be run https://stackoverflow.com/q/25864385.
  • Loading branch information
johntmcintosh committed Nov 2, 2024
1 parent c978384 commit de55e0f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,15 @@ class AndroidDriver(
}

override fun setOrientation(orientation: DeviceOrientation) {
// TODO(jmac) Implement and test
// Disable accelerometer based rotation before overriding orientation
dadb.shell("settings put system accelerometer_rotation 0")

when(orientation) {
DeviceOrientation.PORTRAIT -> dadb.shell("settings put system user_rotation 0")
DeviceOrientation.LANDSCAPE_LEFT -> dadb.shell("settings put system user_rotation 1")
DeviceOrientation.UPSIDE_DOWN -> dadb.shell("settings put system user_rotation 2")
DeviceOrientation.LANDSCAPE_RIGHT -> dadb.shell("settings put system user_rotation 3")
}
}

override fun eraseText(charactersToErase: Int) {
Expand Down

0 comments on commit de55e0f

Please sign in to comment.