• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/core


Commit MetaInfo

修订版926792883660eb986ad214f40554cfba5e3f4c1d (tree)
时间2019-04-01 11:43:26
作者Ken Tsou <kentsou@goog...>
Commiterandroid-build-merger

Log Message

Merge "charger: fix show 0% symptom when start to draw UI" am: a93a89f4bd
am: 5052f7db39

Change-Id: Icf6c36e86d5b7ab10d86f7c38cbd1173f4f6d964

更改概述

差异

--- a/healthd/healthd_draw.cpp
+++ b/healthd/healthd_draw.cpp
@@ -64,7 +64,8 @@ void HealthdDraw::redraw_screen(const animation* batt_anim, GRSurface* surf_unkn
6464 clear_screen();
6565
6666 /* try to display *something* */
67- if (batt_anim->cur_level < 0 || batt_anim->num_frames == 0)
67+ if (batt_anim->cur_status == BATTERY_STATUS_UNKNOWN || batt_anim->cur_level < 0 ||
68+ batt_anim->num_frames == 0)
6869 draw_unknown(surf_unknown);
6970 else
7071 draw_battery(batt_anim);
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -77,6 +77,7 @@ char* locale;
7777 #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC)
7878 #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC)
7979 #define UNPLUGGED_DISPLAY_TIME (3 * MSEC_PER_SEC)
80+#define MAX_BATT_LEVEL_WAIT_TIME (3 * MSEC_PER_SEC)
8081
8182 #define LAST_KMSG_MAX_SZ (32 * 1024)
8283
@@ -105,6 +106,7 @@ struct charger {
105106 int64_t next_screen_transition;
106107 int64_t next_key_check;
107108 int64_t next_pwr_check;
109+ int64_t wait_batt_level_timestamp;
108110
109111 key_state keys[KEY_MAX + 1];
110112
@@ -290,6 +292,21 @@ static void update_screen_state(charger* charger, int64_t now) {
290292
291293 if (!batt_anim->run || now < charger->next_screen_transition) return;
292294
295+ // If battery level is not ready, keep checking in the defined time
296+ if (batt_prop == nullptr ||
297+ (batt_prop->batteryLevel == 0 && batt_prop->batteryStatus == BATTERY_STATUS_UNKNOWN)) {
298+ if (charger->wait_batt_level_timestamp == 0) {
299+ // Set max delay time and skip drawing screen
300+ charger->wait_batt_level_timestamp = now + MAX_BATT_LEVEL_WAIT_TIME;
301+ LOGV("[%" PRId64 "] wait for battery capacity ready\n", now);
302+ return;
303+ } else if (now <= charger->wait_batt_level_timestamp) {
304+ // Do nothing, keep waiting
305+ return;
306+ }
307+ // If timeout and battery level is still not ready, draw unknown battery
308+ }
309+
293310 if (healthd_draw == nullptr) {
294311 if (healthd_config && healthd_config->screen_on) {
295312 if (!healthd_config->screen_on(batt_prop)) {
@@ -709,6 +726,7 @@ void healthd_mode_charger_init(struct healthd_config* config) {
709726 charger->next_screen_transition = -1;
710727 charger->next_key_check = -1;
711728 charger->next_pwr_check = -1;
729+ charger->wait_batt_level_timestamp = 0;
712730
713731 // Initialize Health implementation (which initializes the internal BatteryMonitor).
714732 Health::initInstance(config);