From 30a8feff8374fafd258d57d531d978d3d28457a7 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Thu, 10 Oct 2024 16:57:41 -0400 Subject: [sb] Rename *Fragment* dagger components to Home* Since we are moving away from the fragment, it makes sense to change the names of the dagger component/module/scope to `Home`. This better aligns with how these components are used, which is the home screen status bar Test: build Test: atest SystemUITests Bug: 364360986 Flag: EXEMPT rename from IDE Change-Id: I22e56b3bf8b9b5439483fcc77f37bd4695786abd --- .../statusbar/core/StatusBarInitializerTest.kt | 4 +- .../repository/StatusBarModeRepositoryImplTest.kt | 52 +++----- .../statusbar/core/StatusBarInitializer.kt | 10 +- .../StatusBarModePerDisplayRepository.kt | 11 +- .../repository/StatusBarModeRepositoryStore.kt | 4 +- .../phone/HeadsUpAppearanceController.java | 6 +- .../phone/LegacyLightsOutNotifController.java | 6 +- .../statusbar/phone/StatusBarBoundsProvider.kt | 12 +- .../statusbar/phone/StatusBarDemoMode.java | 6 +- .../phone/fragment/CollapsedStatusBarFragment.java | 28 ++--- .../CollapsedStatusBarFragmentStartable.kt | 6 +- .../fragment/dagger/HomeStatusBarComponent.java | 124 ++++++++++++++++++ .../phone/fragment/dagger/HomeStatusBarModule.java | 139 ++++++++++++++++++++ .../phone/fragment/dagger/HomeStatusBarScope.java | 32 +++++ .../dagger/StatusBarFragmentComponent.java | 122 ------------------ .../fragment/dagger/StatusBarFragmentModule.java | 140 --------------------- .../fragment/dagger/StatusBarFragmentScope.java | 32 ----- .../fragment/dagger/StatusBarStartablesModule.kt | 2 +- .../statusbar/phone/CentralSurfacesImplTest.java | 4 +- .../fragment/CollapsedStatusBarFragmentTest.java | 12 +- 20 files changed, 367 insertions(+), 385 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarComponent.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarScope.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java delete mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentScope.java diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt index 0abd66f9809f..e312d00f3dc2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/core/StatusBarInitializerTest.kt @@ -27,7 +27,7 @@ import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.fragments.FragmentHostManager import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import com.android.systemui.statusbar.pipeline.shared.ui.composable.StatusBarRootFactory import com.android.systemui.statusbar.window.StatusBarWindowController import com.android.systemui.statusbar.window.StatusBarWindowControllerStore @@ -70,7 +70,7 @@ class StatusBarInitializerTest : SysuiTestCase() { statusBarWindowController = windowController, collapsedStatusBarFragmentProvider = { mock(CollapsedStatusBarFragment::class.java) }, statusBarRootFactory = mock(StatusBarRootFactory::class.java), - componentFactory = mock(StatusBarFragmentComponent.Factory::class.java), + componentFactory = mock(HomeStatusBarComponent.Factory::class.java), creationListeners = setOf(), ) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt index 48ae7a2aa260..feda0c65bd7f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryImplTest.kt @@ -36,7 +36,7 @@ import com.android.systemui.statusbar.phone.BoundsPair import com.android.systemui.statusbar.phone.LetterboxAppearance import com.android.systemui.statusbar.phone.LetterboxAppearanceCalculator import com.android.systemui.statusbar.phone.StatusBarBoundsProvider -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.inCallModel @@ -62,8 +62,8 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { private val commandQueue = mock() private val letterboxAppearanceCalculator = mock() private val statusBarBoundsProvider = mock() - private val statusBarFragmentComponent = - mock().also { + private val homeStatusBarComponent = + mock().also { whenever(it.boundsProvider).thenReturn(statusBarBoundsProvider) } private val ongoingCallRepository = kosmos.ongoingCallRepository @@ -78,7 +78,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { ) .apply { this.start() - this.onStatusBarViewInitialized(statusBarFragmentComponent) + this.onStatusBarViewInitialized(homeStatusBarComponent) } private val commandQueueCallback: CommandQueue.Callbacks @@ -235,9 +235,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.isInFullscreenMode) - onSystemBarAttributesChanged( - requestedVisibleTypes = WindowInsets.Type.statusBars(), - ) + onSystemBarAttributesChanged(requestedVisibleTypes = WindowInsets.Type.statusBars()) assertThat(latest).isFalse() } @@ -247,9 +245,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.isInFullscreenMode) - onSystemBarAttributesChanged( - requestedVisibleTypes = WindowInsets.Type.navigationBars(), - ) + onSystemBarAttributesChanged(requestedVisibleTypes = WindowInsets.Type.navigationBars()) assertThat(latest).isTrue() } @@ -259,9 +255,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.isInFullscreenMode) - onSystemBarAttributesChanged( - requestedVisibleTypes = WindowInsets.Type.navigationBars(), - ) + onSystemBarAttributesChanged(requestedVisibleTypes = WindowInsets.Type.navigationBars()) assertThat(latest).isTrue() onSystemBarAttributesChanged( @@ -347,7 +341,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { val startingLetterboxAppearance = LetterboxAppearance( APPEARANCE_LIGHT_STATUS_BARS, - listOf(AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, Rect(0, 0, 1, 1))) + listOf(AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, Rect(0, 0, 1, 1))), ) whenever( letterboxAppearanceCalculator.getLetterboxAppearance( @@ -371,7 +365,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { val newLetterboxAppearance = LetterboxAppearance( APPEARANCE_LOW_PROFILE_BARS, - listOf(AppearanceRegion(APPEARANCE_LOW_PROFILE_BARS, Rect(10, 20, 30, 40))) + listOf(AppearanceRegion(APPEARANCE_LOW_PROFILE_BARS, Rect(10, 20, 30, 40))), ) whenever( letterboxAppearanceCalculator.getLetterboxAppearance( @@ -398,9 +392,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { val latest by collectLastValue(underTest.statusBarAppearance) ongoingCallRepository.setOngoingCallState(inCallModel(startTimeMs = 34)) - onSystemBarAttributesChanged( - requestedVisibleTypes = WindowInsets.Type.navigationBars(), - ) + onSystemBarAttributesChanged(requestedVisibleTypes = WindowInsets.Type.navigationBars()) assertThat(latest!!.mode).isEqualTo(StatusBarMode.SEMI_TRANSPARENT) } @@ -438,9 +430,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { fun statusBarMode_transientShown_semiTransparent() = testScope.runTest { val latest by collectLastValue(underTest.statusBarAppearance) - onSystemBarAttributesChanged( - appearance = APPEARANCE_OPAQUE_STATUS_BARS, - ) + onSystemBarAttributesChanged(appearance = APPEARANCE_OPAQUE_STATUS_BARS) underTest.showTransient() @@ -453,7 +443,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { val latest by collectLastValue(underTest.statusBarAppearance) onSystemBarAttributesChanged( - appearance = APPEARANCE_LOW_PROFILE_BARS or APPEARANCE_OPAQUE_STATUS_BARS, + appearance = APPEARANCE_LOW_PROFILE_BARS or APPEARANCE_OPAQUE_STATUS_BARS ) assertThat(latest!!.mode).isEqualTo(StatusBarMode.LIGHTS_OUT) @@ -464,9 +454,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.statusBarAppearance) - onSystemBarAttributesChanged( - appearance = APPEARANCE_LOW_PROFILE_BARS, - ) + onSystemBarAttributesChanged(appearance = APPEARANCE_LOW_PROFILE_BARS) assertThat(latest!!.mode).isEqualTo(StatusBarMode.LIGHTS_OUT_TRANSPARENT) } @@ -476,9 +464,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.statusBarAppearance) - onSystemBarAttributesChanged( - appearance = APPEARANCE_OPAQUE_STATUS_BARS, - ) + onSystemBarAttributesChanged(appearance = APPEARANCE_OPAQUE_STATUS_BARS) assertThat(latest!!.mode).isEqualTo(StatusBarMode.OPAQUE) } @@ -488,9 +474,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.statusBarAppearance) - onSystemBarAttributesChanged( - appearance = APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS, - ) + onSystemBarAttributesChanged(appearance = APPEARANCE_SEMI_TRANSPARENT_STATUS_BARS) assertThat(latest!!.mode).isEqualTo(StatusBarMode.SEMI_TRANSPARENT) } @@ -500,9 +484,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.statusBarAppearance) - onSystemBarAttributesChanged( - appearance = 0, - ) + onSystemBarAttributesChanged(appearance = 0) assertThat(latest!!.mode).isEqualTo(StatusBarMode.TRANSPARENT) } @@ -540,7 +522,7 @@ class StatusBarModeRepositoryImplTest : SysuiTestCase() { LetterboxDetails( /* letterboxInnerBounds= */ Rect(0, 0, 10, 10), /* letterboxFullBounds= */ Rect(0, 0, 20, 20), - /* appAppearance= */ 0 + /* appAppearance= */ 0, ) ) private val REGIONS_FROM_LETTERBOX_CALCULATOR = diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt index 86398b638543..6201ca553398 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/core/StatusBarInitializer.kt @@ -27,7 +27,7 @@ import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions import com.android.systemui.statusbar.phone.PhoneStatusBarView import com.android.systemui.statusbar.phone.PhoneStatusBarViewController import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import com.android.systemui.statusbar.pipeline.shared.ui.composable.StatusBarRootFactory import com.android.systemui.statusbar.window.StatusBarWindowController import dagger.assisted.Assisted @@ -60,7 +60,7 @@ interface StatusBarInitializer : CoreStartable { * Can be used to retrieve dependencies from that scope, including the status bar root * view. */ - fun onStatusBarViewInitialized(component: StatusBarFragmentComponent) + fun onStatusBarViewInitialized(component: HomeStatusBarComponent) } interface OnStatusBarViewUpdatedListener { @@ -81,10 +81,10 @@ constructor( @Assisted private val statusBarWindowController: StatusBarWindowController, private val collapsedStatusBarFragmentProvider: Provider, private val statusBarRootFactory: StatusBarRootFactory, - private val componentFactory: StatusBarFragmentComponent.Factory, + private val componentFactory: HomeStatusBarComponent.Factory, private val creationListeners: Set<@JvmSuppressWildcards OnStatusBarViewInitializedListener>, ) : StatusBarInitializer { - private var component: StatusBarFragmentComponent? = null + private var component: HomeStatusBarComponent? = null @get:VisibleForTesting var initialized = false @@ -157,7 +157,7 @@ constructor( object : FragmentHostManager.FragmentListener { override fun onFragmentViewCreated(tag: String, fragment: Fragment) { component = - (fragment as CollapsedStatusBarFragment).statusBarFragmentComponent + (fragment as CollapsedStatusBarFragment).homeStatusBarComponent ?: throw IllegalStateException() statusBarViewUpdatedListener?.onStatusBarViewUpdated( component!!.phoneStatusBarViewController, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModePerDisplayRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModePerDisplayRepository.kt index 088c86df8437..44bee1d784fc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModePerDisplayRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModePerDisplayRepository.kt @@ -36,7 +36,7 @@ import com.android.systemui.statusbar.data.model.StatusBarMode import com.android.systemui.statusbar.phone.BoundsPair import com.android.systemui.statusbar.phone.LetterboxAppearanceCalculator import com.android.systemui.statusbar.phone.StatusBarBoundsProvider -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import com.android.systemui.statusbar.phone.ongoingcall.data.repository.OngoingCallRepository import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import dagger.assisted.Assisted @@ -174,7 +174,7 @@ constructor( private val _statusBarBounds = MutableStateFlow(BoundsPair(Rect(), Rect())) - override fun onStatusBarViewInitialized(component: StatusBarFragmentComponent) { + override fun onStatusBarViewInitialized(component: HomeStatusBarComponent) { val statusBarBoundsProvider = component.boundsProvider val listener = object : StatusBarBoundsProvider.BoundsChangeListener { @@ -196,10 +196,9 @@ constructor( /** Modifies the raw [StatusBarAttributes] if letterboxing is needed. */ private val modifiedStatusBarAttributes: StateFlow = - combine( - _originalStatusBarAttributes, - _statusBarBounds, - ) { originalAttributes, statusBarBounds -> + combine(_originalStatusBarAttributes, _statusBarBounds) { + originalAttributes, + statusBarBounds -> if (originalAttributes == null) { null } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryStore.kt index 154be1f96e8b..2c9fa25d8535 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryStore.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarModeRepositoryStore.kt @@ -20,7 +20,7 @@ import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.DisplayId import com.android.systemui.statusbar.core.StatusBarInitializer -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import dagger.Binds import dagger.Module import dagger.multibindings.ClassKey @@ -56,7 +56,7 @@ constructor( defaultDisplay.start() } - override fun onStatusBarViewInitialized(component: StatusBarFragmentComponent) { + override fun onStatusBarViewInitialized(component: HomeStatusBarComponent) { defaultDisplay.onStatusBarViewInitialized(component) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 8f94c0656836..d0f4b6f4a4bb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -16,7 +16,7 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentModule.OPERATOR_NAME_FRAME_VIEW; +import static com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarModule.OPERATOR_NAME_FRAME_VIEW; import android.graphics.Rect; import android.util.MathUtils; @@ -44,7 +44,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.notification.row.shared.AsyncGroupHeaderViewInflation; import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarScope; import com.android.systemui.statusbar.policy.Clock; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.KeyguardStateController; @@ -63,7 +63,7 @@ import javax.inject.Named; * Controls the appearance of heads up notifications in the icon area and the header itself. * It also controls the roundness of the heads up notifications and the pulsing notifications. */ -@StatusBarFragmentScope +@HomeStatusBarScope public class HeadsUpAppearanceController extends ViewController implements OnHeadsUpChangedListener, DarkIconDispatcher.DarkReceiver, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyLightsOutNotifController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyLightsOutNotifController.java index 7c871e183740..5acc3a684515 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyLightsOutNotifController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyLightsOutNotifController.java @@ -18,7 +18,7 @@ package com.android.systemui.statusbar.phone; import static android.view.WindowInsetsController.APPEARANCE_LOW_PROFILE_BARS; -import static com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentModule.LIGHTS_OUT_NOTIF_VIEW; +import static com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarModule.LIGHTS_OUT_NOTIF_VIEW; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -37,7 +37,7 @@ import com.android.internal.view.AppearanceRegion; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.notification.collection.NotifLiveDataStore; import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarScope; import com.android.systemui.util.ViewController; import javax.inject.Inject; @@ -51,7 +51,7 @@ import javax.inject.Named; * This controller shows and hides the notification dot in the status bar to indicate * whether there are notifications when the device is in {@link View#SYSTEM_UI_FLAG_LOW_PROFILE}. */ -@StatusBarFragmentScope +@HomeStatusBarScope public class LegacyLightsOutNotifController extends ViewController { private final CommandQueue mCommandQueue; private final NotifLiveDataStore mNotifDataStore; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarBoundsProvider.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarBoundsProvider.kt index 00b08f097e97..3ac0bac95d68 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarBoundsProvider.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarBoundsProvider.kt @@ -18,10 +18,10 @@ package com.android.systemui.statusbar.phone import android.graphics.Rect import android.view.View -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentModule.END_SIDE_CONTENT -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentModule.START_SIDE_CONTENT -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarModule.END_SIDE_CONTENT +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarModule.START_SIDE_CONTENT +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarScope import com.android.systemui.util.ListenerSet import com.android.systemui.util.boundsOnScreen import javax.inject.Inject @@ -33,13 +33,13 @@ import javax.inject.Named * This is distinct from [StatusBarContentInsetsProvider], which provides the bounds of full status * bar after accounting for system insets. */ -@StatusBarFragmentScope +@HomeStatusBarScope class StatusBarBoundsProvider @Inject constructor( @Named(START_SIDE_CONTENT) private val startSideContent: View, @Named(END_SIDE_CONTENT) private val endSideContent: View, -) : StatusBarFragmentComponent.Startable { +) : HomeStatusBarComponent.Startable { interface BoundsChangeListener { fun onStatusBarBoundsChanged(bounds: BoundsPair) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarDemoMode.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarDemoMode.java index 25b8bfe0da25..1afe416c43c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarDemoMode.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarDemoMode.java @@ -21,7 +21,7 @@ import static com.android.systemui.shared.statusbar.phone.BarTransitions.MODE_SE import static com.android.systemui.shared.statusbar.phone.BarTransitions.MODE_TRANSLUCENT; import static com.android.systemui.shared.statusbar.phone.BarTransitions.MODE_TRANSPARENT; import static com.android.systemui.shared.statusbar.phone.BarTransitions.MODE_WARNING; -import static com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentModule.OPERATOR_NAME_VIEW; +import static com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarModule.OPERATOR_NAME_VIEW; import android.annotation.NonNull; import android.os.Bundle; @@ -32,7 +32,7 @@ import com.android.systemui.demomode.DemoMode; import com.android.systemui.demomode.DemoModeCommandReceiver; import com.android.systemui.demomode.DemoModeController; import com.android.systemui.navigationbar.NavigationBarController; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentScope; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarScope; import com.android.systemui.statusbar.policy.Clock; import com.android.systemui.util.ViewController; @@ -48,7 +48,7 @@ import javax.inject.Named; * This class extends ViewController not because it controls a specific view, but because we want it * to get torn down and re-created in line with the view's lifecycle. */ -@StatusBarFragmentScope +@HomeStatusBarScope public class StatusBarDemoMode extends ViewController implements DemoMode { private final Clock mClockView; private final View mOperatorNameView; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java index d868519ee9e2..d5e82650bdee 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragment.java @@ -66,8 +66,8 @@ import com.android.systemui.statusbar.phone.NotificationIconContainer; import com.android.systemui.statusbar.phone.PhoneStatusBarView; import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager; import com.android.systemui.statusbar.phone.StatusBarLocation; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent.Startable; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent.Startable; import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallListener; import com.android.systemui.statusbar.phone.ui.DarkIconManager; @@ -115,7 +115,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue public static final int FADE_IN_DELAY = 50; private static final int SOURCE_SYSTEM_EVENT_ANIMATOR = 1; private static final int SOURCE_OTHER = 2; - private StatusBarFragmentComponent mStatusBarFragmentComponent; + private HomeStatusBarComponent mHomeStatusBarComponent; private PhoneStatusBarView mStatusBar; private final StatusBarStateController mStatusBarStateController; private final KeyguardStateController mKeyguardStateController; @@ -134,7 +134,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue private StatusBarVisibilityModel mLastModifiedVisibility = StatusBarVisibilityModel.createDefaultModel(); private DarkIconManager mDarkIconManager; - private final StatusBarFragmentComponent.Factory mStatusBarFragmentComponentFactory; + private final HomeStatusBarComponent.Factory mHomeStatusBarComponentFactory; private final CommandQueue mCommandQueue; private final CollapsedStatusBarFragmentLogger mCollapsedStatusBarFragmentLogger; private final OperatorNameViewController.Factory mOperatorNameViewControllerFactory; @@ -239,7 +239,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue @Inject public CollapsedStatusBarFragment( - StatusBarFragmentComponent.Factory statusBarFragmentComponentFactory, + HomeStatusBarComponent.Factory homeStatusBarComponentFactory, OngoingCallController ongoingCallController, SystemStatusAnimationScheduler animationScheduler, ShadeExpansionStateManager shadeExpansionStateManager, @@ -262,7 +262,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue StatusBarWindowStateController statusBarWindowStateController, KeyguardUpdateMonitor keyguardUpdateMonitor, DemoModeController demoModeController) { - mStatusBarFragmentComponentFactory = statusBarFragmentComponentFactory; + mHomeStatusBarComponentFactory = homeStatusBarComponentFactory; mOngoingCallController = ongoingCallController; mAnimationScheduler = animationScheduler; mShadeExpansionStateManager = shadeExpansionStateManager; @@ -335,11 +335,11 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mDumpManager.registerDumpable(getDumpableName(), this); - mStatusBarFragmentComponent = mStatusBarFragmentComponentFactory.create( + mHomeStatusBarComponent = mHomeStatusBarComponentFactory.create( (PhoneStatusBarView) getView()); - mStatusBarFragmentComponent.init(); + mHomeStatusBarComponent.init(); mStartableStates.clear(); - for (Startable startable : mStatusBarFragmentComponent.getStartables()) { + for (Startable startable : mHomeStatusBarComponent.getStartables()) { mStartableStates.put(startable, Startable.State.STARTING); startable.start(); mStartableStates.put(startable, Startable.State.STARTED); @@ -474,7 +474,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue mCarrierConfigTracker.removeCallback(mCarrierConfigCallback); mCarrierConfigTracker.removeDataSubscriptionChangedListener(mDefaultDataListener); - for (Startable startable : mStatusBarFragmentComponent.getStartables()) { + for (Startable startable : mHomeStatusBarComponent.getStartables()) { mStartableStates.put(startable, Startable.State.STOPPING); startable.stop(); mStartableStates.put(startable, Startable.State.STOPPED); @@ -515,8 +515,8 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue * fragment functionality and we won't need to expose it here anymore. */ @Nullable - public StatusBarFragmentComponent getStatusBarFragmentComponent() { - return mStatusBarFragmentComponent; + public HomeStatusBarComponent getHomeStatusBarComponent() { + return mHomeStatusBarComponent; } private StatusBarVisibilityChangeListener mStatusBarVisibilityChangeListener = @@ -622,7 +622,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue // TODO(b/328393714) use HeadsUpNotificationInteractor.showHeadsUpStatusBar instead. boolean headsUpVisible = - mStatusBarFragmentComponent.getHeadsUpAppearanceController().shouldBeVisible(); + mHomeStatusBarComponent.getHeadsUpAppearanceController().shouldBeVisible(); if (SceneContainerFlag.isEnabled()) { // With the scene container, only use the value calculated by the view model to @@ -997,7 +997,7 @@ public class CollapsedStatusBarFragment extends Fragment implements CommandQueue pw.println("mHasPrimaryOngoingActivity=" + mHasPrimaryOngoingActivity); pw.println("mHasSecondaryOngoingActivity=" + mHasSecondaryOngoingActivity); pw.println("mAnimationsEnabled=" + mAnimationsEnabled); - StatusBarFragmentComponent component = mStatusBarFragmentComponent; + HomeStatusBarComponent component = mHomeStatusBarComponent; if (component == null) { pw.println("StatusBarFragmentComponent is null"); } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentStartable.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentStartable.kt index 55af0e3d65a3..94006f6cf1a9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentStartable.kt @@ -20,7 +20,7 @@ import com.android.systemui.CoreStartable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.fragments.FragmentService import com.android.systemui.qs.QSFragmentStartable -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent import dagger.Binds import dagger.Module import dagger.multibindings.ClassKey @@ -37,7 +37,7 @@ class CollapsedStatusBarFragmentStartable @Inject constructor( private val fragmentService: FragmentService, - private val collapsedstatusBarFragmentProvider: Provider + private val collapsedstatusBarFragmentProvider: Provider, ) : CoreStartable { override fun start() { fragmentService.addFragmentInstantiationProvider( @@ -47,7 +47,7 @@ constructor( } } -@Module(subcomponents = [StatusBarFragmentComponent::class]) +@Module(subcomponents = [HomeStatusBarComponent::class]) interface CollapsedStatusBarFragmentStartableModule { @Binds @IntoMap diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarComponent.java new file mode 100644 index 000000000000..d4cb625d3722 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarComponent.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone.fragment.dagger; + +import com.android.systemui.battery.BatteryMeterViewController; +import com.android.systemui.dagger.qualifiers.RootView; +import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor; +import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; +import com.android.systemui.statusbar.phone.LegacyLightsOutNotifController; +import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; +import com.android.systemui.statusbar.phone.PhoneStatusBarView; +import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; +import com.android.systemui.statusbar.phone.StatusBarBoundsProvider; +import com.android.systemui.statusbar.phone.StatusBarDemoMode; +import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; + +import dagger.BindsInstance; +import dagger.Subcomponent; + +import java.util.Set; + +/** + * A subcomponent that gets re-created each time we create a new {@link CollapsedStatusBarFragment}. + * + * This component will also re-create all classes that depend on {@link CollapsedStatusBarFragment} + * and friends. Specifically, the fragment creates a new {@link PhoneStatusBarView} and multiple + * controllers need access to that view, so those controllers will be re-created whenever the + * fragment is recreated. + * + * Anything that depends on {@link CollapsedStatusBarFragment} or {@link PhoneStatusBarView} + * should be included here or in {@link HomeStatusBarModule}. + */ +@Subcomponent(modules = { + HomeStatusBarModule.class, + StatusBarStartablesModule.class +}) +@HomeStatusBarScope +public interface HomeStatusBarComponent { + /** Simple factory. */ + @Subcomponent.Factory + interface Factory { + /** */ + HomeStatusBarComponent create( + @BindsInstance @RootView PhoneStatusBarView phoneStatusBarView); + } + + /** + * Performs initialization logic after {@link HomeStatusBarComponent} has been constructed. + */ + interface Startable { + /** */ + void start(); + /** */ + void stop(); + + enum State { + NONE, STARTING, STARTED, STOPPING, STOPPED + } + } + + /** + * Initialize anything extra for the component. Must be called after the component is created. + */ + default void init() { + // No one accesses these controllers, so we need to make sure we reference them here so they + // do get initialized. + getBatteryMeterViewController().init(); + getHeadsUpAppearanceController().init(); + getPhoneStatusBarViewController().init(); + if (!NotificationsLiveDataStoreRefactor.isEnabled()) { + getLegacyLightsOutNotifController().init(); + } + getStatusBarDemoMode().init(); + } + + /** */ + @HomeStatusBarScope + BatteryMeterViewController getBatteryMeterViewController(); + + /** */ + @HomeStatusBarScope + @RootView + PhoneStatusBarView getPhoneStatusBarView(); + + /** */ + @HomeStatusBarScope + PhoneStatusBarViewController getPhoneStatusBarViewController(); + + /** */ + @HomeStatusBarScope + HeadsUpAppearanceController getHeadsUpAppearanceController(); + + /** */ + @HomeStatusBarScope + LegacyLightsOutNotifController getLegacyLightsOutNotifController(); + + /** */ + @HomeStatusBarScope + StatusBarDemoMode getStatusBarDemoMode(); + + /** */ + @HomeStatusBarScope + PhoneStatusBarTransitions getPhoneStatusBarTransitions(); + + /** */ + Set getStartables(); + + /** */ + StatusBarBoundsProvider getBoundsProvider(); +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarModule.java new file mode 100644 index 000000000000..05b3238187a2 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarModule.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone.fragment.dagger; + +import android.view.View; +import android.view.ViewStub; + +import com.android.systemui.battery.BatteryMeterView; +import com.android.systemui.dagger.qualifiers.RootView; +import com.android.systemui.res.R; +import com.android.systemui.statusbar.HeadsUpStatusBarView; +import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; +import com.android.systemui.statusbar.phone.PhoneStatusBarView; +import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; +import com.android.systemui.statusbar.phone.StatusBarLocation; +import com.android.systemui.statusbar.policy.Clock; +import com.android.systemui.statusbar.window.StatusBarWindowControllerStore; + +import dagger.Module; +import dagger.Provides; + +import java.util.Optional; + +import javax.inject.Named; + +/** Dagger module for {@link HomeStatusBarComponent}. */ +@Module +public interface HomeStatusBarModule { + + String LIGHTS_OUT_NOTIF_VIEW = "lights_out_notif_view"; + String OPERATOR_NAME_VIEW = "operator_name_view"; + String OPERATOR_NAME_FRAME_VIEW = "operator_name_frame_view"; + String START_SIDE_CONTENT = "start_side_content"; + String END_SIDE_CONTENT = "end_side_content"; + + /** */ + @Provides + @HomeStatusBarScope + static BatteryMeterView provideBatteryMeterView(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.battery); + } + + /** */ + @Provides + @HomeStatusBarScope + static StatusBarLocation getStatusBarLocation() { + return StatusBarLocation.HOME; + } + + /** */ + @Provides + @HomeStatusBarScope + @Named(START_SIDE_CONTENT) + static View startSideContent(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.status_bar_start_side_content); + } + + /** */ + @Provides + @HomeStatusBarScope + @Named(END_SIDE_CONTENT) + static View endSideContent(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.status_bar_end_side_content); + } + + /** */ + @Provides + @HomeStatusBarScope + @Named(LIGHTS_OUT_NOTIF_VIEW) + static View provideLightsOutNotifView(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.notification_lights_out); + } + + /** */ + @Provides + @HomeStatusBarScope + @Named(OPERATOR_NAME_VIEW) + static View provideOperatorNameView(@RootView PhoneStatusBarView view) { + View operatorName = ((ViewStub) view.findViewById(R.id.operator_name_stub)).inflate(); + operatorName.setVisibility(View.GONE); + return operatorName; + } + + /** */ + @Provides + @HomeStatusBarScope + @Named(OPERATOR_NAME_FRAME_VIEW) + static Optional provideOperatorFrameNameView(@RootView PhoneStatusBarView view) { + return Optional.ofNullable(view.findViewById(R.id.operator_name_frame)); + } + + /** */ + @Provides + @HomeStatusBarScope + static Clock provideClock(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.clock); + } + + /** */ + @Provides + @HomeStatusBarScope + static PhoneStatusBarViewController providePhoneStatusBarViewController( + PhoneStatusBarViewController.Factory phoneStatusBarViewControllerFactory, + @RootView PhoneStatusBarView phoneStatusBarView) { + return phoneStatusBarViewControllerFactory.create( + phoneStatusBarView); + } + + /** */ + @Provides + @HomeStatusBarScope + static PhoneStatusBarTransitions providePhoneStatusBarTransitions( + @RootView PhoneStatusBarView view, + StatusBarWindowControllerStore statusBarWindowControllerStore) { + return new PhoneStatusBarTransitions( + view, statusBarWindowControllerStore.getDefaultDisplay().getBackgroundView()); + } + + /** */ + @Provides + @HomeStatusBarScope + static HeadsUpStatusBarView providesHeasdUpStatusBarView(@RootView PhoneStatusBarView view) { + return view.findViewById(R.id.heads_up_status_bar_view); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarScope.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarScope.java new file mode 100644 index 000000000000..2b1edddacd8d --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/HomeStatusBarScope.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.phone.fragment.dagger; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import javax.inject.Scope; + +/** + * Scope annotation for singleton items within the {@link HomeStatusBarComponent}. + */ +@Documented +@Retention(RUNTIME) +@Scope +public @interface HomeStatusBarScope {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java deleted file mode 100644 index 96faa359d43e..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentComponent.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone.fragment.dagger; - -import com.android.systemui.battery.BatteryMeterViewController; -import com.android.systemui.dagger.qualifiers.RootView; -import com.android.systemui.statusbar.notification.shared.NotificationsLiveDataStoreRefactor; -import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; -import com.android.systemui.statusbar.phone.LegacyLightsOutNotifController; -import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; -import com.android.systemui.statusbar.phone.PhoneStatusBarView; -import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; -import com.android.systemui.statusbar.phone.StatusBarBoundsProvider; -import com.android.systemui.statusbar.phone.StatusBarDemoMode; -import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; - -import dagger.BindsInstance; -import dagger.Subcomponent; - -import java.util.Set; - -/** - * A subcomponent that gets re-created each time we create a new {@link CollapsedStatusBarFragment}. - * - * This component will also re-create all classes that depend on {@link CollapsedStatusBarFragment} - * and friends. Specifically, the fragment creates a new {@link PhoneStatusBarView} and multiple - * controllers need access to that view, so those controllers will be re-created whenever the - * fragment is recreated. - * - * Anything that depends on {@link CollapsedStatusBarFragment} or {@link PhoneStatusBarView} - * should be included here or in {@link StatusBarFragmentModule}. - */ - -@Subcomponent(modules = { - StatusBarFragmentModule.class, - StatusBarStartablesModule.class -}) -@StatusBarFragmentScope -public interface StatusBarFragmentComponent { - /** Simple factory. */ - @Subcomponent.Factory - interface Factory { - StatusBarFragmentComponent create( - @BindsInstance @RootView PhoneStatusBarView phoneStatusBarView); - } - - /** - * Performs initialization logic after {@link StatusBarFragmentComponent} has been constructed. - */ - interface Startable { - void start(); - void stop(); - - enum State { - NONE, STARTING, STARTED, STOPPING, STOPPED - } - } - - /** - * Initialize anything extra for the component. Must be called after the component is created. - */ - default void init() { - // No one accesses these controllers, so we need to make sure we reference them here so they - // do get initialized. - getBatteryMeterViewController().init(); - getHeadsUpAppearanceController().init(); - getPhoneStatusBarViewController().init(); - if (!NotificationsLiveDataStoreRefactor.isEnabled()) { - getLegacyLightsOutNotifController().init(); - } - getStatusBarDemoMode().init(); - } - - /** */ - @StatusBarFragmentScope - BatteryMeterViewController getBatteryMeterViewController(); - - /** */ - @StatusBarFragmentScope - @RootView - PhoneStatusBarView getPhoneStatusBarView(); - - /** */ - @StatusBarFragmentScope - PhoneStatusBarViewController getPhoneStatusBarViewController(); - - /** */ - @StatusBarFragmentScope - HeadsUpAppearanceController getHeadsUpAppearanceController(); - - /** */ - @StatusBarFragmentScope - LegacyLightsOutNotifController getLegacyLightsOutNotifController(); - - /** */ - @StatusBarFragmentScope - StatusBarDemoMode getStatusBarDemoMode(); - - /** */ - @StatusBarFragmentScope - PhoneStatusBarTransitions getPhoneStatusBarTransitions(); - - /** */ - Set getStartables(); - - /** */ - StatusBarBoundsProvider getBoundsProvider(); -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java deleted file mode 100644 index cf877a741d6b..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentModule.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone.fragment.dagger; - -import android.view.View; -import android.view.ViewStub; - -import com.android.systemui.battery.BatteryMeterView; -import com.android.systemui.dagger.qualifiers.RootView; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.HeadsUpStatusBarView; -import com.android.systemui.statusbar.phone.PhoneStatusBarTransitions; -import com.android.systemui.statusbar.phone.PhoneStatusBarView; -import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; -import com.android.systemui.statusbar.phone.StatusBarLocation; -import com.android.systemui.statusbar.policy.Clock; -import com.android.systemui.statusbar.window.StatusBarWindowController; -import com.android.systemui.statusbar.window.StatusBarWindowControllerStore; - -import dagger.Module; -import dagger.Provides; - -import java.util.Optional; - -import javax.inject.Named; - -/** Dagger module for {@link StatusBarFragmentComponent}. */ -@Module -public interface StatusBarFragmentModule { - - String LIGHTS_OUT_NOTIF_VIEW = "lights_out_notif_view"; - String OPERATOR_NAME_VIEW = "operator_name_view"; - String OPERATOR_NAME_FRAME_VIEW = "operator_name_frame_view"; - String START_SIDE_CONTENT = "start_side_content"; - String END_SIDE_CONTENT = "end_side_content"; - - /** */ - @Provides - @StatusBarFragmentScope - static BatteryMeterView provideBatteryMeterView(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.battery); - } - - /** */ - @Provides - @StatusBarFragmentScope - static StatusBarLocation getStatusBarLocation() { - return StatusBarLocation.HOME; - } - - /** */ - @Provides - @StatusBarFragmentScope - @Named(START_SIDE_CONTENT) - static View startSideContent(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.status_bar_start_side_content); - } - - /** */ - @Provides - @StatusBarFragmentScope - @Named(END_SIDE_CONTENT) - static View endSideContent(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.status_bar_end_side_content); - } - - /** */ - @Provides - @StatusBarFragmentScope - @Named(LIGHTS_OUT_NOTIF_VIEW) - static View provideLightsOutNotifView(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.notification_lights_out); - } - - /** */ - @Provides - @StatusBarFragmentScope - @Named(OPERATOR_NAME_VIEW) - static View provideOperatorNameView(@RootView PhoneStatusBarView view) { - View operatorName = ((ViewStub) view.findViewById(R.id.operator_name_stub)).inflate(); - operatorName.setVisibility(View.GONE); - return operatorName; - } - - /** */ - @Provides - @StatusBarFragmentScope - @Named(OPERATOR_NAME_FRAME_VIEW) - static Optional provideOperatorFrameNameView(@RootView PhoneStatusBarView view) { - return Optional.ofNullable(view.findViewById(R.id.operator_name_frame)); - } - - /** */ - @Provides - @StatusBarFragmentScope - static Clock provideClock(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.clock); - } - - /** */ - @Provides - @StatusBarFragmentScope - static PhoneStatusBarViewController providePhoneStatusBarViewController( - PhoneStatusBarViewController.Factory phoneStatusBarViewControllerFactory, - @RootView PhoneStatusBarView phoneStatusBarView) { - return phoneStatusBarViewControllerFactory.create( - phoneStatusBarView); - } - - /** */ - @Provides - @StatusBarFragmentScope - static PhoneStatusBarTransitions providePhoneStatusBarTransitions( - @RootView PhoneStatusBarView view, - StatusBarWindowControllerStore statusBarWindowControllerStore) { - return new PhoneStatusBarTransitions( - view, statusBarWindowControllerStore.getDefaultDisplay().getBackgroundView()); - } - - /** */ - @Provides - @StatusBarFragmentScope - static HeadsUpStatusBarView providesHeasdUpStatusBarView(@RootView PhoneStatusBarView view) { - return view.findViewById(R.id.heads_up_status_bar_view); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentScope.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentScope.java deleted file mode 100644 index 96cff5960d68..000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarFragmentScope.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.statusbar.phone.fragment.dagger; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Scope; - -/** - * Scope annotation for singleton items within the {@link StatusBarFragmentComponent}. - */ -@Documented -@Retention(RUNTIME) -@Scope -public @interface StatusBarFragmentScope {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarStartablesModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarStartablesModule.kt index 9003d13df0a0..ba9181436fb9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarStartablesModule.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/fragment/dagger/StatusBarStartablesModule.kt @@ -28,5 +28,5 @@ internal interface StatusBarStartablesModule { @IntoSet fun statusBarBoundsCalculator( statusBarBoundsProvider: StatusBarBoundsProvider - ): StatusBarFragmentComponent.Startable + ): HomeStatusBarComponent.Startable } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index dfcb2317a65f..72f410b7630d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -186,7 +186,7 @@ import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController; import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent; import com.android.systemui.statusbar.pipeline.shared.ui.composable.StatusBarRootFactory; import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.ConfigurationController; @@ -517,7 +517,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mStatusBarWindowController, mCollapsedStatusBarFragmentProvider, mock(StatusBarRootFactory.class), - mock(StatusBarFragmentComponent.Factory.class), + mock(HomeStatusBarComponent.Factory.class), emptySet()), mStatusBarWindowControllerStore, mStatusBarWindowStateController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java index 15ef917343ee..80325c0ff6b9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/fragment/CollapsedStatusBarFragmentTest.java @@ -66,7 +66,7 @@ import com.android.systemui.statusbar.events.SystemStatusAnimationScheduler; import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerStatusBarViewBinder; import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; import com.android.systemui.statusbar.phone.StatusBarHideIconsForBouncerManager; -import com.android.systemui.statusbar.phone.fragment.dagger.StatusBarFragmentComponent; +import com.android.systemui.statusbar.phone.fragment.dagger.HomeStatusBarComponent; import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; import com.android.systemui.statusbar.phone.ui.DarkIconManager; import com.android.systemui.statusbar.phone.ui.StatusBarIconController; @@ -109,9 +109,9 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { private final CarrierConfigTracker mCarrierConfigTracker = mock(CarrierConfigTracker.class); @Mock - private StatusBarFragmentComponent.Factory mStatusBarFragmentComponentFactory; + private HomeStatusBarComponent.Factory mStatusBarFragmentComponentFactory; @Mock - private StatusBarFragmentComponent mStatusBarFragmentComponent; + private HomeStatusBarComponent mHomeStatusBarComponent; @Mock private StatusBarStateController mStatusBarStateController; @Mock @@ -1060,7 +1060,7 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { public void setUp_fragmentCreatesDaggerComponent() { CollapsedStatusBarFragment fragment = resumeAndGetFragment(); - assertEquals(mStatusBarFragmentComponent, fragment.getStatusBarFragmentComponent()); + assertEquals(mHomeStatusBarComponent, fragment.getHomeStatusBarComponent()); } @Test @@ -1224,8 +1224,8 @@ public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest { private void setUpDaggerComponent() { when(mStatusBarFragmentComponentFactory.create(any())) - .thenReturn(mStatusBarFragmentComponent); - when(mStatusBarFragmentComponent.getHeadsUpAppearanceController()) + .thenReturn(mHomeStatusBarComponent); + when(mHomeStatusBarComponent.getHeadsUpAppearanceController()) .thenReturn(mHeadsUpAppearanceController); } -- cgit v1.2.3-59-g8ed1b