From 92c260159a6b69f0317d7b66dd11a52772494e48 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 18 Jan 2017 22:54:54 -0800 Subject: [PATCH] healthd: Track the API change of minui/minui.h. ev_init() and ev_iterate_available_keys() now take std::function callback functions. Test: mmma system/core/healthd Change-Id: I8231b57ba816fcba8f698dd7145724021e235664 --- healthd/healthd_mode_charger.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 36c4664c4..2f6937201 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -42,6 +44,7 @@ #include #include #include +#include #ifdef CHARGER_ENABLE_SUSPEND #include @@ -49,7 +52,6 @@ #include "animation.h" #include "AnimationParser.h" -#include "minui/minui.h" #include @@ -563,9 +565,8 @@ static void update_screen_state(struct charger *charger, int64_t now) } } -static int set_key_callback(int code, int value, void *data) +static int set_key_callback(struct charger *charger, int code, int value) { - struct charger *charger = (struct charger *)data; int64_t now = curr_time_ms(); int down = !!value; @@ -600,7 +601,7 @@ static void update_input_state(struct charger *charger, { if (ev->type != EV_KEY) return; - set_key_callback(ev->code, ev->value, charger); + set_key_callback(charger, ev->code, ev->value); } static void set_next_key_check(struct charger *charger, @@ -757,9 +758,8 @@ int healthd_mode_charger_preparetowait(void) return (int)timeout; } -static int input_callback(int fd, unsigned int epevents, void *data) +static int input_callback(struct charger *charger, int fd, unsigned int epevents) { - struct charger *charger = (struct charger *)data; struct input_event ev; int ret; @@ -836,7 +836,8 @@ void healthd_mode_charger_init(struct healthd_config* config) LOGW("--------------- STARTING CHARGER MODE ---------------\n"); - ret = ev_init(input_callback, charger); + ret = ev_init(std::bind(&input_callback, charger, std::placeholders::_1, + std::placeholders::_2)); if (!ret) { epollfd = ev_get_epollfd(); healthd_register_event(epollfd, charger_event_handler); @@ -875,7 +876,8 @@ void healthd_mode_charger_init(struct healthd_config* config) anim->frames[i].surface = scale_frames[i]; } } - ev_sync_key_state(set_key_callback, charger); + ev_sync_key_state(std::bind(&set_key_callback, charger, std::placeholders::_1, + std::placeholders::_2)); charger->next_screen_transition = -1; charger->next_key_check = -1;