From bfd1812fcbcada2dfb1bc9846c0b131658ec2b85 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 25 Apr 2022 11:26:08 -0700 Subject: Try to load colors more frequently During OTA, sysprops aren't available as early in the boot process. This causes the boot animation to not have dynamic colors. This CL tries to load the colors more frequently, at every part loop. Before we'd only try on the first frame of each animation part. Test: adb shell bootanimation Fixes: 229029861 Change-Id: I1bbebf93b4fbc31d945c4181472576cf29f13bc7 --- cmds/bootanimation/BootAnimation.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'cmds/bootanimation/BootAnimation.cpp') diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index fb68c6d84d6a..50c8e933d25f 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -1459,6 +1459,8 @@ bool BootAnimation::playAnimation(const Animation& animation) { int fadedFramesCount = 0; int lastDisplayedProgress = 0; + int colorTransitionStart = animation.colorTransitionStart; + int colorTransitionEnd = animation.colorTransitionEnd; for (size_t i=0 ; i 0 ; r++) { if (shouldStopPlayingPart(part, fadedFramesCount, lastDisplayedProgress)) break; + // It's possible that the sysprops were not loaded yet at this boot phase. + // If that's the case, then we should keep trying until they are available. + if (animation.dynamicColoringEnabled && !mDynamicColorsApplied + && (part.useDynamicColoring || part.postDynamicColoring)) { + SLOGD("Trying to load dynamic color sysprops."); + initDynamicColors(); + if (mDynamicColorsApplied) { + // Sysprops were loaded. Next step is to adjust the animation if we loaded + // the colors after the animation should have started. + const int transitionLength = colorTransitionEnd - colorTransitionStart; + if (part.postDynamicColoring) { + colorTransitionStart = 0; + colorTransitionEnd = fmin(transitionLength, fcount - 1); + } + } + } + mCallbacks->playPart(i, part, r); glClearColor( @@ -1509,9 +1523,8 @@ bool BootAnimation::playAnimation(const Animation& animation) { // - 1 for parts that come after. float colorProgress = part.useDynamicColoring ? fmin(fmax( - ((float)j - animation.colorTransitionStart) / - fmax(animation.colorTransitionEnd - - animation.colorTransitionStart, 1.0f), 0.0f), 1.0f) + ((float)j - colorTransitionStart) / + fmax(colorTransitionEnd - colorTransitionStart, 1.0f), 0.0f), 1.0f) : (part.postDynamicColoring ? 1 : 0); processDisplayEvents(); -- cgit v1.2.3-59-g8ed1b