diff options
author | Dave Mankoff <mankoff@google.com> | 2020-01-21 22:41:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-01-21 22:41:43 +0000 |
commit | abcd5a1db77e935a9bd3c723e7790d7c58fa8543 (patch) | |
tree | 213685120dbb8b3e21ad516f1ac6f65bacd05104 | |
parent | c3de6ca95690bec131739a782ea43009bdddcd14 (diff) | |
parent | 56fe9e42903637488ca53f2975d04f470406be17 (diff) |
Merge "Use subcomponent to add Controller to ActivtableNotificationView"
12 files changed, 238 insertions, 51 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 7506be09e589..36a845002deb 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -38,6 +38,7 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl; import com.android.systemui.statusbar.notification.people.PeopleHubModule; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.phone.KeyguardLiftController; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.dagger.StatusBarComponent; @@ -61,7 +62,7 @@ import dagger.Provides; @Module(includes = {AssistModule.class, ConcurrencyModule.class, PeopleHubModule.class}, - subcomponents = {StatusBarComponent.class}) + subcomponents = {StatusBarComponent.class, NotificationRowComponent.class}) public abstract class SystemUIModule { @Binds diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java index 0ab5afaab696..405f32ad7231 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SuperStatusBarViewFactory.java @@ -21,6 +21,7 @@ import android.view.LayoutInflater; import android.view.ViewGroup; import com.android.systemui.R; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.phone.LockIcon; import com.android.systemui.statusbar.phone.NotificationPanelView; import com.android.systemui.statusbar.phone.NotificationShadeWindowView; @@ -39,6 +40,7 @@ public class SuperStatusBarViewFactory { private final Context mContext; private final InjectionInflationController mInjectionInflationController; + private final NotificationRowComponent.Builder mNotificationRowComponentBuilder; private NotificationShadeWindowView mNotificationShadeWindowView; private StatusBarWindowView mStatusBarWindowView; @@ -46,9 +48,11 @@ public class SuperStatusBarViewFactory { @Inject public SuperStatusBarViewFactory(Context context, - InjectionInflationController injectionInflationController) { + InjectionInflationController injectionInflationController, + NotificationRowComponent.Builder notificationRowComponentBuilder) { mContext = context; mInjectionInflationController = injectionInflationController; + mNotificationRowComponentBuilder = notificationRowComponentBuilder; } /** @@ -114,6 +118,12 @@ public class SuperStatusBarViewFactory { mNotificationShelf = (NotificationShelf) mInjectionInflationController.injectable( LayoutInflater.from(mContext)).inflate(R.layout.status_bar_notification_shelf, container, /* attachToRoot= */ false); + + NotificationRowComponent component = mNotificationRowComponentBuilder + .activatableNotificationView(mNotificationShelf) + .build(); + component.getActivatableNotificationViewController().init(); + if (mNotificationShelf == null) { throw new IllegalStateException( "R.layout.status_bar_notification_shelf could not be properly inflated"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotificationRowBinderImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotificationRowBinderImpl.java index 5cd3e9411b08..2a7683a8c7c2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotificationRowBinderImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/inflation/NotificationRowBinderImpl.java @@ -41,9 +41,6 @@ import com.android.systemui.statusbar.notification.NotificationClicker; import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.logging.NotificationLogger; -import com.android.systemui.statusbar.notification.people.NotificationPersonExtractorPluginBoundary; -import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; -import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifierImpl; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder; @@ -52,13 +49,13 @@ import com.android.systemui.statusbar.notification.stack.NotificationListContain import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.policy.ExtensionControllerImpl; import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.Objects; import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Provider; import javax.inject.Singleton; /** Handles inflating and updating views for notifications. */ @@ -88,6 +85,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { private ExpandableNotificationRow.OnAppOpsClickListener mOnAppOpsClickListener; private BindRowCallback mBindRowCallback; private NotificationClicker mNotificationClicker; + private final Provider<RowInflaterTask> mRowInflaterTaskProvider; private final NotificationLogger mNotificationLogger; @Inject @@ -102,6 +100,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { NotificationGroupManager notificationGroupManager, NotificationGutsManager notificationGutsManager, NotificationInterruptionStateProvider notificationInterruptionStateProvider, + Provider<RowInflaterTask> rowInflaterTaskProvider, NotificationLogger logger) { mContext = context; mRowContentBinder = rowContentBinder; @@ -114,6 +113,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { mGroupManager = notificationGroupManager; mGutsManager = notificationGutsManager; mNotificationInterruptionStateProvider = notificationInterruptionStateProvider; + mRowInflaterTaskProvider = rowInflaterTaskProvider; mNotificationLogger = logger; } @@ -159,7 +159,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder { entry.getRow().setOnDismissRunnable(onDismissRunnable); } else { entry.createIcons(mContext, sbn); - new RowInflaterTask().inflate(mContext, parent, entry, + mRowInflaterTaskProvider.get().inflate(mContext, parent, entry, row -> { bindRow(entry, pmUser, sbn, row, onDismissRunnable); updateNotification(entry, pmUser, sbn, row); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationViewController.java new file mode 100644 index 000000000000..18993ffec357 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationViewController.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2020 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.notification.row; + +import android.view.accessibility.AccessibilityManager; + +import com.android.systemui.plugins.FalsingManager; + +import javax.inject.Inject; + +/** + * Controller for {@link ActivatableNotificationView} + */ +public class ActivatableNotificationViewController { + private final ActivatableNotificationView mView; + private final AccessibilityManager mAccessibilityManager; + private final FalsingManager mFalsingManager; + + @Inject + public ActivatableNotificationViewController(ActivatableNotificationView view, + AccessibilityManager accessibilityManager, FalsingManager falsingManager) { + mView = view; + mAccessibilityManager = accessibilityManager; + mFalsingManager = falsingManager; + } + + /** + * Initialize the controller, setting up handlers and other behavior. + */ + public void init() { + + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/RowInflaterTask.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/RowInflaterTask.java index 0160c547b336..c173b4dbaebe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/RowInflaterTask.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/RowInflaterTask.java @@ -26,6 +26,9 @@ import androidx.asynclayoutinflater.view.AsyncLayoutInflater; import com.android.systemui.R; import com.android.systemui.statusbar.InflationTask; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; + +import javax.inject.Inject; /** * An inflater task that asynchronously inflates a ExpandableNotificationRow @@ -34,12 +37,20 @@ public class RowInflaterTask implements InflationTask, AsyncLayoutInflater.OnInf private static final String TAG = "RowInflaterTask"; private static final boolean TRACE_ORIGIN = true; + private final NotificationRowComponent.Builder mNotificationRowComponentBuilder; private RowInflationFinishedListener mListener; private NotificationEntry mEntry; private boolean mCancelled; private Throwable mInflateOrigin; + @Inject + public RowInflaterTask( + NotificationRowComponent.Builder notificationRowComponentBuilder) { + super(); + mNotificationRowComponentBuilder = notificationRowComponentBuilder; + } + /** * Inflates a new notificationView. This should not be called twice on this object */ @@ -64,6 +75,12 @@ public class RowInflaterTask implements InflationTask, AsyncLayoutInflater.OnInf public void onInflateFinished(View view, int resid, ViewGroup parent) { if (!mCancelled) { try { + // Setup the controller for the view. + NotificationRowComponent component = mNotificationRowComponentBuilder + .activatableNotificationView((ActivatableNotificationView) view) + .build(); + component.getActivatableNotificationViewController().init(); + mEntry.onInflationTaskFinished(); mListener.onInflationFinished((ExpandableNotificationRow) view); } catch (Throwable t) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowComponent.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowComponent.java new file mode 100644 index 000000000000..f16ea7ae23e9 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/dagger/NotificationRowComponent.java @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2020 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.notification.row.dagger; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import javax.inject.Scope; + +import dagger.BindsInstance; +import dagger.Subcomponent; + +/** + * Dagger subcomponent for Notification related views. + */ +@Subcomponent(modules = {}) +@NotificationRowComponent.NotificationRowScope +public interface NotificationRowComponent { + /** + * Builder for {@link NotificationRowComponent}. + */ + @Subcomponent.Builder + interface Builder { + @BindsInstance + Builder activatableNotificationView(ActivatableNotificationView view); + NotificationRowComponent build(); + } + + /** + * Scope annotation for singleton items within the StatusBarComponent. + */ + @Documented + @Retention(RUNTIME) + @Scope + @interface NotificationRowScope {} + + /** + * Creates a ActivatableNotificationViewController. + */ + @NotificationRowScope + ActivatableNotificationViewController getActivatableNotificationViewController(); +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java index 09c1fad423d3..23433cb1682d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java @@ -33,12 +33,14 @@ import com.android.systemui.R; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.people.DataListener; import com.android.systemui.statusbar.notification.people.PeopleHubSectionFooterViewAdapter; import com.android.systemui.statusbar.notification.people.PeopleHubSectionFooterViewBoundary; import com.android.systemui.statusbar.notification.people.PersonViewModel; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; @@ -46,6 +48,8 @@ import java.lang.annotation.Retention; import java.util.ArrayList; import java.util.List; +import javax.inject.Inject; + import kotlin.sequences.Sequence; /** @@ -59,11 +63,13 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section private static final String TAG = "NotifSectionsManager"; private static final boolean DEBUG = false; - private final NotificationStackScrollLayout mParent; + private NotificationStackScrollLayout mParent; private final ActivityStarter mActivityStarter; private final StatusBarStateController mStatusBarStateController; private final ConfigurationController mConfigurationController; private final int mNumberOfSections; + private final NotificationSectionsFeatureManager mSectionsFeatureManager; + private final NotificationRowComponent.Builder mNotificationRowComponentBuilder; private boolean mInitialized = false; private SectionHeaderView mGentleHeader; @@ -99,22 +105,25 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section @Nullable private View.OnClickListener mOnClearGentleNotifsClickListener; + @Inject NotificationSectionsManager( - NotificationStackScrollLayout parent, ActivityStarter activityStarter, StatusBarStateController statusBarStateController, ConfigurationController configurationController, PeopleHubSectionFooterViewAdapter peopleHubViewAdapter, - int numberOfSections) { - mParent = parent; + NotificationSectionsFeatureManager sectionsFeatureManager, + NotificationRowComponent.Builder notificationRowComponentBuilder) { mActivityStarter = activityStarter; mStatusBarStateController = statusBarStateController; mConfigurationController = configurationController; mPeopleHubViewAdapter = peopleHubViewAdapter; - mNumberOfSections = numberOfSections; + mSectionsFeatureManager = sectionsFeatureManager; + mNumberOfSections = mSectionsFeatureManager.getNumberOfBuckets(); + mNotificationRowComponentBuilder = notificationRowComponentBuilder; } - NotificationSection[] createSectionsForBuckets(int[] buckets) { + NotificationSection[] createSectionsForBuckets() { + int[] buckets = mSectionsFeatureManager.getNotificationBuckets(); NotificationSection[] sections = new NotificationSection[buckets.length]; for (int i = 0; i < buckets.length; i++) { sections[i] = new NotificationSection(mParent, buckets[i] /* bucket */); @@ -124,11 +133,13 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section } /** Must be called before use. */ - void initialize(LayoutInflater layoutInflater) { + void initialize( + NotificationStackScrollLayout parent, LayoutInflater layoutInflater) { if (mInitialized) { throw new IllegalStateException("NotificationSectionsManager already initialized"); } mInitialized = true; + mParent = parent; reinflateViews(layoutInflater); mPeopleHubViewAdapter.bindView(mPeopleHubViewBoundary); mConfigurationController.addCallback(mConfigurationListener); @@ -159,6 +170,11 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section mGentleHeader = (SectionHeaderView) layoutInflater.inflate( R.layout.status_bar_notification_section_header, mParent, false); + NotificationRowComponent sectionHeaderComponent = mNotificationRowComponentBuilder + .activatableNotificationView(mGentleHeader) + .build(); + sectionHeaderComponent.getActivatableNotificationViewController().init(); + mGentleHeader.setOnHeaderClickListener(this::onGentleHeaderClick); mGentleHeader.setOnClearAllClickListener(this::onClearGentleNotifsClick); @@ -169,6 +185,11 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section mPeopleHubView = (PeopleHubView) layoutInflater.inflate( R.layout.people_strip, mParent, false); + NotificationRowComponent notificationRowComponent = mNotificationRowComponentBuilder + .activatableNotificationView(mPeopleHubView) + .build(); + notificationRowComponent.getActivatableNotificationViewController().init(); + if (oldPeopleHubPos != -1) { mParent.addView(mPeopleHubView, oldPeopleHubPos); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index dc2d99c3e3a5..11ead8bd2576 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -88,7 +88,6 @@ import com.android.systemui.Interpolators; import com.android.systemui.R; import com.android.systemui.SwipeHelper; import com.android.systemui.colorextraction.SysuiColorExtractor; -import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; @@ -109,14 +108,12 @@ import com.android.systemui.statusbar.notification.DynamicPrivacyController; import com.android.systemui.statusbar.notification.FakeShadowView; import com.android.systemui.statusbar.notification.NotificationEntryListener; import com.android.systemui.statusbar.notification.NotificationEntryManager; -import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.NotificationUtils; import com.android.systemui.statusbar.notification.ShadeViewRefactor; import com.android.systemui.statusbar.notification.ShadeViewRefactor.RefactorComponent; import com.android.systemui.statusbar.notification.VisualStabilityManager; import com.android.systemui.statusbar.notification.collection.NotificationEntry; import com.android.systemui.statusbar.notification.logging.NotificationLogger; -import com.android.systemui.statusbar.notification.people.PeopleHubSectionFooterViewAdapter; import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.ExpandableView; @@ -512,17 +509,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) boolean allowLongPress, NotificationRoundnessManager notificationRoundnessManager, DynamicPrivacyController dynamicPrivacyController, - ConfigurationController configurationController, - ActivityStarter activityStarter, - StatusBarStateController statusBarStateController, + SysuiStatusBarStateController statusBarStateController, HeadsUpManagerPhone headsUpManager, KeyguardBypassController keyguardBypassController, FalsingManager falsingManager, NotificationLockscreenUserManager notificationLockscreenUserManager, NotificationGutsManager notificationGutsManager, - NotificationSectionsFeatureManager sectionsFeatureManager, - PeopleHubSectionFooterViewAdapter peopleHubViewAdapter, - ZenModeController zenController) { + ZenModeController zenController, + NotificationSectionsManager notificationSectionsManager) { super(context, attrs, 0, 0); Resources res = getResources(); @@ -539,22 +533,14 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd mFalsingManager = falsingManager; mZenController = zenController; - int[] buckets = sectionsFeatureManager.getNotificationBuckets(); - mSectionsManager = - new NotificationSectionsManager( - this, - activityStarter, - statusBarStateController, - configurationController, - peopleHubViewAdapter, - buckets.length); - mSectionsManager.initialize(LayoutInflater.from(context)); + mSectionsManager = notificationSectionsManager; + mSectionsManager.initialize(this, LayoutInflater.from(context)); mSectionsManager.setOnClearGentleNotifsClickListener(v -> { // Leave the shade open if there will be other notifs left over to clear final boolean closeShade = !hasActiveClearableNotifications(ROWS_HIGH_PRIORITY); clearNotifications(ROWS_GENTLE, closeShade); }); - mSections = mSectionsManager.createSectionsForBuckets(buckets); + mSections = mSectionsManager.createSectionsForBuckets(); mAmbientState = new AmbientState(context, mSectionsManager, mHeadsUpManager); mBgColor = context.getColor(R.color.notification_shade_background_color); @@ -617,7 +603,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd }); dynamicPrivacyController.addListener(this); mDynamicPrivacyController = dynamicPrivacyController; - mStatusbarStateController = (SysuiStatusBarStateController) statusBarStateController; + mStatusbarStateController = statusBarStateController; } private void updateDismissRtlSetting(boolean dismissRtl) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java index 04116ec68600..2c9058afd7ab 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java @@ -70,7 +70,9 @@ import com.android.systemui.statusbar.notification.NotificationEntryManager; import com.android.systemui.statusbar.notification.NotificationFilter; import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; import com.android.systemui.statusbar.notification.collection.NotificationEntry; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; @@ -151,6 +153,8 @@ public class BubbleControllerTest extends SysuiTestCase { private ShadeController mShadeController; @Mock private RemoteInputUriController mRemoteInputUriController; + @Mock + private NotificationRowComponent mNotificationRowComponent; private SuperStatusBarViewFactory mSuperStatusBarViewFactory; private BubbleData mBubbleData; @@ -167,7 +171,19 @@ public class BubbleControllerTest extends SysuiTestCase { when(mColorExtractor.getNeutralColors()).thenReturn(mGradientColors); mSuperStatusBarViewFactory = new SuperStatusBarViewFactory(mContext, - new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent())); + new InjectionInflationController(SystemUIFactory.getInstance().getRootComponent()), + new NotificationRowComponent.Builder() { + @Override + public NotificationRowComponent.Builder activatableNotificationView( + ActivatableNotificationView view) { + return this; + } + + @Override + public NotificationRowComponent build() { + return mNotificationRowComponent; + } + }); // Bubbles get added to status bar window view mNotificationShadeWindowController = new NotificationShadeWindowController(mContext, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java index d852fa151fd3..4b2ce0157b23 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java @@ -83,12 +83,14 @@ import com.android.systemui.statusbar.notification.collection.provider.HighPrior import com.android.systemui.statusbar.notification.logging.NotifLog; import com.android.systemui.statusbar.notification.logging.NotificationLogger; import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.NotifRemoteViewCache; import com.android.systemui.statusbar.notification.row.NotificationContentInflater; import com.android.systemui.statusbar.notification.row.NotificationGutsManager; import com.android.systemui.statusbar.notification.row.NotificationRowContentBinder; import com.android.systemui.statusbar.notification.row.RowInflaterTask; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.notification.stack.NotificationListContainer; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationGroupManager; @@ -139,6 +141,8 @@ public class NotificationEntryManagerTest extends SysuiTestCase { @Mock private NotifLog mNotifLog; @Mock private FeatureFlags mFeatureFlags; @Mock private LeakDetector mLeakDetector; + @Mock private ActivatableNotificationViewController mActivatableNotificationViewController; + @Mock private NotificationRowComponent.Builder mNotificationRowComponentBuilder; private int mId; private NotificationEntry mEntry; @@ -207,6 +211,10 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mock(NotifRemoteViewCache.class), mRemoteInputManager); + when(mNotificationRowComponentBuilder.activatableNotificationView(any())) + .thenReturn(mNotificationRowComponentBuilder); + when(mNotificationRowComponentBuilder.build()).thenReturn( + () -> mActivatableNotificationViewController); NotificationRowBinderImpl notificationRowBinder = new NotificationRowBinderImpl(mContext, mRemoteInputManager, @@ -218,6 +226,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { mGroupManager, mGutsManager, mNotificationInterruptionStateProvider, + () -> new RowInflaterTask(mNotificationRowComponentBuilder), mock(NotificationLogger.class)); when(mFeatureFlags.isNewNotifPipelineEnabled()).thenReturn(false); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java index 518b6703391e..51f214d8cda2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java @@ -44,8 +44,12 @@ import com.android.systemui.ActivityStarterDelegate; import com.android.systemui.SysuiTestCase; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.StatusBarState; +import com.android.systemui.statusbar.notification.NotificationSectionsFeatureManager; import com.android.systemui.statusbar.notification.people.PeopleHubSectionFooterViewAdapter; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationView; +import com.android.systemui.statusbar.notification.row.ActivatableNotificationViewController; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; +import com.android.systemui.statusbar.notification.row.dagger.NotificationRowComponent; import com.android.systemui.statusbar.policy.ConfigurationController; import org.junit.Before; @@ -58,7 +62,7 @@ import org.mockito.junit.MockitoRule; @SmallTest @RunWith(AndroidTestingRunner.class) -@TestableLooper.RunWithLooper +@TestableLooper.RunWithLooper(setAsMainLooper = true) public class NotificationSectionsManagerTest extends SysuiTestCase { @Rule public final MockitoRule mockitoRule = MockitoJUnit.rule(); @@ -68,30 +72,47 @@ public class NotificationSectionsManagerTest extends SysuiTestCase { @Mock private StatusBarStateController mStatusBarStateController; @Mock private ConfigurationController mConfigurationController; @Mock private PeopleHubSectionFooterViewAdapter mPeopleHubAdapter; + @Mock private NotificationSectionsFeatureManager mSectionsFeatureManager; + @Mock private NotificationRowComponent mNotificationRowComponent; + @Mock private ActivatableNotificationViewController mActivatableNotificationViewController; private NotificationSectionsManager mSectionsManager; @Before public void setUp() { + when(mSectionsFeatureManager.getNumberOfBuckets()).thenReturn(2); + when(mNotificationRowComponent.getActivatableNotificationViewController()).thenReturn( + mActivatableNotificationViewController + ); mSectionsManager = new NotificationSectionsManager( - mNssl, mActivityStarterDelegate, mStatusBarStateController, mConfigurationController, mPeopleHubAdapter, - 2); + mSectionsFeatureManager, + new NotificationRowComponent.Builder() { + @Override + public NotificationRowComponent.Builder activatableNotificationView( + ActivatableNotificationView view) { + return this; + } + + @Override + public NotificationRowComponent build() { + return mNotificationRowComponent; + }}); // Required in order for the header inflation to work properly when(mNssl.generateLayoutParams(any(AttributeSet.class))) .thenReturn(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); - mSectionsManager.initialize(LayoutInflater.from(mContext)); + mSectionsManager.initialize(mNssl, LayoutInflater.from(mContext)); when(mNssl.indexOfChild(any(View.class))).thenReturn(-1); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); } @Test(expected = IllegalStateException.class) public void testDuplicateInitializeThrows() { - mSectionsManager.initialize(LayoutInflater.from(mContext)); + mSectionsManager.initialize(mNssl, LayoutInflater.from(mContext)); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index d9939f485ce5..7602e45c1672 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -46,7 +46,6 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto; -import com.android.systemui.ActivityStarterDelegate; import com.android.systemui.ExpandHelper; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; @@ -74,7 +73,6 @@ import com.android.systemui.statusbar.notification.collection.NotificationRankin import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; import com.android.systemui.statusbar.notification.logging.NotifLog; -import com.android.systemui.statusbar.notification.people.PeopleHubSectionFooterViewAdapter; import com.android.systemui.statusbar.notification.people.PeopleNotificationIdentifier; import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; import com.android.systemui.statusbar.notification.row.FooterView; @@ -87,9 +85,7 @@ import com.android.systemui.statusbar.phone.NotificationIconAreaController; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; -import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ZenModeController; -import com.android.systemui.util.DeviceConfigProxyFake; import com.android.systemui.util.leak.LeakDetector; import org.junit.After; @@ -132,6 +128,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Mock private NotificationRoundnessManager mNotificationRoundnessManager; @Mock private KeyguardBypassController mKeyguardBypassController; @Mock private ZenModeController mZenModeController; + @Mock private NotificationSectionsManager mNotificationSectionsManager; + @Mock private NotificationSection mNotificationSection; private TestableNotificationEntryManager mEntryManager; private int mOriginalInterruptionModelSetting; @@ -181,7 +179,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { NotificationShelf notificationShelf = mock(NotificationShelf.class); - + when(mNotificationSectionsManager.createSectionsForBuckets()).thenReturn( + new NotificationSection[]{ + mNotificationSection + }); // The actual class under test. You may need to work with this class directly when // testing anonymous class members of mStackScroller, like mMenuEventListener, // which refer to members of NotificationStackScrollLayout. The spy @@ -190,17 +191,14 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mStackScrollerInternal = new NotificationStackScrollLayout(getContext(), null, true /* allowLongPress */, mNotificationRoundnessManager, mock(DynamicPrivacyController.class), - mock(ConfigurationController.class), - mock(ActivityStarterDelegate.class), mock(SysuiStatusBarStateController.class), mHeadsUpManager, mKeyguardBypassController, new FalsingManagerFake(), mock(NotificationLockscreenUserManager.class), mock(NotificationGutsManager.class), - new NotificationSectionsFeatureManager(new DeviceConfigProxyFake(), mContext), - mock(PeopleHubSectionFooterViewAdapter.class), - mZenModeController); + mZenModeController, + mNotificationSectionsManager); mStackScroller = spy(mStackScrollerInternal); mStackScroller.setShelf(notificationShelf); mStackScroller.setStatusBar(mBar); |