Merge "support wrist orientation in recovery/fastbootd" into main am: 9a3616d25f
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/2824654 Change-Id: I11e0149ab9cb67c975fea95e93957f609c143e5f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
3d806cad7a
5 changed files with 75 additions and 1 deletions
|
@ -503,6 +503,10 @@ void gr_rotate(GRRotation rot) {
|
||||||
rotation = rot;
|
rotation = rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GRRotation gr_get_rotation() {
|
||||||
|
return rotation;
|
||||||
|
}
|
||||||
|
|
||||||
bool gr_has_multiple_connectors() {
|
bool gr_has_multiple_connectors() {
|
||||||
return gr_backend->HasMultipleConnectors();
|
return gr_backend->HasMultipleConnectors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,9 @@ unsigned int gr_get_height(const GRSurface* surface);
|
||||||
// Sets rotation, flips gr_fb_width/height if 90 degree rotation difference
|
// Sets rotation, flips gr_fb_width/height if 90 degree rotation difference
|
||||||
void gr_rotate(GRRotation rotation);
|
void gr_rotate(GRRotation rotation);
|
||||||
|
|
||||||
|
// Get current rotation
|
||||||
|
GRRotation gr_get_rotation();
|
||||||
|
|
||||||
// Returns the current PixelFormat being used.
|
// Returns the current PixelFormat being used.
|
||||||
PixelFormat gr_pixel_format();
|
PixelFormat gr_pixel_format();
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ class WearRecoveryUI : public ScreenRecoveryUI {
|
||||||
public:
|
public:
|
||||||
WearRecoveryUI();
|
WearRecoveryUI();
|
||||||
|
|
||||||
|
bool Init(const std::string& locale) override;
|
||||||
|
|
||||||
void SetStage(int current, int max) override;
|
void SetStage(int current, int max) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -197,8 +197,23 @@ bool RecoveryUI::Init(const std::string& /* locale */) {
|
||||||
return true;
|
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) {
|
void RecoveryUI::OnTouchDetected(int dx, int dy) {
|
||||||
enum SwipeDirection { UP, DOWN, RIGHT, LEFT } direction;
|
SwipeDirection direction;
|
||||||
|
|
||||||
// We only consider a valid swipe if:
|
// We only consider a valid swipe if:
|
||||||
// - the delta along one axis is below touch_low_threshold_;
|
// - the delta along one axis is below touch_low_threshold_;
|
||||||
|
@ -219,6 +234,11 @@ void RecoveryUI::OnTouchDetected(int dx, int dy) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flip swipe direction if screen is rotated upside down
|
||||||
|
if (gr_get_rotation() == GRRotation::DOWN) {
|
||||||
|
direction = FlipSwipeDirection(direction);
|
||||||
|
}
|
||||||
|
|
||||||
LOG(DEBUG) << "Swipe direction=" << direction;
|
LOG(DEBUG) << "Swipe direction=" << direction;
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case SwipeDirection::UP:
|
case SwipeDirection::UP:
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
|
|
||||||
|
@ -44,6 +45,50 @@ WearRecoveryUI::WearRecoveryUI()
|
||||||
touch_screen_allowed_ = true;
|
touch_screen_allowed_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void FlipOrientation() {
|
||||||
|
auto rotation = gr_get_rotation();
|
||||||
|
if (rotation == GRRotation::NONE) {
|
||||||
|
gr_rotate(GRRotation::DOWN);
|
||||||
|
} else if (rotation == GRRotation::DOWN) {
|
||||||
|
gr_rotate(GRRotation::NONE);
|
||||||
|
} else {
|
||||||
|
LOG(WARNING) << "Unsupported rotation for wrist orientation" << static_cast<int>(rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match values in
|
||||||
|
// frameworks/opt/wear/src/com/android/clockwork/wristorientation/WristOrientationService.java
|
||||||
|
enum class WristOrientation : unsigned {
|
||||||
|
LEFT_WRIST_ROTATION_0 = 0,
|
||||||
|
LEFT_WRIST_ROTATION_180 = 1,
|
||||||
|
RIGHT_WRIST_ROTATION_0 = 2,
|
||||||
|
RIGHT_WRIST_ROTATION_180 = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void InitWristOrientation() {
|
||||||
|
auto prop = android::base::GetUintProperty("ro.boot.wrist_orientation", 0u);
|
||||||
|
WristOrientation orientation{ prop };
|
||||||
|
if (orientation == WristOrientation::LEFT_WRIST_ROTATION_180 ||
|
||||||
|
orientation == WristOrientation::RIGHT_WRIST_ROTATION_180) {
|
||||||
|
LOG(INFO)
|
||||||
|
<< "InitWristOrientation(): flipping orientation because, 'ro.boot.wrist_orientation'="
|
||||||
|
<< prop;
|
||||||
|
|
||||||
|
FlipOrientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WearRecoveryUI::Init(const std::string& locale) {
|
||||||
|
auto result = ScreenRecoveryUI::Init(locale);
|
||||||
|
auto wrist_orientation_enabled =
|
||||||
|
android::base::GetBoolProperty("config.enable_wristorientation", false);
|
||||||
|
LOG(INFO) << "WearRecoveryUI::Init(): enable_wristorientation=" << wrist_orientation_enabled;
|
||||||
|
if (wrist_orientation_enabled) {
|
||||||
|
InitWristOrientation();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw background frame on the screen. Does not flip pages.
|
// Draw background frame on the screen. Does not flip pages.
|
||||||
// Should only be called with updateMutex locked.
|
// Should only be called with updateMutex locked.
|
||||||
// TODO merge drawing routines with screen_ui
|
// TODO merge drawing routines with screen_ui
|
||||||
|
|
Loading…
Reference in a new issue