Tie bouncer over dream state to visibility.

This changelist migrates whether the bouncer is showing over dream away
from the expansion state to visibility. This allows other cases to be
recognized. For example, swiping away the bouncer will affect the
visibility but not necessarily the expansion.

Test: atest StatusBarKeyguardViewManagerTest
Change-Id: Ib140941e72534c75eb3014d64166eca909e96d0e
This commit is contained in:
Bryce Lee
2022-04-22 14:28:06 -07:00
parent f970175b79
commit 4de1c13fe7
4 changed files with 33 additions and 4 deletions

View File

@@ -44,6 +44,7 @@ import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent
import com.android.wm.shell.animation.FlingAnimationUtils;
import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Named;
@@ -153,8 +154,6 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
private void setPanelExpansion(float expansion, float dragDownAmount) {
mCurrentExpansion = expansion;
mCentralSurfaces.ifPresent(centralSurfaces -> centralSurfaces.setBouncerShowingOverDream(
mCurrentExpansion != KeyguardBouncer.EXPANSION_HIDDEN));
PanelExpansionChangeEvent event =
new PanelExpansionChangeEvent(
/* fraction= */ mCurrentExpansion,

View File

@@ -164,6 +164,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override
public void onVisibilityChanged(boolean isVisible) {
mCentralSurfaces
.setBouncerShowingOverDream(
isVisible && mDreamOverlayStateController.isOverlayActive());
if (!isVisible) {
mCentralSurfaces.setBouncerHiddenFraction(KeyguardBouncer.EXPANSION_HIDDEN);
}

View File

@@ -428,7 +428,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
@Test
public void testInformBouncerShowingOnExpand() {
swipeToPosition(1f, Direction.UP, 0);
verify(mCentralSurfaces).setBouncerShowingOverDream(true);
}
/**
@@ -441,7 +440,6 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
Mockito.clearInvocations(mCentralSurfaces);
swipeToPosition(0f, Direction.DOWN, 0);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
}

View File

@@ -61,7 +61,9 @@ import com.google.common.truth.Truth;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.util.Optional;
@@ -97,6 +99,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Mock private LatencyTracker mLatencyTracker;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private KeyguardBouncer.BouncerExpansionCallback mBouncerExpansionCallback;
@Before
public void setUp() {
@@ -136,6 +139,11 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mBypassController);
when(mKeyguardStateController.isOccluded()).thenReturn(false);
mStatusBarKeyguardViewManager.show(null);
ArgumentCaptor<KeyguardBouncer.BouncerExpansionCallback> callbackArgumentCaptor =
ArgumentCaptor.forClass(KeyguardBouncer.BouncerExpansionCallback.class);
verify(mKeyguardBouncerFactory).create(any(ViewGroup.class),
callbackArgumentCaptor.capture());
mBouncerExpansionCallback = callbackArgumentCaptor.getValue();
}
@Test
@@ -417,4 +425,24 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
return new PanelExpansionChangeEvent(
fraction, expanded, tracking, /* dragDownPxAmount= */ 0f);
}
@Test
public void testReportBouncerOnDreamWhenVisible() {
mBouncerExpansionCallback.onVisibilityChanged(true);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
Mockito.clearInvocations(mCentralSurfaces);
when(mDreamOverlayStateController.isOverlayActive()).thenReturn(true);
mBouncerExpansionCallback.onVisibilityChanged(true);
verify(mCentralSurfaces).setBouncerShowingOverDream(true);
}
@Test
public void testReportBouncerOnDreamWhenNotVisible() {
mBouncerExpansionCallback.onVisibilityChanged(false);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
Mockito.clearInvocations(mCentralSurfaces);
when(mDreamOverlayStateController.isOverlayActive()).thenReturn(true);
mBouncerExpansionCallback.onVisibilityChanged(false);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
}
}