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

Commit 426bbdb4 authored by Jack Wu's avatar Jack Wu
Browse files

charger: fix secondary display not turning off after first display was off



turn off both display after first display was turned off

Bug: 242967285
Test: charging animation can show in display correctly
Ignore-AOSP-First: cherry-pick from aosp
Signed-off-by: default avatarJack Wu <wjack@google.com>
Change-Id: Ie5741b49322aaf8a3750b1977fb203e4d0df3539
parent c3bda9f3
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ void HealthdDraw::blank_screen(bool blank, int drm) {
    gr_fb_blank(blank, drm);
}

/* support screen rotation for foldable phone */
// support screen rotation for foldable phone
void HealthdDraw::rotate_screen(int drm) {
    if (!graphics_available) return;
    if (drm == 0)
@@ -108,6 +108,11 @@ void HealthdDraw::rotate_screen(int drm) {
        gr_rotate(GRRotation::NONE /* Portrait mode */);
}

// detect dual display
bool HealthdDraw::has_multiple_connectors() {
    return graphics_available && gr_has_multiple_connectors();
}

void HealthdDraw::clear_screen(void) {
    if (!graphics_available) return;
    gr_color(0, 0, 0, 255);
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ class HealthdDraw {
  // Rotate screen.
  virtual void rotate_screen(int drm);

  // Detect dual display
  virtual bool has_multiple_connectors();

  static std::unique_ptr<HealthdDraw> Create(animation *anim);

 protected:
+15 −0
Original line number Diff line number Diff line
@@ -289,6 +289,18 @@ static void reset_animation(animation* anim) {
    anim->run = false;
}

void Charger::BlankSecScreen() {
    int drm = drm_ == DRM_INNER ? 1 : 0;

    if (!init_screen_) {
        /* blank the secondary screen */
        healthd_draw_->blank_screen(false, drm);
        healthd_draw_->redraw_screen(&batt_anim_, surf_unknown_);
        healthd_draw_->blank_screen(true, drm);
        init_screen_ = true;
    }
}

void Charger::UpdateScreenState(int64_t now) {
    int disp_time;

@@ -338,6 +350,9 @@ void Charger::UpdateScreenState(int64_t now) {
        reset_animation(&batt_anim_);
        next_screen_transition_ = -1;
        healthd_draw_->blank_screen(true, static_cast<int>(drm_));
        if (healthd_draw_->has_multiple_connectors()) {
            BlankSecScreen();
        }
        screen_blanked_ = true;
        LOGV("[%" PRId64 "] animation done\n", now);
        if (configuration_->ChargerIsOnline()) {
+2 −0
Original line number Diff line number Diff line
@@ -107,9 +107,11 @@ class Charger {
    void InitAnimation();
    int RequestEnableSuspend();
    int RequestDisableSuspend();
    void BlankSecScreen();

    bool have_battery_state_ = false;
    bool screen_blanked_ = false;
    bool init_screen_ = false;
    int64_t next_screen_transition_ = 0;
    int64_t next_key_check_ = 0;
    int64_t next_pwr_check_ = 0;