summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2014-07-01 17:41:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-30 22:50:32 +0000
commitecedc9a6977c69bf742569a450840061c047fa6b (patch)
tree491295b0effd0b5b61e87cfe3549f5043f5c3bd2 /healthd
parent0c3664f08dd5bfa786b3fe82ed2343c7989d35dd (diff)
parenta7300274fdc5c92144471b1fe6dd19a8d18ae393 (diff)
downloadsystem_core-ecedc9a6977c69bf742569a450840061c047fa6b.zip
system_core-ecedc9a6977c69bf742569a450840061c047fa6b.tar.gz
system_core-ecedc9a6977c69bf742569a450840061c047fa6b.tar.bz2
Merge "charger: leave screen off when entered with very low battery"
Diffstat (limited to 'healthd')
-rw-r--r--healthd/healthd_mode_charger.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index d11f609..43f6640 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -68,6 +68,7 @@ char *locale;
#define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC)
#define BATTERY_FULL_THRESH 95
+#define SCREEN_ON_BATTERY_THRESH 1
#define LAST_KMSG_PATH "/proc/last_kmsg"
#define LAST_KMSG_PSTORE_PATH "/sys/fs/pstore/console-ramoops"
@@ -172,6 +173,7 @@ static struct charger charger_state;
static int char_width;
static int char_height;
+static bool minui_inited;
/* current time in milliseconds */
static int64_t curr_time_ms(void)
@@ -354,6 +356,27 @@ static void update_screen_state(struct charger *charger, int64_t now)
if (!batt_anim->run || now < charger->next_screen_transition)
return;
+ if (!minui_inited) {
+ int batt_cap = get_battery_capacity();
+
+ if (batt_cap < SCREEN_ON_BATTERY_THRESH) {
+ LOGV("[%lld] level %d, leave screen off\n", now, batt_cap);
+ batt_anim->run = false;
+ charger->next_screen_transition = -1;
+ if (charger->charger_connected)
+ request_suspend(true);
+ return;
+ }
+
+ gr_init();
+ gr_font_size(&char_width, &char_height);
+
+#ifndef CHARGER_DISABLE_INIT_BLANK
+ gr_fb_blank(true);
+#endif
+ minui_inited = true;
+ }
+
/* animation is over, blank screen and leave */
if (batt_anim->cur_cycle == batt_anim->num_cycles) {
reset_animation(batt_anim);
@@ -657,9 +680,6 @@ void healthd_mode_charger_init(struct healthd_config* /*config*/)
LOGI("--------------- STARTING CHARGER MODE ---------------\n");
- gr_init();
- gr_font_size(&char_width, &char_height);
-
ret = ev_init(input_callback, charger);
if (!ret) {
epollfd = ev_get_epollfd();
@@ -694,10 +714,6 @@ void healthd_mode_charger_init(struct healthd_config* /*config*/)
ev_sync_key_state(set_key_callback, charger);
-#ifndef CHARGER_DISABLE_INIT_BLANK
- gr_fb_blank(true);
-#endif
-
charger->next_screen_transition = -1;
charger->next_key_check = -1;
charger->next_pwr_check = -1;