Loading healthd/healthd_draw.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,8 @@ void HealthdDraw::redraw_screen(const animation* batt_anim, GRSurface* surf_unkn clear_screen(); clear_screen(); /* try to display *something* */ /* 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); draw_unknown(surf_unknown); else else draw_battery(batt_anim); draw_battery(batt_anim); Loading healthd/healthd_mode_charger.cpp +18 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ char* locale; #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) #define UNPLUGGED_DISPLAY_TIME (3 * 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) #define LAST_KMSG_MAX_SZ (32 * 1024) Loading Loading @@ -105,6 +106,7 @@ struct charger { int64_t next_screen_transition; int64_t next_screen_transition; int64_t next_key_check; int64_t next_key_check; int64_t next_pwr_check; int64_t next_pwr_check; int64_t wait_batt_level_timestamp; key_state keys[KEY_MAX + 1]; key_state keys[KEY_MAX + 1]; Loading Loading @@ -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 (!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_draw == nullptr) { if (healthd_config && healthd_config->screen_on) { if (healthd_config && healthd_config->screen_on) { if (!healthd_config->screen_on(batt_prop)) { if (!healthd_config->screen_on(batt_prop)) { Loading Loading @@ -709,6 +726,7 @@ void healthd_mode_charger_init(struct healthd_config* config) { charger->next_screen_transition = -1; charger->next_screen_transition = -1; charger->next_key_check = -1; charger->next_key_check = -1; charger->next_pwr_check = -1; charger->next_pwr_check = -1; charger->wait_batt_level_timestamp = 0; // Initialize Health implementation (which initializes the internal BatteryMonitor). // Initialize Health implementation (which initializes the internal BatteryMonitor). Health::initInstance(config); Health::initInstance(config); Loading Loading
healthd/healthd_draw.cpp +2 −1 Original line number Original line Diff line number Diff line Loading @@ -64,7 +64,8 @@ void HealthdDraw::redraw_screen(const animation* batt_anim, GRSurface* surf_unkn clear_screen(); clear_screen(); /* try to display *something* */ /* 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); draw_unknown(surf_unknown); else else draw_battery(batt_anim); draw_battery(batt_anim); Loading
healthd/healthd_mode_charger.cpp +18 −0 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ char* locale; #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) #define UNPLUGGED_DISPLAY_TIME (3 * 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) #define LAST_KMSG_MAX_SZ (32 * 1024) Loading Loading @@ -105,6 +106,7 @@ struct charger { int64_t next_screen_transition; int64_t next_screen_transition; int64_t next_key_check; int64_t next_key_check; int64_t next_pwr_check; int64_t next_pwr_check; int64_t wait_batt_level_timestamp; key_state keys[KEY_MAX + 1]; key_state keys[KEY_MAX + 1]; Loading Loading @@ -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 (!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_draw == nullptr) { if (healthd_config && healthd_config->screen_on) { if (healthd_config && healthd_config->screen_on) { if (!healthd_config->screen_on(batt_prop)) { if (!healthd_config->screen_on(batt_prop)) { Loading Loading @@ -709,6 +726,7 @@ void healthd_mode_charger_init(struct healthd_config* config) { charger->next_screen_transition = -1; charger->next_screen_transition = -1; charger->next_key_check = -1; charger->next_key_check = -1; charger->next_pwr_check = -1; charger->next_pwr_check = -1; charger->wait_batt_level_timestamp = 0; // Initialize Health implementation (which initializes the internal BatteryMonitor). // Initialize Health implementation (which initializes the internal BatteryMonitor). Health::initInstance(config); Health::initInstance(config); Loading