From 56540a0509d60f7b419a779b74ad31178b9f1fbc Mon Sep 17 00:00:00 2001 From: Jack Wu Date: Fri, 22 Oct 2021 17:10:37 +0800 Subject: [PATCH] charger: support screen rotation Bug: 191831427 Test: charging animation can show in display correctly Signed-off-by: Jack Wu Change-Id: Iedcd7d6c3cd841c44bdf1116701abcbd12a26959 --- healthd/healthd_draw.cpp | 9 +++++++++ healthd/healthd_draw.h | 3 +++ healthd/healthd_mode_charger.cpp | 1 + 3 files changed, 13 insertions(+) diff --git a/healthd/healthd_draw.cpp b/healthd/healthd_draw.cpp index 0e6fd2783..3e73fcd08 100644 --- a/healthd/healthd_draw.cpp +++ b/healthd/healthd_draw.cpp @@ -99,6 +99,15 @@ void HealthdDraw::blank_screen(bool blank, int drm) { gr_fb_blank(blank, drm); } +/* support screen rotation for foldable phone */ +void HealthdDraw::rotate_screen(int drm) { + if (!graphics_available) return; + if (drm == 0) + gr_rotate(GRRotation::RIGHT /* landscape mode */); + else + gr_rotate(GRRotation::NONE /* Portrait mode */); +} + void HealthdDraw::clear_screen(void) { if (!graphics_available) return; gr_color(0, 0, 0, 255); diff --git a/healthd/healthd_draw.h b/healthd/healthd_draw.h index 0d7ac7ad0..3d4abbdda 100644 --- a/healthd/healthd_draw.h +++ b/healthd/healthd_draw.h @@ -35,6 +35,9 @@ class HealthdDraw { // Blanks screen if true, unblanks if false. virtual void blank_screen(bool blank, int drm); + // Rotate screen. + virtual void rotate_screen(int drm); + static std::unique_ptr Create(animation *anim); protected: diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 012e33ba1..9fe85d40d 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -352,6 +352,7 @@ void Charger::UpdateScreenState(int64_t now) { if (screen_switch_ == SCREEN_SWITCH_ENABLE) { healthd_draw_->blank_screen(true, 0 /* drm */); healthd_draw_->blank_screen(true, 1 /* drm */); + healthd_draw_->rotate_screen(static_cast(drm_)); screen_blanked_ = true; screen_switch_ = SCREEN_SWITCH_DISABLE; }