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

Commit 92679288 authored by Ken Tsou's avatar Ken Tsou Committed by android-build-merger
Browse files

Merge "charger: fix show 0% symptom when start to draw UI" am: a93a89f4

am: 5052f7db

Change-Id: Icf6c36e86d5b7ab10d86f7c38cbd1173f4f6d964
parents 9f6f6f07 5052f7db
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ void HealthdDraw::redraw_screen(const animation* batt_anim, GRSurface* surf_unkn
    clear_screen();

    /* try to display *something* */
    if (batt_anim->cur_level < 0 || batt_anim->num_frames == 0)
    if (batt_anim->cur_status == BATTERY_STATUS_UNKNOWN || batt_anim->cur_level < 0 ||
        batt_anim->num_frames == 0)
        draw_unknown(surf_unknown);
    else
        draw_battery(batt_anim);
+18 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ char* locale;
#define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC)
#define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC)
#define UNPLUGGED_DISPLAY_TIME (3 * MSEC_PER_SEC)
#define MAX_BATT_LEVEL_WAIT_TIME (3 * MSEC_PER_SEC)

#define LAST_KMSG_MAX_SZ (32 * 1024)

@@ -105,6 +106,7 @@ struct charger {
    int64_t next_screen_transition;
    int64_t next_key_check;
    int64_t next_pwr_check;
    int64_t wait_batt_level_timestamp;

    key_state keys[KEY_MAX + 1];

@@ -290,6 +292,21 @@ static void update_screen_state(charger* charger, int64_t now) {

    if (!batt_anim->run || now < charger->next_screen_transition) return;

    // If battery level is not ready, keep checking in the defined time
    if (batt_prop == nullptr ||
        (batt_prop->batteryLevel == 0 && batt_prop->batteryStatus == BATTERY_STATUS_UNKNOWN)) {
        if (charger->wait_batt_level_timestamp == 0) {
            // Set max delay time and skip drawing screen
            charger->wait_batt_level_timestamp = now + MAX_BATT_LEVEL_WAIT_TIME;
            LOGV("[%" PRId64 "] wait for battery capacity ready\n", now);
            return;
        } else if (now <= charger->wait_batt_level_timestamp) {
            // Do nothing, keep waiting
            return;
        }
        // If timeout and battery level is still not ready, draw unknown battery
    }

    if (healthd_draw == nullptr) {
        if (healthd_config && healthd_config->screen_on) {
            if (!healthd_config->screen_on(batt_prop)) {
@@ -709,6 +726,7 @@ void healthd_mode_charger_init(struct healthd_config* config) {
    charger->next_screen_transition = -1;
    charger->next_key_check = -1;
    charger->next_pwr_check = -1;
    charger->wait_batt_level_timestamp = 0;

    // Initialize Health implementation (which initializes the internal BatteryMonitor).
    Health::initInstance(config);