diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2014-06-23 20:59:32 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-06-23 17:14:09 +0000 |
commit | 62ecd51f8a5435e925382ee1f0064655b75cc936 (patch) | |
tree | f87cd8b2908a7d67d9b7ca6648c73e607fd67575 | |
parent | e6d567bd106de30e97d33a8b93b967ada5edd328 (diff) | |
parent | 9015eaa30fec3b5763e49124d7aa822862261842 (diff) | |
download | system_core-62ecd51f8a5435e925382ee1f0064655b75cc936.zip system_core-62ecd51f8a5435e925382ee1f0064655b75cc936.tar.gz system_core-62ecd51f8a5435e925382ee1f0064655b75cc936.tar.bz2 |
Merge "healthd: Avoid animation while not charging."
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index cfac312..86610b2 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -409,24 +409,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->charger_connected) { 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 + /* 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++; } } |