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

Commit 19d07d1c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "charger: Fix charger pixel format useless" am: 69cde888

parents e3e35dad 69cde888
Loading
Loading
Loading
Loading
+29 −24
Original line number Diff line number Diff line
@@ -308,31 +308,8 @@ void Charger::UpdateScreenState(int64_t now) {
        // If timeout and battery level is still not ready, draw unknown battery
    }

    if (healthd_draw_ == nullptr) {
        std::optional<bool> out_screen_on = configuration_->ChargerShouldKeepScreenOn();
        if (out_screen_on.has_value()) {
            if (!*out_screen_on) {
                LOGV("[%" PRId64 "] leave screen off\n", now);
                batt_anim_.run = false;
                next_screen_transition_ = -1;
                if (configuration_->ChargerIsOnline()) {
                    RequestEnableSuspend();
                }
                return;
            }
        }

        healthd_draw_ = HealthdDraw::Create(&batt_anim_);
    if (healthd_draw_ == nullptr) return;

#if !defined(__ANDROID_VNDK__)
        if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) {
            healthd_draw_->blank_screen(true, static_cast<int>(drm_));
            screen_blanked_ = true;
        }
#endif
    }

    /* animation is over, blank screen and leave */
    if (batt_anim_.num_cycles > 0 && batt_anim_.cur_cycle == batt_anim_.num_cycles) {
        reset_animation(&batt_anim_);
@@ -736,6 +713,33 @@ void Charger::InitAnimation() {
    }
}

void Charger::InitHealthdDraw() {
    if (healthd_draw_ == nullptr) {
        std::optional<bool> out_screen_on = configuration_->ChargerShouldKeepScreenOn();
        if (out_screen_on.has_value()) {
            if (!*out_screen_on) {
                LOGV("[%" PRId64 "] leave screen off\n", curr_time_ms());
                batt_anim_.run = false;
                next_screen_transition_ = -1;
                if (configuration_->ChargerIsOnline()) {
                    RequestEnableSuspend();
                }
                return;
            }
        }

        healthd_draw_ = HealthdDraw::Create(&batt_anim_);
        if (healthd_draw_ == nullptr) return;

#if !defined(__ANDROID_VNDK__)
        if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) {
            healthd_draw_->blank_screen(true, static_cast<int>(drm_));
            screen_blanked_ = true;
        }
#endif
    }
}

void Charger::OnInit(struct healthd_config* config) {
    int ret;
    int i;
@@ -753,6 +757,7 @@ void Charger::OnInit(struct healthd_config* config) {
    }

    InitAnimation();
    InitHealthdDraw();

    ret = CreateDisplaySurface(batt_anim_.fail_file, &surf_unknown_);
    if (ret < 0) {
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ class Charger {
    void HandleInputState(int64_t now);
    void HandlePowerSupplyState(int64_t now);
    int InputCallback(int fd, unsigned int epevents);
    void InitHealthdDraw();
    void InitAnimation();
    int RequestEnableSuspend();
    int RequestDisableSuspend();