From 9cc4ea329fd63ecd8a5764b1762c1574904842f6 Mon Sep 17 00:00:00 2001 From: Jenny TC Date: Wed, 30 Apr 2014 08:12:11 +0530 Subject: [PATCH] Charger: Avoid animation while not charging DO NOT MERGE At present, charging animation runs irrespective of whether charger is connected or not. When the charger is disconnected, device not shutdown for 10secs. Charging animation during this period should be avoided. Change-Id: Idf8e6a11261aec2812f1ebbbdec1bd1ad769565e Signed-off-by: Pavan Kumar S Signed-off-by: Jenny TC Signed-off-by: Yong Yao --- charger/charger.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/charger/charger.c b/charger/charger.c index 15add87d0..47b1c0754 100644 --- a/charger/charger.c +++ b/charger/charger.c @@ -751,24 +751,33 @@ static void update_screen_state(struct charger *charger, int64_t now) /* schedule next screen transition */ charger->next_screen_transition = now + disp_time; - /* advance frame cntr to the next valid frame + /* advance frame cntr to the next valid frame only if we are charging * if necessary, advance cycle cntr, and reset frame cntr */ - batt_anim->cur_frame++; - - /* if the frame is used for level-only, that is only show it when it's - * the current level, skip it during the animation. - */ - while (batt_anim->cur_frame < batt_anim->num_frames && - batt_anim->frames[batt_anim->cur_frame].level_only) + if (charger->num_supplies_online != 0) { batt_anim->cur_frame++; - if (batt_anim->cur_frame >= batt_anim->num_frames) { - batt_anim->cur_cycle++; - batt_anim->cur_frame = 0; + + /* if the frame is used for level-only, that is only show it when it's + * the current level, skip it during the animation. + */ + while (batt_anim->cur_frame < batt_anim->num_frames && + batt_anim->frames[batt_anim->cur_frame].level_only) + batt_anim->cur_frame++; + if (batt_anim->cur_frame >= batt_anim->num_frames) { + batt_anim->cur_cycle++; + batt_anim->cur_frame = 0; /* don't reset the cycle counter, since we use that as a signal * in a test above to check if animation is over */ + } + } else { + /* Stop animating if we're not charging. + * If we stop it immediately instead of going through this loop, then + * the animation would stop somewhere in the middle. + */ + batt_anim->cur_frame = 0; + batt_anim->cur_cycle++; } }