diff options
| author | Ruchi Kandoi <kandoiruchi@google.com> | 2014-09-25 19:44:42 -0700 |
|---|---|---|
| committer | Ruchi Kandoi <kandoiruchi@google.com> | 2014-09-26 14:37:17 -0700 |
| commit | bdf11c76a39d979abd105a4f27bc1973b88893ad (patch) | |
| tree | 44cbc7e59b8069e7d27339679d047e2497ba1a1d /healthd | |
| parent | ea52030bc6819c7ea6ffc921df9c3f13b7f8b94c (diff) | |
| download | system_core-bdf11c76a39d979abd105a4f27bc1973b88893ad.zip system_core-bdf11c76a39d979abd105a4f27bc1973b88893ad.tar.gz system_core-bdf11c76a39d979abd105a4f27bc1973b88893ad.tar.bz2 | |
healthd: Add callback for screen_on to the healthdHAL
Adds a callback to the healthdHAL which can check for device specific
properties to decide if the screen should turn on.
Change-Id: I543e7729ecb291157df4d3be1bd718f8af01ac40
Signed-off-by: Ruchi Kandoi<kandoiruchi@google.com>
Diffstat (limited to 'healthd')
| -rw-r--r-- | healthd/healthd.cpp | 3 | ||||
| -rw-r--r-- | healthd/healthd.h | 1 | ||||
| -rw-r--r-- | healthd/healthd_mode_charger.cpp | 44 |
3 files changed, 22 insertions, 26 deletions
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp index 30a4b42..f4171bd 100644 --- a/healthd/healthd.cpp +++ b/healthd/healthd.cpp @@ -53,6 +53,7 @@ static struct healthd_config healthd_config = { .batteryCurrentAvgPath = String8(String8::kEmptyString), .batteryChargeCounterPath = String8(String8::kEmptyString), .energyCounter = NULL, + .screen_on = NULL, }; static int eventct; @@ -314,8 +315,8 @@ static int healthd_init() { return -1; } - healthd_mode_ops->init(&healthd_config); healthd_board_init(&healthd_config); + healthd_mode_ops->init(&healthd_config); wakealarm_init(); uevent_init(); gBatteryMonitor = new BatteryMonitor(); diff --git a/healthd/healthd.h b/healthd/healthd.h index 972e728..4704f0b 100644 --- a/healthd/healthd.h +++ b/healthd/healthd.h @@ -67,6 +67,7 @@ struct healthd_config { android::String8 batteryChargeCounterPath; int (*energyCounter)(int64_t *); + bool (*screen_on)(android::BatteryProperties *props); }; // Global helper functions diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index fd5cecf..5039649 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -68,7 +68,6 @@ char *locale; #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) #define BATTERY_FULL_THRESH 95 -#define SCREEN_ON_BATTERY_THRESH 0 #define LAST_KMSG_PATH "/proc/last_kmsg" #define LAST_KMSG_PSTORE_PATH "/sys/fs/pstore/console-ramoops" @@ -109,7 +108,6 @@ struct animation { struct charger { bool have_battery_state; bool charger_connected; - int capacity; int64_t next_screen_transition; int64_t next_key_check; int64_t next_pwr_check; @@ -170,7 +168,8 @@ static struct animation battery_animation = { }; static struct charger charger_state; - +static struct healthd_config *healthd_config; +static struct android::BatteryProperties *batt_prop; static int char_width; static int char_height; static bool minui_inited; @@ -240,11 +239,6 @@ out: LOGW("\n"); } -static int get_battery_capacity() -{ - return charger_state.capacity; -} - #ifdef CHARGER_ENABLE_SUSPEND static int request_suspend(bool enable) { @@ -357,15 +351,16 @@ static void update_screen_state(struct charger *charger, int64_t now) return; if (!minui_inited) { - int batt_cap = get_battery_capacity(); - - if (batt_cap < SCREEN_ON_BATTERY_THRESH) { - LOGV("[%" PRId64 "] 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; + + if (healthd_config && healthd_config->screen_on) { + if (!healthd_config->screen_on(batt_prop)) { + LOGV("[%" PRId64 "] leave screen off\n", now); + batt_anim->run = false; + charger->next_screen_transition = -1; + if (charger->charger_connected) + request_suspend(true); + return; + } } gr_init(); @@ -392,17 +387,15 @@ static void update_screen_state(struct charger *charger, int64_t now) /* animation starting, set up the animation */ if (batt_anim->cur_frame == 0) { - int batt_cap; int ret; LOGV("[%" PRId64 "] animation starting\n", now); - batt_cap = get_battery_capacity(); - if (batt_cap >= 0 && batt_anim->num_frames != 0) { + if (batt_prop && batt_prop->batteryLevel >= 0 && batt_anim->num_frames != 0) { int i; /* find first frame given current capacity */ for (i = 1; i < batt_anim->num_frames; i++) { - if (batt_cap < batt_anim->frames[i].min_capacity) + if (batt_prop->batteryLevel < batt_anim->frames[i].min_capacity) break; } batt_anim->cur_frame = i - 1; @@ -410,8 +403,8 @@ static void update_screen_state(struct charger *charger, int64_t now) /* show the first frame for twice as long */ disp_time = batt_anim->frames[batt_anim->cur_frame].disp_time * 2; } - - batt_anim->capacity = batt_cap; + if (batt_prop) + batt_anim->capacity = batt_prop->batteryLevel; } /* unblank the screen on first cycle */ @@ -609,7 +602,6 @@ void healthd_mode_charger_battery_update( charger->charger_connected = props->chargerAcOnline || props->chargerUsbOnline || props->chargerWirelessOnline; - charger->capacity = props->batteryLevel; if (!charger->have_battery_state) { charger->have_battery_state = true; @@ -617,6 +609,7 @@ void healthd_mode_charger_battery_update( reset_animation(charger->batt_anim); kick_animation(charger->batt_anim); } + batt_prop = props; } int healthd_mode_charger_preparetowait(void) @@ -669,7 +662,7 @@ static void charger_event_handler(uint32_t /*epevents*/) ev_dispatch(); } -void healthd_mode_charger_init(struct healthd_config* /*config*/) +void healthd_mode_charger_init(struct healthd_config* config) { int ret; struct charger *charger = &charger_state; @@ -717,4 +710,5 @@ void healthd_mode_charger_init(struct healthd_config* /*config*/) charger->next_screen_transition = -1; charger->next_key_check = -1; charger->next_pwr_check = -1; + healthd_config = config; } |
