diff options
author | Chunmei Cai <ccai@codeaurora.org> | 2015-09-06 15:43:32 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-10-07 19:12:22 -0700 |
commit | f10412c2d00547b82d26461c71a032d083562e5d (patch) | |
tree | 9fe30ab5e91a6e7a5e0cd5f43e8a89aa3d69068a | |
parent | 6013e8d811510fe5fd87938e69c7918d6728105c (diff) | |
download | system_core-f10412c2d00547b82d26461c71a032d083562e5d.zip system_core-f10412c2d00547b82d26461c71a032d083562e5d.tar.gz system_core-f10412c2d00547b82d26461c71a032d083562e5d.tar.bz2 |
healthd: charger: Add board overrides in mode_charger
Add following overrides in mode_charger to improve the off-mode charging
user experience:
1. Draw battery information on the animation, such as: capacity;
2. Handle board specific battery status update;
3. Handle board specific mode charger initialization;
4. Turn on/off the backlight explicitely;
5. Reduce the unplugged shutdown delay to 1 seccond;
6. Do a period chorse and then heartbeat to reduce the animation boot
time.
Change-Id: Ic2b7ab6deeb52c4effe3b4af9b590950d5ee97f1
-rw-r--r-- | healthd/healthd.cpp | 3 | ||||
-rw-r--r-- | healthd/healthd.h | 16 | ||||
-rw-r--r-- | healthd/healthd_board_default.cpp | 20 | ||||
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 40 |
4 files changed, 68 insertions, 11 deletions
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp index b0002cc..452cc25 100644 --- a/healthd/healthd.cpp +++ b/healthd/healthd.cpp @@ -357,6 +357,9 @@ int main(int argc, char **argv) { exit(2); } + periodic_chores(); + healthd_mode_ops->heartbeat(); + healthd_mainloop(); KLOG_ERROR("Main loop terminated, exiting\n"); return 3; diff --git a/healthd/healthd.h b/healthd/healthd.h index 84b6d76..b9ffb35 100644 --- a/healthd/healthd.h +++ b/healthd/healthd.h @@ -121,4 +121,20 @@ void healthd_board_init(struct healthd_config *config); int healthd_board_battery_update(struct android::BatteryProperties *props); +//This API is called to turn on/off the display backlight incase it can't be +//handle correcty in the display driver by calling gr_fg_blank(); +void healthd_board_mode_charger_set_backlight(bool en); + +//This API is called to update the battery/charging status by using the user +//noticeable method other then the animation, such as: LEDs +void healthd_board_mode_charger_battery_update(struct android::BatteryProperties *batt_prop); + +//This API is used to handle some board specific charger mode initialization, +//such as: checking the charging is enabled or not. +void healthd_board_mode_charger_init(void); + +//This API is called in the draw_battery() function to draw more infomation +//about the battery on the animation, such as the SoC (State of Charge). +void healthd_board_mode_charger_draw_battery(struct android::BatteryProperties *batt_prop); + #endif /* _HEALTHD_H_ */ diff --git a/healthd/healthd_board_default.cpp b/healthd/healthd_board_default.cpp index ed4ddb4..81733fe 100644 --- a/healthd/healthd_board_default.cpp +++ b/healthd/healthd_board_default.cpp @@ -27,3 +27,23 @@ int healthd_board_battery_update(struct android::BatteryProperties*) // return 0 to log periodic polled battery status to kernel log return 0; } + +void healthd_board_mode_charger_draw_battery(struct android::BatteryProperties*) +{ + +} + +void healthd_board_mode_charger_battery_update(struct android::BatteryProperties*) +{ + +} + +void healthd_board_mode_charger_set_backlight(bool) +{ + +} + +void healthd_board_mode_charger_init() +{ + +} diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 6800ad2..355c638 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -65,7 +65,7 @@ char *locale; #define BATTERY_UNKNOWN_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 (1 * MSEC_PER_SEC) #define BATTERY_FULL_THRESH 95 @@ -314,6 +314,7 @@ static void draw_battery(struct charger *charger) batt_anim->cur_frame, frame->min_capacity, frame->disp_time); } + healthd_board_mode_charger_draw_battery(batt_prop); } static void redraw_screen(struct charger *charger) @@ -367,6 +368,7 @@ static void update_screen_state(struct charger *charger, int64_t now) gr_font_size(&char_width, &char_height); #ifndef CHARGER_DISABLE_INIT_BLANK + healthd_board_mode_charger_set_backlight(false); gr_fb_blank(true); #endif minui_inited = true; @@ -376,6 +378,7 @@ static void update_screen_state(struct charger *charger, int64_t now) if (batt_anim->cur_cycle == batt_anim->num_cycles) { reset_animation(batt_anim); charger->next_screen_transition = -1; + healthd_board_mode_charger_set_backlight(false); gr_fb_blank(true); LOGV("[%" PRId64 "] animation done\n", now); if (charger->charger_connected) @@ -406,9 +409,11 @@ static void update_screen_state(struct charger *charger, int64_t now) batt_anim->capacity = batt_prop->batteryLevel; } - /* unblank the screen on first cycle */ - if (batt_anim->cur_cycle == 0) + /* unblank the screen on first cycle */ + if (batt_anim->cur_cycle == 0) { gr_fb_blank(false); + healthd_board_mode_charger_set_backlight(true); + } /* draw the new frame (@ cur_frame) */ redraw_screen(charger); @@ -508,6 +513,7 @@ static void set_next_key_check(struct charger *charger, static void process_key(struct charger *charger, int code, int64_t now) { + struct animation *batt_anim = charger->batt_anim; struct key_state *key = &charger->keys[code]; if (code == KEY_POWER) { @@ -534,17 +540,25 @@ static void process_key(struct charger *charger, int code, int64_t now) * make sure we wake up at the right-ish time to check */ set_next_key_check(charger, key, POWER_ON_KEY_TIME); - - /* Turn on the display and kick animation on power-key press - * rather than on key release - */ - kick_animation(charger->batt_anim); - request_suspend(false); } } else { - /* if the power key got released, force screen state cycle */ if (key->pending) { - kick_animation(charger->batt_anim); + /* If key is pressed when the animation is not running, kick + * the animation and quite suspend; If key is pressed when + * the animation is running, turn off the animation and request + * suspend. + */ + if (!batt_anim->run) { + kick_animation(batt_anim); + request_suspend(false); + } else { + reset_animation(batt_anim); + charger->next_screen_transition = -1; + healthd_board_mode_charger_set_backlight(false); + gr_fb_blank(true); + if (charger->charger_connected) + request_suspend(true); + } } } } @@ -565,6 +579,8 @@ static void handle_power_supply_state(struct charger *charger, int64_t now) if (!charger->have_battery_state) return; + healthd_board_mode_charger_battery_update(batt_prop); + if (!charger->charger_connected) { /* Last cycle would have stopped at the extreme top of battery-icon @@ -683,6 +699,8 @@ void healthd_mode_charger_init(struct healthd_config* config) LOGW("--------------- STARTING CHARGER MODE ---------------\n"); + healthd_board_mode_charger_init(); + ret = ev_init(input_callback, charger); if (!ret) { epollfd = ev_get_epollfd(); |