From 0e2230c880b0cab2d51681b50f45a667643dadc3 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Thu, 19 Aug 2021 10:17:22 -0400 Subject: [PATCH] 1/3 Begin removine SuperStatusBarViewFactory. Use the StatusBarComponent in its place. Bug: 190746471 Test: atest SystemUITests && manual Change-Id: Idc7c347d19309dbbab8c134370d31479ddf5eb86 --- .../statusbar/SuperStatusBarViewFactory.java | 34 ------------------- .../systemui/statusbar/phone/StatusBar.java | 14 ++++---- .../phone/dagger/StatusBarComponent.java | 16 +++++---- .../phone/dagger/StatusBarPhoneModule.java | 7 ++-- .../phone/dagger/StatusBarViewModule.java | 21 ++++++++++++ .../statusbar/phone/StatusBarTest.java | 12 +++---- 6 files changed, 44 insertions(+), 60 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java index e4ae560ba69ba..78ebe9bcbb9e5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java @@ -23,8 +23,6 @@ import android.view.ViewGroup; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.statusbar.notification.row.dagger.NotificationShelfComponent; -import com.android.systemui.statusbar.phone.NotificationPanelView; -import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.StatusBarWindowView; import com.android.systemui.util.InjectionInflationController; @@ -41,7 +39,6 @@ public class SuperStatusBarViewFactory { private final InjectionInflationController mInjectionInflationController; private final NotificationShelfComponent.Builder mNotificationShelfComponentBuilder; - private NotificationShadeWindowView mNotificationShadeWindowView; private StatusBarWindowView mStatusBarWindowView; private NotificationShelfController mNotificationShelfController; @@ -54,28 +51,6 @@ public class SuperStatusBarViewFactory { mNotificationShelfComponentBuilder = notificationShelfComponentBuilder; } - /** - * Gets the inflated {@link NotificationShadeWindowView} from - * {@link R.layout#super_notification_shade}. - * Returns a cached instance, if it has already been inflated. - */ - public NotificationShadeWindowView getNotificationShadeWindowView() { - if (mNotificationShadeWindowView != null) { - return mNotificationShadeWindowView; - } - - mNotificationShadeWindowView = (NotificationShadeWindowView) - mInjectionInflationController.injectable( - LayoutInflater.from(mContext)).inflate(R.layout.super_notification_shade, - /* root= */ null); - if (mNotificationShadeWindowView == null) { - throw new IllegalStateException( - "R.layout.super_notification_shade could not be properly inflated"); - } - - return mNotificationShadeWindowView; - } - /** * Gets the inflated {@link StatusBarWindowView} from {@link R.layout#super_status_bar}. * Returns a cached instance, if it has already been inflated. @@ -127,13 +102,4 @@ public class SuperStatusBarViewFactory { return mNotificationShelfController; } - - public NotificationPanelView getNotificationPanelView() { - NotificationShadeWindowView notificationShadeWindowView = getNotificationShadeWindowView(); - if (notificationShadeWindowView == null) { - return null; - } - - return mNotificationShadeWindowView.findViewById(R.id.notification_panel); - } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 02d74316ecb2b..dda67e7923b94 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -228,11 +228,11 @@ import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.tuner.TunerService; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; +import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.MessageRouter; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wmshell.BubblesManager; -import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.startingsurface.SplashscreenContentDrawer; @@ -248,7 +248,6 @@ import java.util.Optional; import java.util.concurrent.Executor; import javax.inject.Named; -import javax.inject.Provider; import dagger.Lazy; @@ -491,7 +490,7 @@ public class StatusBar extends SystemUI implements protected NotificationShadeWindowViewController mNotificationShadeWindowViewController; private final DozeParameters mDozeParameters; private final Lazy mBiometricUnlockControllerLazy; - private final Provider mStatusBarComponentBuilder; + private final StatusBarComponent.Factory mStatusBarComponentFactory; private final PluginManager mPluginManager; private final Optional mSplitScreenOptional; private final StatusBarNotificationActivityStarter.Builder @@ -744,7 +743,7 @@ public class StatusBar extends SystemUI implements DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, - Provider statusBarComponentBuilder, + StatusBarComponent.Factory statusBarComponentFactory, PluginManager pluginManager, Optional splitScreenOptional, LightsOutNotifController lightsOutNotifController, @@ -841,7 +840,7 @@ public class StatusBar extends SystemUI implements mNotificationShadeDepthControllerLazy = notificationShadeDepthControllerLazy; mVolumeComponent = volumeComponent; mCommandQueue = commandQueue; - mStatusBarComponentBuilder = statusBarComponentBuilder; + mStatusBarComponentFactory = statusBarComponentFactory; mPluginManager = pluginManager; mSplitScreenOptional = splitScreenOptional; mStatusBarNotificationActivityStarterBuilder = statusBarNotificationActivityStarterBuilder; @@ -1533,9 +1532,8 @@ public class StatusBar extends SystemUI implements } private void inflateStatusBarWindow() { - mNotificationShadeWindowView = mSuperStatusBarViewFactory.getNotificationShadeWindowView(); - StatusBarComponent statusBarComponent = mStatusBarComponentBuilder.get() - .statusBarWindowView(mNotificationShadeWindowView).build(); + StatusBarComponent statusBarComponent = mStatusBarComponentFactory.create(); + mNotificationShadeWindowView = statusBarComponent.getNotificationShadeWindowView(); mNotificationShadeWindowViewController = statusBarComponent .getNotificationShadeWindowViewController(); mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java index d408c0cc32670..a5ff9e2fdf96f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarComponent.java @@ -34,7 +34,6 @@ import java.lang.annotation.Retention; import javax.inject.Scope; -import dagger.BindsInstance; import dagger.Subcomponent; /** @@ -46,11 +45,9 @@ public interface StatusBarComponent { /** * Builder for {@link StatusBarComponent}. */ - @Subcomponent.Builder - interface Builder { - @BindsInstance Builder statusBarWindowView( - NotificationShadeWindowView notificationShadeWindowView); - StatusBarComponent build(); + @Subcomponent.Factory + interface Factory { + StatusBarComponent create(); } /** @@ -61,6 +58,13 @@ public interface StatusBarComponent { @Scope @interface StatusBarScope {} + /** + * Creates a {@link NotificationShadeWindowView}/ + * @return + */ + @StatusBarScope + NotificationShadeWindowView getNotificationShadeWindowView(); + /** * Creates a NotificationShadeWindowViewController. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java index b36c45e7f8ef9..e11ef0ac7ef69 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarPhoneModule.java @@ -104,11 +104,11 @@ import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.tuner.TunerService; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; +import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.MessageRouter; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wmshell.BubblesManager; -import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.startingsurface.StartingSurface; @@ -117,7 +117,6 @@ import java.util.Optional; import java.util.concurrent.Executor; import javax.inject.Named; -import javax.inject.Provider; import dagger.Lazy; import dagger.Module; @@ -187,7 +186,7 @@ public interface StatusBarPhoneModule { DozeScrimController dozeScrimController, VolumeComponent volumeComponent, CommandQueue commandQueue, - Provider statusBarComponentBuilder, + StatusBarComponent.Factory statusBarComponentFactory, PluginManager pluginManager, Optional splitScreenOptional, LightsOutNotifController lightsOutNotifController, @@ -281,7 +280,7 @@ public interface StatusBarPhoneModule { dozeScrimController, volumeComponent, commandQueue, - statusBarComponentBuilder, + statusBarComponentFactory, pluginManager, splitScreenOptional, lightsOutNotifController, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java index 0e83eda2734a2..c5fba13dde3cb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/StatusBarViewModule.java @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.phone.dagger; import android.annotation.Nullable; +import android.content.Context; +import android.view.LayoutInflater; import android.view.View; import com.android.keyguard.LockIconView; @@ -26,6 +28,7 @@ import com.android.systemui.biometrics.AuthRippleView; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; import com.android.systemui.statusbar.phone.TapAgainView; +import com.android.systemui.util.InjectionInflationController; import javax.inject.Named; @@ -37,6 +40,24 @@ public abstract class StatusBarViewModule { public static final String SPLIT_SHADE_HEADER = "split_shade_header"; + /** */ + @Provides + @StatusBarComponent.StatusBarScope + public static NotificationShadeWindowView providesNotificationShadeWindowView( + InjectionInflationController injectionInflationController, + Context context) { + NotificationShadeWindowView notificationShadeWindowView = (NotificationShadeWindowView) + injectionInflationController.injectable( + LayoutInflater.from(context)).inflate(R.layout.super_notification_shade, + /* root= */ null); + if (notificationShadeWindowView == null) { + throw new IllegalStateException( + "R.layout.super_notification_shade could not be properly inflated"); + } + + return notificationShadeWindowView; + } + /** */ @Provides @StatusBarComponent.StatusBarScope diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 6c59c3e27f238..1adaee2a9f8fb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -140,12 +140,12 @@ import com.android.systemui.statusbar.policy.UserInfoControllerImpl; import com.android.systemui.statusbar.policy.UserSwitcherController; import com.android.systemui.tuner.TunerService; import com.android.systemui.unfold.UnfoldLightRevealOverlayAnimation; +import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.concurrency.MessageRouterImpl; import com.android.systemui.util.time.FakeSystemClock; import com.android.systemui.volume.VolumeComponent; import com.android.systemui.wmshell.BubblesManager; -import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.wm.shell.bubbles.Bubbles; import com.android.wm.shell.legacysplitscreen.LegacySplitScreen; import com.android.wm.shell.startingsurface.StartingSurface; @@ -160,8 +160,6 @@ import java.io.ByteArrayOutputStream; import java.io.PrintWriter; import java.util.Optional; -import javax.inject.Provider; - import dagger.Lazy; @SmallTest @@ -235,8 +233,7 @@ public class StatusBarTest extends SysuiTestCase { @Mock private ViewMediatorCallback mKeyguardVieMediatorCallback; @Mock private VolumeComponent mVolumeComponent; @Mock private CommandQueue mCommandQueue; - @Mock private Provider mStatusBarComponentBuilderProvider; - @Mock private StatusBarComponent.Builder mStatusBarComponentBuilder; + @Mock private StatusBarComponent.Factory mStatusBarComponentFactory; @Mock private StatusBarComponent mStatusBarComponent; @Mock private PluginManager mPluginManager; @Mock private LegacySplitScreen mLegacySplitScreen; @@ -341,8 +338,7 @@ public class StatusBarTest extends SysuiTestCase { when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); - when(mStatusBarComponentBuilderProvider.get()).thenReturn(mStatusBarComponentBuilder); - when(mStatusBarComponentBuilder.build()).thenReturn(mStatusBarComponent); + when(mStatusBarComponentFactory.create()).thenReturn(mStatusBarComponent); when(mStatusBarComponent.getNotificationShadeWindowViewController()).thenReturn( mNotificationShadeWindowViewController); @@ -407,7 +403,7 @@ public class StatusBarTest extends SysuiTestCase { mDozeScrimController, mVolumeComponent, mCommandQueue, - mStatusBarComponentBuilderProvider, + mStatusBarComponentFactory, mPluginManager, Optional.of(mLegacySplitScreen), mLightsOutNotifController,