diff options
author | Dima Zavin <dima@android.com> | 2011-09-26 14:14:19 -0700 |
---|---|---|
committer | Dima Zavin <dima@android.com> | 2011-09-26 14:14:19 -0700 |
commit | 1a5ca61b28b3269b625b7a7162b4f50734f7fea9 (patch) | |
tree | 5652d191a3b39b865bea2a8724866875cdb652f7 /charger/charger.c | |
parent | fc44f5f4d4b3b05d9eba1ee787b70e1dfe0f18c5 (diff) | |
download | system_core-1a5ca61b28b3269b625b7a7162b4f50734f7fea9.zip system_core-1a5ca61b28b3269b625b7a7162b4f50734f7fea9.tar.gz system_core-1a5ca61b28b3269b625b7a7162b4f50734f7fea9.tar.bz2 |
charger: use the new asset for almost full, and show full @ 95%
Change-Id: I5f8729260ae068d35d981ff2c16d576c3d4dd82f
Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'charger/charger.c')
-rw-r--r-- | charger/charger.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/charger/charger.c b/charger/charger.c index 595bb66..0ade250 100644 --- a/charger/charger.c +++ b/charger/charger.c @@ -58,6 +58,8 @@ #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) #define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) +#define BATTERY_FULL_THRESH 95 + #define LOGE(x...) do { KLOG_ERROR("charger", x); } while (0) #define LOGI(x...) do { KLOG_INFO("charger", x); } while (0) #define LOGV(x...) do { KLOG_DEBUG("charger", x); } while (0) @@ -152,6 +154,11 @@ static struct frame batt_anim_frames[] = { .disp_time = 750, .min_capacity = 80, }, + { + .name = "charger/battery_5", + .disp_time = 750, + .min_capacity = BATTERY_FULL_THRESH, + }, }; static struct animation battery_animation = { @@ -231,6 +238,22 @@ err: return -1; } +static int get_battery_capacity(struct charger *charger) +{ + int ret; + int batt_cap = -1; + + if (!charger->battery) + return -1; + + ret = read_file_int(charger->battery->cap_path, &batt_cap); + if (ret < 0 || batt_cap > 100) { + batt_cap = -1; + } + + return batt_cap; +} + static struct power_supply *find_supply(struct charger *charger, const char *name) { @@ -619,10 +642,8 @@ static void update_screen_state(struct charger *charger, int64_t now) int ret; LOGV("[%lld] animation starting\n", now); - ret = read_file_int(charger->battery->cap_path, &batt_cap); - if (ret < 0 || batt_cap > 100) { - batt_cap = -1; - } else if (batt_anim->num_frames != 0) { + batt_cap = get_battery_capacity(charger); + if (batt_cap >= 0 && batt_anim->num_frames != 0) { int i; /* find first frame given current capacity */ |