Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41580e69 authored by Beverly's avatar Beverly
Browse files

Update max # notifs in NotifPanelViewController

Instead of updating in NotificationViewHierarchyManager. Now both the
old and new pipeline will show the correct # max notifications in
the shade.  This fixes the bug where only a max 3 notifications was
showing in the notification shade when the new notification rendering
pipeline was enabled. (onKeyguard wasn't being updated and the max # of
notifications on the keyguard is 3.)

This fix includes:
- Update ExpandableNotificationRow's keyguard state via status bar state
controller listener instead of relying on a direct call to update from NVHM/StatusBar
- Removing NotificationPresenter getMaxNotificationsWhileLocked method.
Instead, if a package wants to override this value, it should override the config
value keyguard_max_notification_count
- This also fixes regular notification expansion when enabling the
new notification pipeline because now onKeyguard is being updated
appropriately, so the expansion states can evaluate correctly

Test: atest SystemUITests
Change-Id: I07593ef5d95674911f6f96a5c03cf4128a885a99
parent 89ecbea1
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -54,14 +54,6 @@ public interface NotificationPresenter extends ExpandableNotificationRow.OnExpan
     */
    void updateNotificationViews(String reason);

    /**
     * Returns the maximum number of notifications to show while locked.
     *
     * @param recompute whether something has changed that means we should recompute this value
     * @return the maximum number of notifications to show while locked
     */
    int getMaxNotificationsWhileLocked(boolean recompute);

    /**
     * Called when the row states are updated by {@link NotificationViewHierarchyManager}.
     */
+4 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ public class NotificationShelfController {
        return mView.getShelfIcons();
    }

    public @View.Visibility int getVisibility() {
        return mView.getVisibility();
    };

    public void setCollapsedIcons(NotificationIconContainer notificationIcons) {
        mView.setCollapsedIcons(notificationIcons);
    }
+0 −7
Original line number Diff line number Diff line
@@ -420,11 +420,6 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle

        int visibleNotifications = 0;
        boolean onKeyguard = mStatusBarStateController.getState() == StatusBarState.KEYGUARD;
        int maxNotifications = -1;
        if (onKeyguard && !mBypassController.getBypassEnabled()) {
            maxNotifications = mPresenter.getMaxNotificationsWhileLocked(true /* recompute */);
        }
        mListContainer.setMaxDisplayedNotifications(maxNotifications);
        Stack<ExpandableNotificationRow> stack = new Stack<>();
        for (int i = N - 1; i >= 0; i--) {
            View child = mListContainer.getContainerChildAt(i);
@@ -439,8 +434,6 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            boolean isChildNotification =
                    mGroupManager.isChildInGroupWithSummary(entry.getSbn());

            row.setOnKeyguard(onKeyguard);

            if (!onKeyguard) {
                // If mAlwaysExpandNonGroupedNotification is false, then only expand the
                // very first notification and if it's not a child of grouped notifications.
+1 −2
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
                                        .build();
                        ExpandableNotificationRowController rowController =
                                component.getExpandableNotificationRowController();
                        rowController.init();
                        rowController.init(entry);
                        entry.setRowController(rowController);
                        bindRow(entry, row);
                        updateRow(entry, row);
@@ -160,7 +160,6 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
        mNotificationRemoteInputManager.bindRow(row);
        row.setOnActivatedListener(mPresenter);
        entry.setRow(row);
        row.setEntry(entry);
        mNotifBindPipeline.manageRow(entry, row);
        mBindRowCallback.onBindRow(row);
    }
+11 −19
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        void onExpansionChanged(boolean isExpanded);
    }

    private StatusBarStateController mStatusbarStateController;
    private StatusBarStateController mStatusBarStateController;
    private KeyguardBypassController mBypassController;
    private LayoutListener mLayoutListener;
    private RowContentBindStage mRowContentBindStage;
@@ -462,16 +462,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    /**
     * Set the entry for the row.
     *
     * @param entry the entry this row is tied to
     */
    public void setEntry(@NonNull NotificationEntry entry) {
        mEntry = entry;
        cacheIsSystemNotification();
    }

    /**
     * Marks a content view as freeable, setting it so that future inflations do not reinflate
     * and ensuring that the view is freed when it is safe to remove.
@@ -1584,6 +1574,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     * Initialize row.
     */
    public void initialize(
            NotificationEntry entry,
            String appName,
            String notificationKey,
            ExpansionLogger logger,
@@ -1598,6 +1589,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            StatusBarStateController statusBarStateController,
            PeopleNotificationIdentifier peopleNotificationIdentifier,
            OnUserInteractionCallback onUserInteractionCallback) {
        mEntry = entry;
        mAppName = appName;
        if (mMenuRow == null) {
            mMenuRow = new NotificationMenuRow(mContext, peopleNotificationIdentifier);
@@ -1616,12 +1608,15 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mMediaManager = notificationMediaManager;
        setOnFeedbackClickListener(onFeedbackClickListener);
        mFalsingManager = falsingManager;
        mStatusbarStateController = statusBarStateController;
        mStatusBarStateController = statusBarStateController;

        mPeopleNotificationIdentifier = peopleNotificationIdentifier;
        for (NotificationContentView l : mLayouts) {
            l.setPeopleNotificationIdentifier(mPeopleNotificationIdentifier);
        }
        mOnUserInteractionCallback = onUserInteractionCallback;

        cacheIsSystemNotification();
    }

    private void initDimens() {
@@ -2134,8 +2129,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
     */
    @Override
    public boolean isSoundEffectsEnabled() {
        final boolean mute = mStatusbarStateController != null
                && mStatusbarStateController.isDozing()
        final boolean mute = mStatusBarStateController != null
                && mStatusBarStateController.isDozing()
                && mSecureStateProvider != null &&
                !mSecureStateProvider.getAsBoolean();
        return !mute && super.isSoundEffectsEnabled();
@@ -2259,10 +2254,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        }
    }

    /**
     * @param onKeyguard whether to prevent notification expansion
     */
    public void setOnKeyguard(boolean onKeyguard) {
    void setOnKeyguard(boolean onKeyguard) {
        if (onKeyguard != mOnKeyguard) {
            boolean wasAboveShelf = isAboveShelf();
            final boolean wasExpanded = isExpanded();
@@ -2331,7 +2323,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
    }

    private boolean isDozing() {
        return mStatusbarStateController != null && mStatusbarStateController.isDozing();
        return mStatusBarStateController != null && mStatusBarStateController.isDozing();
    }

    @Override
Loading