diff options
author | Jack Wu <wjack@google.com> | 2021-09-29 22:27:56 +0800 |
---|---|---|
committer | Jack Wu <wjack@google.com> | 2022-01-25 19:59:04 +0800 |
commit | c1b171138e4a984b7384611310a8511adecaa5c6 (patch) | |
tree | 2b398fc5cdef6296a87280f9fdf05a3ff94bd221 /healthd | |
parent | d950242c0d7e9c9760a4bb4b552d74f766a56e0e (diff) | |
download | core-c1b171138e4a984b7384611310a8511adecaa5c6.tar.gz |
Charger: support secondary connector
set first connector as default
Test: charging animation can show in correct display
Bug: 191831427
Signed-off-by: Jack Wu <wjack@google.com>
Change-Id: Ia79981569e799f01db0036f0ecbdaca36a539ac6
Diffstat (limited to 'healthd')
-rw-r--r-- | healthd/healthd_draw.cpp | 6 | ||||
-rw-r--r-- | healthd/healthd_draw.h | 3 | ||||
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 7 | ||||
-rw-r--r-- | healthd/include_charger/charger/healthd_mode_charger.h | 7 |
4 files changed, 17 insertions, 6 deletions
diff --git a/healthd/healthd_draw.cpp b/healthd/healthd_draw.cpp index 4484fa61e..0e6fd2783 100644 --- a/healthd/healthd_draw.cpp +++ b/healthd/healthd_draw.cpp @@ -94,9 +94,9 @@ void HealthdDraw::redraw_screen(const animation* batt_anim, GRSurface* surf_unkn gr_flip(); } -void HealthdDraw::blank_screen(bool blank) { +void HealthdDraw::blank_screen(bool blank, int drm) { if (!graphics_available) return; - gr_fb_blank(blank); + gr_fb_blank(blank, drm); } void HealthdDraw::clear_screen(void) { @@ -139,6 +139,8 @@ int HealthdDraw::draw_text(const GRFont* font, int x, int y, const char* str) { void HealthdDraw::determine_xy(const animation::text_field& field, const int length, int* x, int* y) { *x = field.pos_x; + screen_width_ = gr_fb_width() / (kSplitScreen ? 2 : 1); + screen_height_ = gr_fb_height(); int str_len_px = length * field.font->char_width; if (field.pos_x == CENTER_VAL) { diff --git a/healthd/healthd_draw.h b/healthd/healthd_draw.h index 0b48ce842..0d7ac7ad0 100644 --- a/healthd/healthd_draw.h +++ b/healthd/healthd_draw.h @@ -31,8 +31,9 @@ class HealthdDraw { // Redraws screen. void redraw_screen(const animation* batt_anim, GRSurface* surf_unknown); + // According to the index of Direct Rendering Manager, // Blanks screen if true, unblanks if false. - virtual void blank_screen(bool blank); + virtual void blank_screen(bool blank, int drm); static std::unique_ptr<HealthdDraw> Create(animation *anim); diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 0f9779c4f..821206f06 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -327,7 +327,7 @@ void Charger::UpdateScreenState(int64_t now) { #if !defined(__ANDROID_VNDK__) if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) { - healthd_draw_->blank_screen(true); + healthd_draw_->blank_screen(true, static_cast<int>(drm_)); screen_blanked_ = true; } #endif @@ -337,7 +337,7 @@ void Charger::UpdateScreenState(int64_t now) { if (batt_anim_.num_cycles > 0 && batt_anim_.cur_cycle == batt_anim_.num_cycles) { reset_animation(&batt_anim_); next_screen_transition_ = -1; - healthd_draw_->blank_screen(true); + healthd_draw_->blank_screen(true, static_cast<int>(drm_)); screen_blanked_ = true; LOGV("[%" PRId64 "] animation done\n", now); if (configuration_->ChargerIsOnline()) { @@ -349,7 +349,7 @@ void Charger::UpdateScreenState(int64_t now) { disp_time = batt_anim_.frames[batt_anim_.cur_frame].disp_time; if (screen_blanked_) { - healthd_draw_->blank_screen(false); + healthd_draw_->blank_screen(false, static_cast<int>(drm_)); screen_blanked_ = false; } @@ -743,6 +743,7 @@ void Charger::OnInit(struct healthd_config* config) { batt_anim_.frames[i].surface = scale_frames[i]; } } + drm_ = DRM_INNER; ev_sync_key_state(std::bind(&Charger::SetKeyCallback, this, std::placeholders::_1, std::placeholders::_2)); diff --git a/healthd/include_charger/charger/healthd_mode_charger.h b/healthd/include_charger/charger/healthd_mode_charger.h index 216e5ad3c..698719f78 100644 --- a/healthd/include_charger/charger/healthd_mode_charger.h +++ b/healthd/include_charger/charger/healthd_mode_charger.h @@ -44,6 +44,11 @@ struct ChargerHealthInfo { aidl::android::hardware::health::BatteryStatus battery_status; }; +enum DirectRenderManager { + DRM_INNER, + DRM_OUTER, +}; + // Configuration interface for charger. This includes: // - HalHealthLoop APIs that interests charger. // - configuration values that used to be provided by sysprops @@ -102,6 +107,8 @@ class Charger { int64_t next_pwr_check_ = 0; int64_t wait_batt_level_timestamp_ = 0; + DirectRenderManager drm_; + key_state keys_[KEY_MAX + 1] = {}; animation batt_anim_; |