diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java index ebd610bb0af44..0c9e1ec1ff776 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java index 24660b261c519..01aa2ec9bfe6d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java @@ -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; - apply(mCurrentState); + 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; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java index ddccd834f76e0..26199d53a2b4f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImplTest.java @@ -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(()-> {