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

Commit 7b6e3392 authored by Lucas Dupin's avatar Lucas Dupin Committed by Automerger Merge Worker
Browse files

Merge "Window LayoutParams optimizations" into tm-dev am: 0278922a am: ae92e8cb

parents bce9900a ae92e8cb
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -179,13 +179,6 @@ public interface NotificationShadeWindowController extends RemoteInputController
     */
    default void setRequestTopUi(boolean requestTopUi, String componentTag) {}

    /**
     * Under low light conditions, we might want to increase the display brightness on devices that
     * don't have an IR camera.
     * @param brightness float from 0 to 1 or {@code LayoutParams.BRIGHTNESS_OVERRIDE_NONE}
     */
    default void setFaceAuthDisplayBrightness(float brightness) {}

    /**
     * If {@link LightRevealScrim} obscures the UI.
     * @param opaque if the scrim is opaque
+20 −10
Original line number Diff line number Diff line
@@ -111,7 +111,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    private final SysuiColorExtractor mColorExtractor;
    private final ScreenOffAnimationController mScreenOffAnimationController;
    private float mFaceAuthDisplayBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
    /**
     * Layout params would be aggregated and dispatched all at once if this is > 0.
     *
@@ -266,12 +265,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        mScreenBrightnessDoze = value / 255f;
    }

    @Override
    public void setFaceAuthDisplayBrightness(float brightness) {
        mFaceAuthDisplayBrightness = brightness;
        apply(mCurrentState);
    }

    private void setKeyguardDark(boolean dark) {
        int vis = mNotificationShadeView.getSystemUiVisibility();
        if (dark) {
@@ -455,7 +448,9 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    private void applyWindowLayoutParams() {
        if (mDeferWindowLayoutParams == 0 && mLp != null && mLp.copyFrom(mLpChanged) != 0) {
            Trace.beginSection("updateViewLayout");
            mWindowManager.updateViewLayout(mNotificationShadeView, mLp);
            Trace.endSection();
        }
    }

@@ -523,7 +518,7 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        if (state.mForceDozeBrightness) {
            mLpChanged.screenBrightness = mScreenBrightnessDoze;
        } else {
            mLpChanged.screenBrightness = mFaceAuthDisplayBrightness;
            mLpChanged.screenBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
        }
    }

@@ -572,6 +567,10 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    @Override
    public void setPanelVisible(boolean visible) {
        if (mCurrentState.mPanelVisible == visible
                && mCurrentState.mNotificationShadeFocusable == visible) {
            return;
        }
        mCurrentState.mPanelVisible = visible;
        mCurrentState.mNotificationShadeFocusable = visible;
        apply(mCurrentState);
@@ -626,8 +625,14 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    @Override
    public void setScrimsVisibility(int scrimsVisibility) {
        if (scrimsVisibility == mCurrentState.mScrimsVisibility) {
            return;
        }
        boolean wasExpanded = isExpanded(mCurrentState);
        mCurrentState.mScrimsVisibility = scrimsVisibility;
        if (wasExpanded != isExpanded(mCurrentState)) {
            apply(mCurrentState);
        }
        mScrimsVisibilityListener.accept(scrimsVisibility);
    }

@@ -687,6 +692,9 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW

    @Override
    public void setPanelExpanded(boolean isExpanded) {
        if (mCurrentState.mPanelExpanded == isExpanded) {
            return;
        }
        mCurrentState.mPanelExpanded = isExpanded;
        apply(mCurrentState);
    }
@@ -703,6 +711,9 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
     */
    @Override
    public void setForceDozeBrightness(boolean forceDozeBrightness) {
        if (mCurrentState.mForceDozeBrightness == forceDozeBrightness) {
            return;
        }
        mCurrentState.mForceDozeBrightness = forceDozeBrightness;
        apply(mCurrentState);
    }
@@ -841,7 +852,6 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
        boolean mLightRevealScrimOpaque;
        boolean mForceCollapsed;
        boolean mForceDozeBrightness;
        int mFaceAuthDisplayBrightness;
        boolean mForceUserActivity;
        boolean mLaunchingActivity;
        boolean mBackdropShowing;
+14 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import android.app.IActivityManager;
@@ -103,6 +104,7 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
        mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);

        mNotificationShadeWindowController.attach();
        verify(mWindowManager).addView(eq(mNotificationShadeWindowView), any());
    }

    @Test
@@ -173,6 +175,14 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
        verify(mWindowManager, never()).updateViewLayout(any(), mLayoutParameters.capture());
    }

    @Test
    public void setScrimsVisibility_earlyReturn() {
        clearInvocations(mWindowManager);
        mNotificationShadeWindowController.setScrimsVisibility(ScrimController.TRANSPARENT);
        // Abort early if value didn't change
        verify(mWindowManager, never()).updateViewLayout(any(), mLayoutParameters.capture());
    }

    @Test
    public void attach_animatingKeyguardAndSurface_wallpaperVisible() {
        clearInvocations(mWindowManager);
@@ -221,6 +231,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    public void setPanelExpanded_notFocusable_altFocusable_whenPanelIsOpen() {
        mNotificationShadeWindowController.setPanelExpanded(true);
        clearInvocations(mWindowManager);
        mNotificationShadeWindowController.setPanelExpanded(true);
        verifyNoMoreInteractions(mWindowManager);
        mNotificationShadeWindowController.setNotificationShadeFocusable(true);

        verify(mWindowManager).updateViewLayout(any(), mLayoutParameters.capture());
@@ -287,6 +299,8 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
    public void batchApplyWindowLayoutParams_doesNotDispatchEvents() {
        mNotificationShadeWindowController.setForceDozeBrightness(true);
        verify(mWindowManager).updateViewLayout(any(), any());
        mNotificationShadeWindowController.setForceDozeBrightness(true);
        verifyNoMoreInteractions(mWindowManager);

        clearInvocations(mWindowManager);
        mNotificationShadeWindowController.batchApplyWindowLayoutParams(()-> {