Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1b17113 authored by Jack Wu's avatar Jack Wu
Browse files

Charger: support secondary connector



set first connector as default

Test: charging animation can show in correct display
Bug: 191831427
Signed-off-by: default avatarJack Wu <wjack@google.com>
Change-Id: Ia79981569e799f01db0036f0ecbdaca36a539ac6
parent d950242c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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) {
+2 −1
Original line number Diff line number Diff line
@@ -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);

+4 −3
Original line number Diff line number Diff line
@@ -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));

+7 −0
Original line number Diff line number Diff line
@@ -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_;