diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java index 5c41d572149cc..f6db9e434610e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java @@ -46,6 +46,7 @@ import com.android.systemui.bouncer.ui.binder.KeyguardBouncerViewBinder; import com.android.systemui.bouncer.ui.viewmodel.KeyguardBouncerViewModel; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.compose.ComposeFacade; +import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dock.DockManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.flags.Flags; @@ -72,7 +73,6 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.PhoneStatusBarViewController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.window.StatusBarWindowStateController; import com.android.systemui.unfold.UnfoldTransitionProgressProvider; import com.android.systemui.util.time.SystemClock; @@ -87,7 +87,7 @@ import javax.inject.Provider; /** * Controller for {@link NotificationShadeWindowView}. */ -@CentralSurfacesComponent.CentralSurfacesScope +@SysUISingleton public class NotificationShadeWindowViewController { private static final String TAG = "NotifShadeWindowVC"; private final FalsingCollector mFalsingCollector; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 0a7ee52fba46b..5fb729cb26f19 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -413,7 +413,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private final Point mCurrentDisplaySize = new Point(); - protected NotificationShadeWindowView mNotificationShadeWindowView; protected PhoneStatusBarView mStatusBarView; private PhoneStatusBarViewController mPhoneStatusBarViewController; private PhoneStatusBarTransitions mStatusBarTransitions; @@ -456,7 +455,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private final FalsingManager mFalsingManager; private final BroadcastDispatcher mBroadcastDispatcher; private final ConfigurationController mConfigurationController; - protected NotificationShadeWindowViewController mNotificationShadeWindowViewController; + private final Lazy + mNotificationShadeWindowViewControllerLazy; private final DozeParameters mDozeParameters; private final Lazy mBiometricUnlockControllerLazy; private final CentralSurfacesComponent.Factory mCentralSurfacesComponentFactory; @@ -722,6 +722,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { Lazy assistManagerLazy, ConfigurationController configurationController, NotificationShadeWindowController notificationShadeWindowController, + Lazy notificationShadeWindowViewControllerLazy, NotificationShelfController notificationShelfController, NotificationStackScrollLayoutController notificationStackScrollLayoutController, DozeParameters dozeParameters, @@ -825,6 +826,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mAssistManagerLazy = assistManagerLazy; mConfigurationController = configurationController; mNotificationShadeWindowController = notificationShadeWindowController; + mNotificationShadeWindowViewControllerLazy = notificationShadeWindowViewControllerLazy; mNotificationShelfController = notificationShelfController; mStackScrollerController = notificationStackScrollLayoutController; mStackScroller = mStackScrollerController.getView(); @@ -1073,7 +1075,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mDozeServiceHost.initialize( this, mStatusBarKeyguardViewManager, - mNotificationShadeWindowViewController, + getNotificationShadeWindowViewController(), mShadeSurface, mAmbientIndicationContainer); updateLightRevealScrimVisibility(); @@ -1235,8 +1237,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { updateTheme(); inflateStatusBarWindow(); - mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener()); - mWallpaperController.setRootView(mNotificationShadeWindowView); + getNotificationShadeWindowView().setOnTouchListener(getStatusBarWindowTouchListener()); + mWallpaperController.setRootView(getNotificationShadeWindowView()); // TODO: Deal with the ugliness that comes from having some of the status bar broken out // into fragments, but the rest here, it leaves some awkward lifecycle and whatnot. @@ -1257,7 +1259,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mStatusBarView = statusBarView; mPhoneStatusBarViewController = statusBarViewController; mStatusBarTransitions = statusBarTransitions; - mNotificationShadeWindowViewController + getNotificationShadeWindowViewController() .setStatusBarViewController(mPhoneStatusBarViewController); // Ensure we re-propagate panel expansion values to the panel controller and // any listeners it may have, such as PanelBar. This will also ensure we @@ -1271,7 +1273,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mStatusBarInitializer.initializeStatusBar( mCentralSurfacesComponent::createCollapsedStatusBarFragment); - mStatusBarTouchableRegionManager.setup(this, mNotificationShadeWindowView); + mStatusBarTouchableRegionManager.setup(this, getNotificationShadeWindowView()); createNavigationBar(result); @@ -1279,7 +1281,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mLockscreenWallpaper = mLockscreenWallpaperLazy.get(); } - mAmbientIndicationContainer = mNotificationShadeWindowView.findViewById( + mAmbientIndicationContainer = getNotificationShadeWindowView().findViewById( R.id.ambient_indication_container); mAutoHideController.setStatusBar(new AutoHideUiElement() { @@ -1304,10 +1306,10 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } }); - ScrimView scrimBehind = mNotificationShadeWindowView.findViewById(R.id.scrim_behind); - ScrimView notificationsScrim = mNotificationShadeWindowView + ScrimView scrimBehind = getNotificationShadeWindowView().findViewById(R.id.scrim_behind); + ScrimView notificationsScrim = getNotificationShadeWindowView() .findViewById(R.id.scrim_notifications); - ScrimView scrimInFront = mNotificationShadeWindowView.findViewById(R.id.scrim_in_front); + ScrimView scrimInFront = getNotificationShadeWindowView().findViewById(R.id.scrim_in_front); mScrimController.setScrimVisibleListener(scrimsVisible -> { mNotificationShadeWindowController.setScrimsVisibility(scrimsVisible); @@ -1345,7 +1347,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mNotificationShelfController, mHeadsUpManager); - BackDropView backdrop = mNotificationShadeWindowView.findViewById(R.id.backdrop); + BackDropView backdrop = getNotificationShadeWindowView().findViewById(R.id.backdrop); if (mWallpaperManager.isLockscreenLiveWallpaperEnabled()) { mMediaManager.setup(null, null, null, mScrimController, null); } else { @@ -1364,7 +1366,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { }); // Set up the quick settings tile panel - final View container = mNotificationShadeWindowView.findViewById(R.id.qs_frame); + final View container = getNotificationShadeWindowView().findViewById(R.id.qs_frame); if (container != null) { FragmentHostManager fragmentHostManager = mFragmentService.getFragmentHostManager(container); @@ -1379,7 +1381,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { .withDefault(this::createDefaultQSFragment) .build()); mBrightnessMirrorController = new BrightnessMirrorController( - mNotificationShadeWindowView, + getNotificationShadeWindowView(), mShadeSurface, mNotificationShadeDepthControllerLazy.get(), mBrightnessSliderFactory, @@ -1396,7 +1398,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { }); } - mReportRejectedTouch = mNotificationShadeWindowView + mReportRejectedTouch = getNotificationShadeWindowView() .findViewById(R.id.report_rejected_touch); if (mReportRejectedTouch != null) { updateReportRejectedTouchVisibility(); @@ -1544,7 +1546,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected QS createDefaultQSFragment() { return mFragmentService - .getFragmentHostManager(mNotificationShadeWindowView) + .getFragmentHostManager(getNotificationShadeWindowView()) .create(QSFragment.class); } @@ -1553,7 +1555,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mActivityLaunchAnimator.setCallback(mActivityLaunchAnimatorCallback); mActivityLaunchAnimator.addListener(mActivityLaunchAnimatorListener); mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider( - mNotificationShadeWindowViewController, + getNotificationShadeWindowViewController(), mNotifListContainer, mHeadsUpManager, mJankMonitor); @@ -1592,7 +1594,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mAutoHideController.checkUserAutoHide(event); mRemoteInputManager.checkRemoteInputOutside(event); mShadeController.onStatusBarTouch(event); - return mNotificationShadeWindowView.onTouchEvent(event); + return getNotificationShadeWindowView().onTouchEvent(event); }; } @@ -1606,15 +1608,12 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mCentralSurfacesComponent::createCollapsedStatusBarFragment); ViewGroup windowRootView = mCentralSurfacesComponent.getWindowRootView(); - mNotificationShadeWindowView = mCentralSurfacesComponent.getNotificationShadeWindowView(); - mNotificationShadeWindowViewController = mCentralSurfacesComponent - .getNotificationShadeWindowViewController(); // TODO(b/277762009): Inject [NotificationShadeWindowView] directly into the controller. // (Right now, there's a circular dependency.) mNotificationShadeWindowController.setWindowRootView(windowRootView); - mNotificationShadeWindowViewController.setupExpandedStatusBar(); + getNotificationShadeWindowViewController().setupExpandedStatusBar(); mShadeController.setNotificationShadeWindowViewController( - mNotificationShadeWindowViewController); + getNotificationShadeWindowViewController()); mBackActionInteractor.setup(mQsController, mShadeSurface); mPresenter = mCentralSurfacesComponent.getNotificationPresenter(); mNotificationActivityStarter = mCentralSurfacesComponent.getNotificationActivityStarter(); @@ -1633,6 +1632,14 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mCommandQueue.addCallback(mCommandQueueCallbacks); } + protected NotificationShadeWindowViewController getNotificationShadeWindowViewController() { + return mNotificationShadeWindowViewControllerLazy.get(); + } + + protected NotificationShadeWindowView getNotificationShadeWindowView() { + return getNotificationShadeWindowViewController().getView(); + } + protected void startKeyguard() { Trace.beginSection("CentralSurfaces#startKeyguard"); mStatusBarStateController.addCallback(mStateListener, @@ -1688,7 +1695,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public AuthKeyguardMessageArea getKeyguardMessageArea() { - return mNotificationShadeWindowViewController.getKeyguardMessageArea(); + return getNotificationShadeWindowViewController().getKeyguardMessageArea(); } @Override @@ -1982,11 +1989,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { pw.print(" mWallpaperSupported= "); pw.println(mWallpaperSupported); pw.println(" ShadeWindowView: "); - if (mNotificationShadeWindowViewController != null) { - mNotificationShadeWindowViewController.dump(pw, args); - CentralSurfaces.dumpBarTransitions( - pw, "PhoneStatusBarTransitions", mStatusBarTransitions); - } + getNotificationShadeWindowViewController().dump(pw, args); + CentralSurfaces.dumpBarTransitions( + pw, "PhoneStatusBarTransitions", mStatusBarTransitions); pw.println(" mMediaManager: "); if (mMediaManager != null) { @@ -2860,7 +2865,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { updateVisibleToUser(); updateNotificationPanelTouchState(); - mNotificationShadeWindowViewController.cancelCurrentTouch(); + getNotificationShadeWindowViewController().cancelCurrentTouch(); if (mLaunchCameraOnFinishedGoingToSleep) { mLaunchCameraOnFinishedGoingToSleep = false; @@ -3172,12 +3177,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { updateScrimController(); } - @VisibleForTesting - public void setNotificationShadeWindowViewController( - NotificationShadeWindowViewController nswvc) { - mNotificationShadeWindowViewController = nswvc; - } - /** * Set the amount of progress we are currently in if we're transitioning to the full shade. * 0.0f means we're not transitioning yet, while 1 means we're all the way in the full @@ -3412,7 +3411,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mVisible = visible; if (visible) { DejankUtils.notifyRendererOfExpensiveFrame( - mNotificationShadeWindowView, "onShadeVisibilityChanged"); + getNotificationShadeWindowView(), "onShadeVisibilityChanged"); } else { mGutsManager.closeAndSaveGuts(true /* removeLeavebehind */, true /* force */, true /* removeControls */, -1 /* x */, -1 /* y */, true /* resetMenu */); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java index 4ae460a3f0e19..e77f419f74e10 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesComponent.java @@ -21,8 +21,6 @@ import static com.android.systemui.statusbar.phone.dagger.StatusBarViewModule.ST import static java.lang.annotation.RetentionPolicy.RUNTIME; import com.android.systemui.scene.ui.view.WindowRootView; -import com.android.systemui.shade.NotificationShadeWindowView; -import com.android.systemui.shade.NotificationShadeWindowViewController; import com.android.systemui.shade.ShadeHeaderController; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.notification.NotificationActivityStarter; @@ -76,16 +74,6 @@ public interface CentralSurfacesComponent { /** Creates the root view of the main SysUI window}. */ WindowRootView getWindowRootView(); - /** - * Creates or returns a {@link NotificationShadeWindowView}. - */ - NotificationShadeWindowView getNotificationShadeWindowView(); - - /** - * Creates a NotificationShadeWindowViewController. - */ - NotificationShadeWindowViewController getNotificationShadeWindowViewController(); - /** * Creates a StatusBarHeadsUpChangeListener. */ 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 3d35233ad646a..530085191e96d 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 @@ -129,7 +129,6 @@ import com.android.systemui.settings.brightness.BrightnessSliderController; import com.android.systemui.shade.CameraLauncher; import com.android.systemui.shade.NotificationPanelView; import com.android.systemui.shade.NotificationPanelViewController; -import com.android.systemui.shade.NotificationShadeWindowView; import com.android.systemui.shade.NotificationShadeWindowViewController; import com.android.systemui.shade.QuickSettingsController; import com.android.systemui.shade.ShadeController; @@ -252,7 +251,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Mock private NotificationLogger.ExpansionStateLogger mExpansionStateLogger; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private StatusBarSignalPolicy mStatusBarSignalPolicy; - @Mock private NotificationShadeWindowView mNotificationShadeWindowView; @Mock private BroadcastDispatcher mBroadcastDispatcher; @Mock private AssistManager mAssistManager; @Mock private NotificationGutsManager mNotificationGutsManager; @@ -276,6 +274,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Mock private NotificationIconAreaController mNotificationIconAreaController; @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; + @Mock private Lazy + mNotificationShadeWindowViewControllerLazy; @Mock private NotificationShelfController mNotificationShelfController; @Mock private DozeParameters mDozeParameters; @Mock private Lazy mLockscreenWallpaperLazy; @@ -428,10 +428,10 @@ public class CentralSurfacesImplTest extends SysuiTestCase { when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); when(mCameraLauncherLazy.get()).thenReturn(mCameraLauncher); + when(mNotificationShadeWindowViewControllerLazy.get()) + .thenReturn(mNotificationShadeWindowViewController); when(mStatusBarComponentFactory.create()).thenReturn(mCentralSurfacesComponent); - when(mCentralSurfacesComponent.getNotificationShadeWindowViewController()).thenReturn( - mNotificationShadeWindowViewController); doAnswer(invocation -> { ((Runnable) invocation.getArgument(0)).run(); return null; @@ -510,6 +510,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { () -> mAssistManager, configurationController, mNotificationShadeWindowController, + mNotificationShadeWindowViewControllerLazy, mNotificationShelfController, mStackScrollerController, mDozeParameters, @@ -586,9 +587,8 @@ public class CentralSurfacesImplTest extends SysuiTestCase { when(mKeyguardViewMediator.getViewMediatorCallback()).thenReturn( mKeyguardVieMediatorCallback); - // TODO: we should be able to call mCentralSurfaces.start() and have all the below values - // initialized automatically and make NPVC private. - mCentralSurfaces.mNotificationShadeWindowView = mNotificationShadeWindowView; + // TODO(b/277764509): we should be able to call mCentralSurfaces.start() and have all the + // below values initialized automatically. mCentralSurfaces.mDozeScrimController = mDozeScrimController; mCentralSurfaces.mPresenter = mNotificationPresenter; mCentralSurfaces.mKeyguardIndicationController = mKeyguardIndicationController; @@ -823,8 +823,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { */ @Test public void testPredictiveBackCallback_invocationCollapsesPanel() { - mCentralSurfaces.setNotificationShadeWindowViewController( - mNotificationShadeWindowViewController); mCentralSurfaces.handleVisibleToUserChanged(true); verify(mOnBackInvokedDispatcher).registerOnBackInvokedCallback( eq(OnBackInvokedDispatcher.PRIORITY_DEFAULT), @@ -841,8 +839,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { */ @Test public void testPredictiveBackAnimation_progressMaxScalesPanel() { - mCentralSurfaces.setNotificationShadeWindowViewController( - mNotificationShadeWindowViewController); mCentralSurfaces.handleVisibleToUserChanged(true); verify(mOnBackInvokedDispatcher).registerOnBackInvokedCallback( eq(OnBackInvokedDispatcher.PRIORITY_DEFAULT), @@ -864,8 +860,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { */ @Test public void testPredictiveBackAnimation_progressMinScalesPanel() { - mCentralSurfaces.setNotificationShadeWindowViewController( - mNotificationShadeWindowViewController); mCentralSurfaces.handleVisibleToUserChanged(true); verify(mOnBackInvokedDispatcher).registerOnBackInvokedCallback( eq(OnBackInvokedDispatcher.PRIORITY_DEFAULT),