Merge changes I69cadfeb,I79c72e38,I58546516 into udc-dev

* changes:
  [Central Surfaces] Make NotificationPanelView a singleton.
  [Central Surfaces] Make NotificationStackScrollLayout a singleton.
  [Central Surfaces] Make NotificationShadeWindowView a singleton.
This commit is contained in:
Caitlin Shkuratov
2023-04-19 14:46:12 +00:00
committed by Android (Google) Code Review
8 changed files with 136 additions and 103 deletions

View File

@@ -71,6 +71,7 @@ import com.android.systemui.screenshot.dagger.ScreenshotModule;
import com.android.systemui.security.data.repository.SecurityRepositoryModule;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeModule;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolatorImpl;
import com.android.systemui.smartspace.dagger.SmartspaceModule;
@@ -175,6 +176,7 @@ import javax.inject.Named;
SecurityRepositoryModule.class,
ScreenRecordModule.class,
SettingsUtilModule.class,
ShadeModule.class,
SmartRepliesInflationModule.class,
SmartspaceModule.class,
StatusBarPipelineModule.class,

View File

@@ -1021,9 +1021,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
userAvatarContainer,
keyguardUserSwitcherView);
NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
R.id.notification_stack_scroller);
mNotificationStackScrollLayoutController.attach(stackScrollLayout);
mNotificationStackScrollLayoutController.setOnHeightChangedListener(
new NsslHeightChangedListener());
mNotificationStackScrollLayoutController.setOnEmptySpaceClickListener(

View File

@@ -84,10 +84,6 @@ public class NotificationShadeWindowView extends FrameLayout {
setMotionEventSplittingEnabled(false);
}
public NotificationPanelView getNotificationPanelView() {
return findViewById(R.id.notification_panel);
}
@Override
public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) {
final Insets insets = windowInsets.getInsetsIgnoringVisibility(systemBars());

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2023 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.shade
import android.view.LayoutInflater
import com.android.systemui.R
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import dagger.Module
import dagger.Provides
/** Module for classes related to the notification shade. */
@Module
abstract class ShadeModule {
companion object {
@Provides
@SysUISingleton
// TODO(b/277762009): Do something similar to
// {@link StatusBarWindowModule.InternalWindowView} so that only
// {@link NotificationShadeWindowViewController} can inject this view.
fun providesNotificationShadeWindowView(
layoutInflater: LayoutInflater,
): NotificationShadeWindowView {
return layoutInflater.inflate(R.layout.super_notification_shade, /* root= */ null)
as NotificationShadeWindowView?
?: throw IllegalStateException(
"R.layout.super_notification_shade could not be properly inflated"
)
}
// TODO(b/277762009): Only allow this view's controller to inject the view. See above.
@Provides
@SysUISingleton
fun providesNotificationStackScrollLayout(
notificationShadeWindowView: NotificationShadeWindowView,
): NotificationStackScrollLayout {
return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller)
}
// TODO(b/277762009): Only allow this view's controller to inject the view. See above.
@Provides
@SysUISingleton
fun providesNotificationPanelView(
notificationShadeWindowView: NotificationShadeWindowView,
): NotificationPanelView {
return notificationShadeWindowView.findViewById(R.id.notification_panel)
}
}
}

View File

@@ -627,6 +627,7 @@ public class NotificationStackScrollLayoutController {
@Inject
public NotificationStackScrollLayoutController(
NotificationStackScrollLayout view,
@Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress,
NotificationGutsManager notificationGutsManager,
NotificationVisibilityProvider visibilityProvider,
@@ -668,6 +669,7 @@ public class NotificationStackScrollLayoutController {
NotificationTargetsHelper notificationTargetsHelper,
SecureSettings secureSettings,
NotificationDismissibilityProvider dismissibilityProvider) {
mView = view;
mStackStateLogger = stackLogger;
mLogger = logger;
mAllowLongPress = allowLongPress;
@@ -711,10 +713,10 @@ public class NotificationStackScrollLayoutController {
mSecureSettings = secureSettings;
mDismissibilityProvider = dismissibilityProvider;
updateResources();
setUpView();
}
public void attach(NotificationStackScrollLayout view) {
mView = view;
private void setUpView() {
mView.setLogger(mStackStateLogger);
mView.setController(this);
mView.setLogger(mLogger);

View File

@@ -1645,6 +1645,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mNotificationShadeWindowView = mCentralSurfacesComponent.getNotificationShadeWindowView();
mNotificationShadeWindowViewController = mCentralSurfacesComponent
.getNotificationShadeWindowViewController();
// TODO(b/277762009): Inject [NotificationShadeWindowView] directly into the controller.
// (Right now, there's a circular dependency.)
mNotificationShadeWindowController.setNotificationShadeView(mNotificationShadeWindowView);
mNotificationShadeWindowViewController.setupExpandedStatusBar();
NotificationPanelViewController npvc =

View File

@@ -95,29 +95,6 @@ public abstract class StatusBarViewModule {
public static final String SHADE_HEADER = "large_screen_shade_header";
public static final String STATUS_BAR_FRAGMENT = "status_bar_fragment";
/** */
@Provides
@CentralSurfacesComponent.CentralSurfacesScope
public static NotificationShadeWindowView providesNotificationShadeWindowView(
LayoutInflater layoutInflater) {
NotificationShadeWindowView notificationShadeWindowView = (NotificationShadeWindowView)
layoutInflater.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
@CentralSurfacesComponent.CentralSurfacesScope
public static NotificationStackScrollLayout providesNotificationStackScrollLayout(
NotificationShadeWindowView notificationShadeWindowView) {
return notificationShadeWindowView.findViewById(R.id.notification_stack_scroller);
}
/** */
@Provides
@CentralSurfacesComponent.CentralSurfacesScope
@@ -157,14 +134,6 @@ public abstract class StatusBarViewModule {
}
}
/** */
@Provides
@CentralSurfacesComponent.CentralSurfacesScope
public static NotificationPanelView getNotificationPanelView(
NotificationShadeWindowView notificationShadeWindowView) {
return notificationShadeWindowView.getNotificationPanelView();
}
/** */
@Binds
@CentralSurfacesComponent.CentralSurfacesScope

View File

@@ -152,67 +152,18 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
when(mNotificationSwipeHelperBuilder.build()).thenReturn(mNotificationSwipeHelper);
mController = new NotificationStackScrollLayoutController(
true,
mNotificationGutsManager,
mVisibilityProvider,
mHeadsUpManager,
mNotificationRoundnessManager,
mTunerService,
mDeviceProvisionedController,
mDynamicPrivacyController,
mConfigurationController,
mSysuiStatusBarStateController,
mKeyguardMediaController,
mKeyguardBypassController,
mZenModeController,
mNotificationLockscreenUserManager,
mMetricsLogger,
mDumpManager,
new FalsingCollectorFake(),
new FalsingManagerFake(),
mResources,
mNotificationSwipeHelperBuilder,
mCentralSurfaces,
mScrimController,
mGroupExpansionManager,
mSilentHeaderController,
mNotifPipeline,
mNotifPipelineFlags,
mNotifCollection,
mLockscreenShadeTransitionController,
mUiEventLogger,
mRemoteInputManager,
mVisibilityLocationProviderDelegator,
mSeenNotificationsProvider,
mShadeController,
mJankMonitor,
mStackLogger,
mLogger,
mNotificationStackSizeCalculator,
mFeatureFlags,
mNotificationTargetsHelper,
mSecureSettings,
mock(NotificationDismissibilityProvider.class)
);
when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(true);
}
@Test
public void testAttach_viewAlreadyAttached() {
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mConfigurationController).addCallback(
any(ConfigurationController.ConfigurationListener.class));
}
@Test
public void testAttach_viewAttachedAfterInit() {
when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(false);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ false);
verify(mConfigurationController, never()).addCallback(
any(ConfigurationController.ConfigurationListener.class));
@@ -225,7 +176,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() {
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
mController.mConfigurationListener.onDensityOrFontScaleChanged();
verify(mNotificationStackScrollLayout).reinflateViews();
}
@@ -233,7 +185,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testUpdateEmptyShadeView_notificationsVisible_zenHiding() {
when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(true);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
setupShowEmptyShadeViewState(true);
reset(mNotificationStackScrollLayout);
@@ -253,7 +205,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testUpdateEmptyShadeView_notificationsHidden_zenNotHiding() {
when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
setupShowEmptyShadeViewState(true);
reset(mNotificationStackScrollLayout);
@@ -273,7 +225,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testUpdateEmptyShadeView_splitShadeMode_alwaysShowEmptyView() {
when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mSysuiStatusBarStateController).addCallback(
mStateListenerArgumentCaptor.capture(), anyInt());
StatusBarStateController.StateListener stateListener =
@@ -299,11 +252,11 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testOnUserChange_verifySensitiveProfile() {
when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true);
initController(/* viewIsAttached= */ true);
ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
.forClass(UserChangedListener.class);
mController.attach(mNotificationStackScrollLayout);
verify(mNotificationLockscreenUserManager)
.addUserChangedListener(userChangedCaptor.capture());
reset(mNotificationStackScrollLayout);
@@ -317,7 +270,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
public void testOnStatePostChange_verifyIfProfileIsPublic() {
when(mNotificationLockscreenUserManager.isAnyProfilePublicMode()).thenReturn(true);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mSysuiStatusBarStateController).addCallback(
mStateListenerArgumentCaptor.capture(), anyInt());
@@ -337,7 +290,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
ArgumentCaptor<OnMenuEventListener> onMenuEventListenerArgumentCaptor =
ArgumentCaptor.forClass(OnMenuEventListener.class);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mNotificationSwipeHelperBuilder).setOnMenuEventListener(
onMenuEventListenerArgumentCaptor.capture());
@@ -358,7 +311,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
ArgumentCaptor<OnMenuEventListener> onMenuEventListenerArgumentCaptor =
ArgumentCaptor.forClass(OnMenuEventListener.class);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mNotificationSwipeHelperBuilder).setOnMenuEventListener(
onMenuEventListenerArgumentCaptor.capture());
@@ -377,7 +330,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
dismissListenerArgumentCaptor = ArgumentCaptor.forClass(
NotificationStackScrollLayout.ClearAllListener.class);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mNotificationStackScrollLayout).setClearAllListener(
dismissListenerArgumentCaptor.capture());
@@ -394,7 +347,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
ArgumentCaptor.forClass(RemoteInputController.Callback.class);
doNothing().when(mRemoteInputManager).addControllerCallback(callbackCaptor.capture());
when(mRemoteInputManager.isRemoteInputActive()).thenReturn(false);
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
verify(mNotificationStackScrollLayout).setIsRemoteInputActive(false);
RemoteInputController.Callback callback = callbackCaptor.getValue();
callback.onRemoteInputActive(true);
@@ -403,8 +356,8 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testSetNotifStats_updatesHasFilteredOutSeenNotifications() {
initController(/* viewIsAttached= */ true);
mSeenNotificationsProvider.setHasFilteredOutSeenNotifications(true);
mController.attach(mNotificationStackScrollLayout);
mController.getNotifStackController().setNotifStats(NotifStats.getEmpty());
verify(mNotificationStackScrollLayout).setHasFilteredOutSeenNotifications(true);
verify(mNotificationStackScrollLayout).updateFooter();
@@ -414,7 +367,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
@Test
public void testAttach_updatesViewStatusBarState() {
// GIVEN: Controller is attached
mController.attach(mNotificationStackScrollLayout);
initController(/* viewIsAttached= */ true);
ArgumentCaptor<StatusBarStateController.StateListener> captor =
ArgumentCaptor.forClass(StatusBarStateController.StateListener.class);
verify(mSysuiStatusBarStateController).addCallback(captor.capture(), anyInt());
@@ -458,6 +411,55 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
}
}
private void initController(boolean viewIsAttached) {
when(mNotificationStackScrollLayout.isAttachedToWindow()).thenReturn(viewIsAttached);
mController = new NotificationStackScrollLayoutController(
mNotificationStackScrollLayout,
true,
mNotificationGutsManager,
mVisibilityProvider,
mHeadsUpManager,
mNotificationRoundnessManager,
mTunerService,
mDeviceProvisionedController,
mDynamicPrivacyController,
mConfigurationController,
mSysuiStatusBarStateController,
mKeyguardMediaController,
mKeyguardBypassController,
mZenModeController,
mNotificationLockscreenUserManager,
mMetricsLogger,
mDumpManager,
new FalsingCollectorFake(),
new FalsingManagerFake(),
mResources,
mNotificationSwipeHelperBuilder,
mCentralSurfaces,
mScrimController,
mGroupExpansionManager,
mSilentHeaderController,
mNotifPipeline,
mNotifPipelineFlags,
mNotifCollection,
mLockscreenShadeTransitionController,
mUiEventLogger,
mRemoteInputManager,
mVisibilityLocationProviderDelegator,
mSeenNotificationsProvider,
mShadeController,
mJankMonitor,
mStackLogger,
mLogger,
mNotificationStackSizeCalculator,
mFeatureFlags,
mNotificationTargetsHelper,
mSecureSettings,
mock(NotificationDismissibilityProvider.class)
);
}
static class LogMatcher implements ArgumentMatcher<LogMaker> {
private int mCategory, mType;