summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--healthd/healthd.cpp3
-rw-r--r--healthd/healthd.h16
-rw-r--r--healthd/healthd_board_default.cpp20
-rw-r--r--healthd/healthd_mode_charger.cpp40
4 files changed, 68 insertions, 11 deletions
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp
index d8f671a..c3de13c 100644
--- a/healthd/healthd.cpp
+++ b/healthd/healthd.cpp
@@ -374,6 +374,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 3ca1953..0b2a16e 100644
--- a/healthd/healthd.h
+++ b/healthd/healthd.h
@@ -155,4 +155,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();