summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-09-26 19:44:47 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-09-26 19:44:47 -0700
commita5bfd4e3835b44296896da933ca9484441148ae3 (patch)
tree1a3b43d68f37748310553a7089e405d9f6b83644
parentdf3429de1294de4b3cadfbfcca06e8c9dc4e090d (diff)
parent1a5ca61b28b3269b625b7a7162b4f50734f7fea9 (diff)
downloadsystem_core-a5bfd4e3835b44296896da933ca9484441148ae3.zip
system_core-a5bfd4e3835b44296896da933ca9484441148ae3.tar.gz
system_core-a5bfd4e3835b44296896da933ca9484441148ae3.tar.bz2
am 1a5ca61b: charger: use the new asset for almost full, and show full @ 95%
* commit '1a5ca61b28b3269b625b7a7162b4f50734f7fea9': charger: use the new asset for almost full, and show full @ 95%
-rw-r--r--charger/charger.c29
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 */