From 879f1bf42c45d80ea2e377ffde66d0f188843978 Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Thu, 8 Dec 2022 21:20:01 -0800 Subject: [PATCH] Complication Dagger Component introduction. This changelist introduces a dagger component dedicated to complications. This component will house complication-specific entities as complications are separated from the dream overlay. A factory for the component is provided to DreamOverlayService for constructing complication dependencies in the near term. Eventually, DreamOverlayService will be able to accept complication components specified elsewhere to interact with complications in other surfaces. Test: atest DreamOverlayServiceTest Bug: 261781069 Change-Id: I581f480a402afc2dbc1d052fd07ec152e9c0ea7b --- .../android/systemui/dagger/SystemUIModule.java | 2 ++ .../systemui/dreams/DreamOverlayService.java | 5 +++++ .../complication/dagger/ComplicationComponent.kt | 12 ++++++++++++ .../systemui/dreams/DreamOverlayServiceTest.java | 15 +++++++++++---- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationComponent.kt diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 3a59f4b5436ca..246528653380e 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -40,6 +40,7 @@ import com.android.systemui.controls.dagger.ControlsModule; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.demomode.dagger.DemoModeModule; import com.android.systemui.doze.dagger.DozeComponent; +import com.android.systemui.dreams.complication.dagger.ComplicationComponent; import com.android.systemui.dreams.dagger.DreamModule; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; @@ -163,6 +164,7 @@ import dagger.Provides; }, subcomponents = { CentralSurfacesComponent.class, + ComplicationComponent.class, NavigationBarComponent.class, NotificationRowComponent.class, DozeComponent.class, diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index ace33caa48238..b927ae752cd85 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -41,6 +41,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.complication.Complication; +import com.android.systemui.dreams.complication.dagger.ComplicationComponent; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; @@ -80,6 +81,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ // True if the service has been destroyed. private boolean mDestroyed = false; + private final ComplicationComponent mComplicationComponent; + private final DreamOverlayComponent mDreamOverlayComponent; private final LifecycleRegistry mLifecycleRegistry; @@ -128,6 +131,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ Context context, @Main Executor executor, WindowManager windowManager, + ComplicationComponent.Factory complicationComponentFactory, DreamOverlayComponent.Factory dreamOverlayComponentFactory, DreamOverlayStateController stateController, KeyguardUpdateMonitor keyguardUpdateMonitor, @@ -147,6 +151,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ final Complication.Host host = () -> mExecutor.execute(DreamOverlayService.this::requestExit); + mComplicationComponent = complicationComponentFactory.create(); mDreamOverlayComponent = dreamOverlayComponentFactory.create(viewModelStore, host, null); mLifecycleRegistry = mDreamOverlayComponent.getLifecycleRegistry(); diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationComponent.kt b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationComponent.kt new file mode 100644 index 0000000000000..89497098f8ae2 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/ComplicationComponent.kt @@ -0,0 +1,12 @@ +package com.android.systemui.dreams.complication.dagger + +import dagger.Subcomponent + +@Subcomponent +interface ComplicationComponent { + /** Factory for generating [ComplicationComponent]. */ + @Subcomponent.Factory + interface Factory { + fun create(): ComplicationComponent + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java index ff2978db5cb09..99ca9a6c1553d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -46,8 +46,8 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; +import com.android.systemui.dreams.complication.dagger.ComplicationComponent; import com.android.systemui.dreams.dagger.DreamOverlayComponent; -import com.android.systemui.dreams.touch.BouncerSwipeTouchHandler; import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; @@ -88,6 +88,12 @@ public class DreamOverlayServiceTest extends SysuiTestCase { @Mock WindowManagerImpl mWindowManager; + @Mock + ComplicationComponent.Factory mComplicationComponentFactory; + + @Mock + ComplicationComponent mComplicationComponent; + @Mock DreamOverlayComponent.Factory mDreamOverlayComponentFactory; @@ -112,9 +118,6 @@ public class DreamOverlayServiceTest extends SysuiTestCase { @Mock ViewGroup mDreamOverlayContainerViewParent; - @Mock - BouncerSwipeTouchHandler mBouncerSwipeTouchHandler; - @Mock UiEventLogger mUiEventLogger; @@ -135,6 +138,9 @@ public class DreamOverlayServiceTest extends SysuiTestCase { .thenReturn(mLifecycleRegistry); when(mDreamOverlayComponent.getDreamOverlayTouchMonitor()) .thenReturn(mDreamOverlayTouchMonitor); + when(mComplicationComponentFactory + .create()) + .thenReturn(mComplicationComponent); // TODO(b/261781069): A touch handler should be passed in from the complication component // when the complication component is introduced. when(mDreamOverlayComponentFactory @@ -144,6 +150,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { .thenReturn(mDreamOverlayContainerView); mService = new DreamOverlayService(mContext, mMainExecutor, mWindowManager, + mComplicationComponentFactory, mDreamOverlayComponentFactory, mStateController, mKeyguardUpdateMonitor,