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

Commit 690c6f53 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Re-evaluate scrim color on keyguard vis event

The color of the scrims depends on the keyguard visibility.
This CL fixes a race condition where the keyguard state would be
delayed causing the scrim color to be wrong.

Test: unlock device with fp multiple times (unlock to activity)
Fixes: 110994792
Change-Id: I4715159b961fa7c989bfdca9088229bff40054aa
parent 81926cfb
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final DozeParameters mDozeParameters;
    private final AlarmTimeout mTimeTicker;
    private final KeyguardVisibilityCallback mKeyguardVisibilityCallback;

    private final SysuiColorExtractor mColorExtractor;
    private GradientColors mLockColors;
@@ -171,6 +172,8 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        mUnlockMethodCache = UnlockMethodCache.getInstance(mContext);
        mDarkenWhileDragging = !mUnlockMethodCache.canSkipBouncer();
        mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
        mKeyguardVisibilityCallback = new KeyguardVisibilityCallback();
        mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback);
        mScrimBehindAlphaResValue = mContext.getResources().getFloat(R.dimen.scrim_behind_alpha);
        mTimeTicker = new AlarmTimeout(alarmManager, this::onHideWallpaperTimeout,
                "hide_aod_wallpaper", new Handler());
@@ -910,4 +913,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        default void onCancelled() {
        }
    }

    /**
     * Simple keyguard callback that updates scrims when keyguard visibility changes.
     */
    private class KeyguardVisibilityCallback extends KeyguardUpdateMonitorCallback {

        @Override
        public void onKeyguardVisibilityChanged(boolean showing) {
            mNeedsDrawableColorUpdate = true;
            scheduleUpdate();
        }
    }
}