summaryrefslogtreecommitdiff
path: root/cmds/bootanimation/BootAnimation.cpp
diff options
context:
space:
mode:
author niuwenchao <niuwenchao@xiaomi.com> 2022-12-23 17:34:22 +0800
committer wenchao niu <niuwenchao@xiaomi.com> 2023-04-07 02:57:41 +0000
commit9cd6ac8f33180f6c9b54b6fed0b9430bc6007205 (patch)
treede8b90fe4da921edea16f6313517ac10f6bdaf51 /cmds/bootanimation/BootAnimation.cpp
parentde8dd4aabbdaaa1975de2545ce9b0f5e2490ccd9 (diff)
Fix the problem of slow exit of boot animation
When desc.txt configuration interval is very long, it leads to too long sleep time, which affects the execution frequency of checkExit and leads to untimely exit of boot animation. For example: 1080 2400 5 p 0 5 part0 Change-Id: I9806a934189642a31ceb72cbf35c3ff07fe6b7d8 Signed-off-by: niuwenchao <niuwenchao@xiaomi.com>
Diffstat (limited to 'cmds/bootanimation/BootAnimation.cpp')
-rw-r--r--cmds/bootanimation/BootAnimation.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index 6b6bc9728b7f..27dadda40407 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -107,6 +107,7 @@ static const char PROGRESS_PROP_NAME[] = "service.bootanim.progress";
static const char DISPLAYS_PROP_NAME[] = "persist.service.bootanim.displays";
static const char CLOCK_ENABLED_PROP_NAME[] = "persist.sys.bootanim.clock.enabled";
static const int ANIM_ENTRY_NAME_MAX = ANIM_PATH_MAX + 1;
+static const int MAX_CHECK_EXIT_INTERVAL_US = 50000;
static constexpr size_t TEXT_POS_LEN_MAX = 16;
static const int DYNAMIC_COLOR_COUNT = 4;
static const char U_TEXTURE[] = "uTexture";
@@ -1680,7 +1681,17 @@ bool BootAnimation::playAnimation(const Animation& animation) {
checkExit();
}
- usleep(part.pause * ns2us(frameDuration));
+ int pauseDuration = part.pause * ns2us(frameDuration);
+ while(pauseDuration > 0 && !exitPending()){
+ if (pauseDuration > MAX_CHECK_EXIT_INTERVAL_US) {
+ usleep(MAX_CHECK_EXIT_INTERVAL_US);
+ pauseDuration -= MAX_CHECK_EXIT_INTERVAL_US;
+ } else {
+ usleep(pauseDuration);
+ break;
+ }
+ checkExit();
+ }
if (exitPending() && !part.count && mCurrentInset >= mTargetInset &&
!part.hasFadingPhase()) {