From f501b295e11d22455f661707adad9d020b193d25 Mon Sep 17 00:00:00 2001 From: William Xiao Date: Wed, 12 Apr 2023 10:17:58 -0700 Subject: [PATCH] Fix home controls showing on low light dream Low light should never show complications, so short circuit early and don't return any in the state controller. Bug: 277746325 Test: atest DreamOverlayStateControllerTest Change-Id: Iae6388dafa69098b70e9229bc562172fec1fb149 --- .../dreams/DreamOverlayStateController.java | 4 ++++ .../dreams/DreamOverlayStateControllerTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java index a47565390d6b9..b575f9a0ab8b0 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayStateController.java @@ -182,6 +182,10 @@ public class DreamOverlayStateController implements * Returns collection of present {@link Complication}. */ public Collection getComplications(boolean filterByAvailability) { + if (isLowLightActive()) { + // Don't show complications on low light. + return Collections.emptyList(); + } return Collections.unmodifiableCollection(filterByAvailability ? mComplications .stream() diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java index 34fa76fd5d46e..55f0a8cd3f08f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayStateControllerTest.java @@ -234,6 +234,23 @@ public class DreamOverlayStateControllerTest extends SysuiTestCase { .isTrue(); } + @Test + public void testComplicationsNotShownForLowLight() { + final Complication complication = Mockito.mock(Complication.class); + final DreamOverlayStateController stateController = getDreamOverlayStateController(true); + + // Add a complication and verify it's returned in getComplications. + stateController.addComplication(complication); + mExecutor.runAllReady(); + assertThat(stateController.getComplications().contains(complication)) + .isTrue(); + + stateController.setLowLightActive(true); + mExecutor.runAllReady(); + + assertThat(stateController.getComplications()).isEmpty(); + } + @Test public void testNotifyLowLightChanged() { final DreamOverlayStateController stateController = getDreamOverlayStateController(true);