From f4a0886bc333c5426d659a2b69fc210a84068f8f Mon Sep 17 00:00:00 2001 From: Darrell Shi Date: Fri, 26 Aug 2022 23:12:21 +0000 Subject: [PATCH] Add smartspace complication even when targets empty. This CL changes the logic to add smartspace complication even when smartspace targets are empty. The default smartspace card (with only date) should still be displayed, so to be consistent with the lockscreen and laucher. Bug: 243105222 Fix: 243105222 Test: atest SmartSpaceComplicationTest Test: wipe device, enable art gallery screensaver, see the default smartspace card shown with only date info Change-Id: I46af1c5ec017e4eb78ef9cd7e96e887fcb5597bb --- .../complication/SmartSpaceComplication.java | 6 +----- .../SmartSpaceComplicationTest.java | 20 ++++++------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/SmartSpaceComplication.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/SmartSpaceComplication.java index 567bdbc011704..a981f255a8735 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/SmartSpaceComplication.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/SmartSpaceComplication.java @@ -70,11 +70,7 @@ public class SmartSpaceComplication implements Complication { new BcSmartspaceDataPlugin.SmartspaceTargetListener() { @Override public void onSmartspaceTargetsUpdated(List targets) { - if (!targets.isEmpty()) { - mDreamOverlayStateController.addComplication(mComplication); - } else { - mDreamOverlayStateController.removeComplication(mComplication); - } + mDreamOverlayStateController.addComplication(mComplication); } }; diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/SmartSpaceComplicationTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/SmartSpaceComplicationTest.java index 7d54758acee7d..fa8f88a083685 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/SmartSpaceComplicationTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/SmartSpaceComplicationTest.java @@ -43,7 +43,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import java.util.Arrays; +import java.util.Collections; @SmallTest @RunWith(AndroidTestingRunner.class) @@ -60,9 +60,6 @@ public class SmartSpaceComplicationTest extends SysuiTestCase { @Mock private SmartSpaceComplication mComplication; - @Mock - private ComplicationViewModel mComplicationViewModel; - @Mock private View mBcSmartspaceView; @@ -125,12 +122,12 @@ public class SmartSpaceComplicationTest extends SysuiTestCase { // Test final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class); - listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target)); + listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.singletonList(target)); verify(mDreamOverlayStateController).addComplication(eq(mComplication)); } @Test - public void testOverlayActive_targetsEmpty_removesComplication() { + public void testOverlayActive_targetsEmpty_addsComplication() { final SmartSpaceComplication.Registrant registrant = getRegistrant(); registrant.start(); @@ -145,13 +142,9 @@ public class SmartSpaceComplicationTest extends SysuiTestCase { ArgumentCaptor.forClass(BcSmartspaceDataPlugin.SmartspaceTargetListener.class); verify(mSmartspaceController).addListener(listenerCaptor.capture()); - final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class); - listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target)); - verify(mDreamOverlayStateController).addComplication(eq(mComplication)); - // Test - listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList()); - verify(mDreamOverlayStateController).removeComplication(eq(mComplication)); + listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.emptyList()); + verify(mDreamOverlayStateController).addComplication(eq(mComplication)); } @Test @@ -170,8 +163,7 @@ public class SmartSpaceComplicationTest extends SysuiTestCase { ArgumentCaptor.forClass(BcSmartspaceDataPlugin.SmartspaceTargetListener.class); verify(mSmartspaceController).addListener(listenerCaptor.capture()); - final SmartspaceTarget target = Mockito.mock(SmartspaceTarget.class); - listenerCaptor.getValue().onSmartspaceTargetsUpdated(Arrays.asList(target)); + listenerCaptor.getValue().onSmartspaceTargetsUpdated(Collections.emptyList()); verify(mDreamOverlayStateController).addComplication(eq(mComplication)); // Test