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

Commit 52b2f003 authored by András Kurucz's avatar András Kurucz
Browse files

Don't set negative alpha values for the KeyguardBottomArea

Sometimes the NSSL#updateKeyguardBottomAreaAlpha() was calculating
negative alpha values. This resulted in the KeyguardIndicationAreaBinder
and the KeyguardBottomAreaViewBinder setting an invalid alpha value, and
toggleing the importantForAccessibility property on their views.

This CL removes these unnecessary updates, and hopefully helps with
reducing some jank.

Test: atest NotificationPanelViewControllerWithCoroutinesTest
Bug: 296578272
Change-Id: I339cbd2b4522a24345f430cb4f6a5f1a4579a02c
parent 6c497788
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -2312,7 +2312,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        return mKeyguardInteractor.getWakefulnessModel().getValue();
    }

    private void maybeAnimateBottomAreaAlpha() {
    @VisibleForTesting
    void maybeAnimateBottomAreaAlpha() {
        mBottomAreaShadeAlphaAnimator.cancel();
        if (mBarState == StatusBarState.SHADE_LOCKED) {
            mBottomAreaShadeAlphaAnimator.setFloatValues(mBottomAreaShadeAlpha, 0.0f);
@@ -2674,10 +2675,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        // • User tapping on lock screen: bouncer won't be visible but panel expansion will
        //   change due to "unlock hint animation." In this case, fading out the bottom area
        //   would also hide the message that says "swipe to unlock," we don't want to do that.
        float expansionAlpha = MathUtils.map(
                isUnlockHintRunning() ? 0 : KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f,
                0f, 1f,
        float expansionAlpha = MathUtils.constrainedMap(0f, 1f,
                isUnlockHintRunning() ? 0f : KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f,
                getExpandedFraction());

        float alpha = Math.min(expansionAlpha, 1 - mQsController.computeExpansionFraction());
        alpha *= mBottomAreaShadeAlpha;
        if (mFeatureFlags.isEnabled(Flags.MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA)) {
+28 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import androidx.test.filters.SmallTest
import com.android.internal.util.CollectionUtils
import com.android.keyguard.KeyguardClockSwitch.LARGE
import com.android.systemui.R
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags.ONE_WAY_HAPTICS_API_MIGRATION
import com.android.systemui.statusbar.StatusBarState.KEYGUARD
import com.android.systemui.statusbar.StatusBarState.SHADE
@@ -261,4 +262,31 @@ class NotificationPanelViewControllerWithCoroutinesTest :
        }
        advanceUntilIdle()
    }

    @Test
    fun onLayoutChange_shadeCollapsed_bottomAreaAlphaIsZero() = runTest {
        // GIVEN bottomAreaShadeAlpha was updated before
        mNotificationPanelViewController.maybeAnimateBottomAreaAlpha()

        // WHEN a layout change is triggered with the shade being closed
        triggerLayoutChange()

        // THEN the bottomAreaAlpha is zero
        val bottomAreaAlpha by collectLastValue(mFakeKeyguardRepository.bottomAreaAlpha)
        assertThat(bottomAreaAlpha).isEqualTo(0f)
    }

    @Test
    fun onShadeExpanded_bottomAreaAlphaIsFullyOpaque() = runTest {
        // GIVEN bottomAreaShadeAlpha was updated before
        mNotificationPanelViewController.maybeAnimateBottomAreaAlpha()

        // WHEN the shade expanded
        val transitionDistance = mNotificationPanelViewController.maxPanelTransitionDistance
        mNotificationPanelViewController.expandedHeight = transitionDistance.toFloat()

        // THEN the bottomAreaAlpha is fully opaque
        val bottomAreaAlpha by collectLastValue(mFakeKeyguardRepository.bottomAreaAlpha)
        assertThat(bottomAreaAlpha).isEqualTo(1f)
    }
}