Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf4646bf authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Fix race condition in GradientDrawable

Animation would be able to override subsequent setColors
if the color request was the same as the one in the current frame.

Test: Set lock wallpaper to black, lock device
Test: Unlock device, look at scrims
Change-Id: I22fa390bdc6d39eaf09974fcbc5f60bbc46f4f66
parent ea296350
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ public class GradientDrawable extends Drawable {
    private int mMainColor;
    private int mSecondaryColor;
    private ValueAnimator mColorAnimation;
    private int mMainColorTo;
    private int mSecondaryColorTo;

    public GradientDrawable(@NonNull Context context) {
        mDensity = context.getResources().getDisplayMetrics().density;
@@ -76,7 +78,7 @@ public class GradientDrawable extends Drawable {
    }

    public void setColors(int mainColor, int secondaryColor, boolean animated) {
        if (mainColor == mMainColor && secondaryColor == mSecondaryColor) {
        if (mainColor == mMainColorTo && secondaryColor == mSecondaryColorTo) {
            return;
        }

@@ -84,6 +86,9 @@ public class GradientDrawable extends Drawable {
            mColorAnimation.cancel();
        }

        mMainColorTo = mainColor;
        mSecondaryColorTo = mainColor;

        if (animated) {
            final int mainFrom = mMainColor;
            final int secFrom = mSecondaryColor;