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

Commit e93d18f8 authored by Yining Liu's avatar Yining Liu
Browse files

Fix the notification content view alpha regression

Fixes the notification content view alpha regression caused by fixing
the alpha flicker during HUN appearing animation. We should limit the
reset of view sensitiveness and only do it when it's actually needed.

Fix: 342212697
Flag: com.android.systemui.notification_content_alpha_optimization
Test: atest PlatformScenarioTests:android.platform.test.scenario.sysui.notification.SensitiveNotificationProtectionWith50BigPictureNotificationsMicrobenchmark -- --test-arg com.android.tradefed.testtype.AndroidJUnitTest:device-listeners:android.device.collectors.UiInteractionFrameInfoListener,android.device.collectors.UiActionLatencyListener --module-arg PlatformScenarioTests:instrumentation-arg:iterations:=1 --module-arg PlatformScenarioTests:instrumentation-arg:drop-cache:=false --module-arg PlatformScenarioTests:instrumentation-arg:kill-app:=false
Change-Id: Iae24f6f09471a11ec428187b2a0aa96882c7dbf1
parent 590199f5
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -2935,24 +2935,21 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        if (mShowingPublicInitialized && mShowingPublic == oldShowingPublic) {
            return;
        }
        float oldAlpha = getContentView().getAlpha();

        if (!animated) {
            if (!NotificationContentAlphaOptimization.isEnabled()
                    || mShowingPublic != oldShowingPublic) {
                // Don't reset the alpha or cancel the animation if the showing layout doesn't
                // change
                mPublicLayout.animate().cancel();
                mPrivateLayout.animate().cancel();
                if (mChildrenContainer != null) {
                    mChildrenContainer.animate().cancel();
                }
                resetAllContentAlphas();
            }
            mPublicLayout.setVisibility(mShowingPublic ? View.VISIBLE : View.INVISIBLE);
            updateChildrenVisibility();
            if (NotificationContentAlphaOptimization.isEnabled()) {
                // We want to set the old alpha to the now-showing layout to avoid breaking an
                // on-going animation
                if (oldAlpha != 1f) {
                    setAlphaAndLayerType(mShowingPublic ? mPublicLayout : mPrivateLayout, oldAlpha);
                }
            }
        } else {
            animateShowingPublic(delay, duration, mShowingPublic);
        }
+4 −4
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {

    @Test
    @EnableFlags(NotificationContentAlphaOptimization.FLAG_NAME)
    public void setHideSensitive_changeContent_shouldNotDisturbAnimation() throws Exception {
    public void setHideSensitive_changeContent_shouldResetAlpha() throws Exception {

        // Given: A sensitive row that has public version but is not hiding sensitive,
        // and is during an animation that sets its alpha value to be 0.5f
@@ -351,12 +351,12 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {

        // Then: The alpha value of private layout should be reset to 1, private layout be
        // INVISIBLE;
        // The alpha value of public layout should be 0.5 to preserve the animation state, public
        // layout should be VISIBLE
        // The alpha value of public layout should be reset to 1 to avoid remaining transparent,
        // public layout should be VISIBLE
        assertEquals(View.INVISIBLE, row.getPrivateLayout().getVisibility());
        assertEquals(1f, row.getPrivateLayout().getAlpha(), 0);
        assertEquals(View.VISIBLE, row.getPublicLayout().getVisibility());
        assertEquals(0.5f, row.getPublicLayout().getAlpha(), 0);
        assertEquals(1f, row.getPublicLayout().getAlpha(), 0);
    }

    @Test