support wrist orientation in recovery/fastbootd
Add support for wrist orientation in recovery. Feature controlled by
the property "config.enable_wristorientation".
Read 'ro.boot.wrist_orientation' property to determine if screen
orientation should be flipped and swipes inverted.
Bug: 257123026
Bug: 309982093
Test: build boot/recovery
Test: recovery/fastbootd uses same orientation as android
Change-Id: I29e0e682cca81d302dae502382b6270afe105d72
diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp
index 8bc0244..9b0fd94 100644
--- a/recovery_ui/ui.cpp
+++ b/recovery_ui/ui.cpp
@@ -197,8 +197,23 @@
return true;
}
+enum SwipeDirection { UP, DOWN, RIGHT, LEFT };
+
+static SwipeDirection FlipSwipeDirection(SwipeDirection direction) {
+ switch (direction) {
+ case UP:
+ return SwipeDirection::DOWN;
+ case DOWN:
+ return SwipeDirection::UP;
+ case RIGHT:
+ return SwipeDirection::LEFT;
+ case LEFT:
+ return SwipeDirection::RIGHT;
+ }
+}
+
void RecoveryUI::OnTouchDetected(int dx, int dy) {
- enum SwipeDirection { UP, DOWN, RIGHT, LEFT } direction;
+ SwipeDirection direction;
// We only consider a valid swipe if:
// - the delta along one axis is below touch_low_threshold_;
@@ -219,6 +234,11 @@
return;
}
+ // Flip swipe direction if screen is rotated upside down
+ if (gr_get_rotation() == GRRotation::DOWN) {
+ direction = FlipSwipeDirection(direction);
+ }
+
LOG(DEBUG) << "Swipe direction=" << direction;
switch (direction) {
case SwipeDirection::UP: