Window LayoutParams optimizations

Bug: 225004500
Test: manual
Test: atest NotificationShadeWindowControllerImplTest
Change-Id: Ia60a5f7ec88d6ff961db0da04891afd9e3e139d6
This commit is contained in:
Lucas Dupin
2022-05-02 18:21:00 -07:00
parent e5f9c3da5c
commit 9c8bd2d5b4
3 changed files with 34 additions and 17 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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(()-> {