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

Commit 9515cc29 authored by Ned Burns's avatar Ned Burns Committed by Android (Google) Code Review
Browse files

Merge changes I0bd67c64,Id0d2c323,I19e04771

* changes:
  Remove unused isUpdate argument in RowBinder
  Only NotificationListener gets to call updateNotificationRanking()
  Centralize reorder-on-priority-change logic
parents adf35773 f529ec2b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -47,7 +47,11 @@ public interface NotificationEntryListener {
    }

    /**
     * Called when a notification is updated, before any filtering of notifications have occurred.
     * Called when a notification is about to be updated. Notification- and ranking-derived fields
     * on the entry have already been updated but the following have not yet occurred:
     * (a) View binding (i.e. the associated view has not yet been updated / inflation has not yet
     *      been kicked off.
     * (b) Notification filtering
     */
    default void onPreEntryUpdated(NotificationEntry entry) {
    }
+4 −8
Original line number Diff line number Diff line
@@ -230,7 +230,6 @@ public class NotificationEntryManager implements
                }
            }
        }
        entry.setLowPriorityStateUpdated(false);
    }

    @Override
@@ -346,8 +345,7 @@ public class NotificationEntryManager implements

        Dependency.get(LeakDetector.class).trackInstance(entry);
        // Construct the expanded view.
        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
                mNotificationData.get(entry.key) != null);
        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification));

        abortExistingInflation(key);

@@ -384,13 +382,11 @@ public class NotificationEntryManager implements

        mNotificationData.update(entry, ranking, notification);

        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
                mNotificationData.get(entry.key) != null);

        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onPreEntryUpdated(entry);
        }

        getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification));
        updateNotifications();

        if (DEBUG) {
@@ -422,6 +418,7 @@ public class NotificationEntryManager implements
        }
    }

    @Override
    public void updateNotificationRanking(NotificationListenerService.RankingMap rankingMap) {
        List<NotificationEntry> entries = new ArrayList<>();
        entries.addAll(mNotificationData.getActiveNotifications());
@@ -447,8 +444,7 @@ public class NotificationEntryManager implements
                    entry,
                    oldImportances.get(entry.key),
                    oldAdjustments.get(entry.key),
                    NotificationUiAdjustment.extractFromNotificationEntry(entry),
                    mNotificationData.get(entry.key) != null);
                    NotificationUiAdjustment.extractFromNotificationEntry(entry));
        }

        updateNotifications();
+7 −13
Original line number Diff line number Diff line
@@ -124,8 +124,7 @@ public class NotificationRowBinder {
     */
    public void inflateViews(
            NotificationEntry entry,
            Runnable onDismissRunnable,
            boolean isUpdate)
            Runnable onDismissRunnable)
            throws InflationException {
        ViewGroup parent = mListContainer.getViewParentForNotification(entry);
        PackageManager pmUser = StatusBar.getPackageManagerForUser(mContext,
@@ -135,13 +134,13 @@ public class NotificationRowBinder {
        if (entry.rowExists()) {
            entry.updateIcons(mContext, sbn);
            entry.reset();
            updateNotification(entry, pmUser, sbn, entry.getRow(), isUpdate);
            updateNotification(entry, pmUser, sbn, entry.getRow());
        } else {
            entry.createIcons(mContext, sbn);
            new RowInflaterTask().inflate(mContext, parent, entry,
                    row -> {
                        bindRow(entry, pmUser, sbn, row, onDismissRunnable);
                        updateNotification(entry, pmUser, sbn, row, isUpdate);
                        updateNotification(entry, pmUser, sbn, row);
                    });
        }
    }
@@ -197,15 +196,14 @@ public class NotificationRowBinder {
            NotificationEntry entry,
            @Nullable Integer oldImportance,
            NotificationUiAdjustment oldAdjustment,
            NotificationUiAdjustment newAdjustment,
            boolean isUpdate) {
            NotificationUiAdjustment newAdjustment) {
        if (NotificationUiAdjustment.needReinflate(oldAdjustment, newAdjustment)) {
            if (entry.rowExists()) {
                entry.reset();
                PackageManager pmUser = StatusBar.getPackageManagerForUser(
                        mContext,
                        entry.notification.getUser().getIdentifier());
                updateNotification(entry, pmUser, entry.notification, entry.getRow(), isUpdate);
                updateNotification(entry, pmUser, entry.notification, entry.getRow());
            } else {
                // Once the RowInflaterTask is done, it will pick up the updated entry, so
                // no-op here.
@@ -224,12 +222,8 @@ public class NotificationRowBinder {
            NotificationEntry entry,
            PackageManager pmUser,
            StatusBarNotification sbn,
            ExpandableNotificationRow row,
            boolean isUpdate) {
        boolean isLowPriority = entry.ambient;
        boolean wasLowPriority = row.isLowPriority();
        row.setIsLowPriority(isLowPriority);
        row.setLowPriorityStateUpdated(isUpdate && (wasLowPriority != isLowPriority));
            ExpandableNotificationRow row) {
        row.setIsLowPriority(entry.ambient);
        // bind the click event to the content area
        checkNotNull(mNotificationClicker).register(row, sbn);

+15 −12
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
    private boolean mReorderingAllowed;
    private VisibilityLocationProvider mVisibilityLocationProvider;
    private ArraySet<View> mAllowedReorderViews = new ArraySet<>();
    private ArraySet<View> mLowPriorityReorderingViews = new ArraySet<>();
    private ArraySet<NotificationEntry> mLowPriorityReorderingViews = new ArraySet<>();
    private ArraySet<View> mAddedChildren = new ArraySet<>();
    private boolean mPulsing;

@@ -53,13 +53,20 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
    public VisualStabilityManager(NotificationEntryManager notificationEntryManager) {
        notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
            @Override
            public void onEntryReinflated(NotificationEntry entry) {
                if (entry.hasLowPriorityStateUpdated()) {
                    onLowPriorityUpdated(entry);
                    if (mPresenter != null) {
                        mPresenter.updateNotificationViews();
            public void onPreEntryUpdated(NotificationEntry entry) {
                final boolean mAmbientStateHasChanged =
                        entry.ambient != entry.getRow().isLowPriority();
                if (mAmbientStateHasChanged) {
                    mLowPriorityReorderingViews.add(entry);
                }
            }

            @Override
            public void onPostEntryUpdated(NotificationEntry entry) {
                // This line is technically not required as we'll get called as the hierarchy
                // manager will call onReorderingFinished() immediately before this.
                // TODO: Find a way to make this relationship more explicit
                mLowPriorityReorderingViews.remove(entry);
            }
        });
    }
@@ -142,7 +149,7 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
        if (mAddedChildren.contains(row)) {
            return true;
        }
        if (mLowPriorityReorderingViews.contains(row)) {
        if (mLowPriorityReorderingViews.contains(row.getEntry())) {
            return true;
        }
        if (mAllowedReorderViews.contains(row)
@@ -172,10 +179,6 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
        }
    }

    private void onLowPriorityUpdated(NotificationEntry entry) {
        mLowPriorityReorderingViews.add(entry.getRow());
    }

    /**
     * Notify the visual stability manager that a new view was added and should be allowed to
     * reorder next time.
+0 −8
Original line number Diff line number Diff line
@@ -622,10 +622,6 @@ public final class NotificationEntry {
        return null;
    }

    public boolean hasLowPriorityStateUpdated() {
        return row != null && row.hasLowPriorityStateUpdated();
    }

    public void removeRow() {
        if (row != null) row.setRemoved();
    }
@@ -650,10 +646,6 @@ public final class NotificationEntry {
        return parent == null;
    }

    public void setLowPriorityStateUpdated(boolean updated) {
        if (row != null) row.setLowPriorityStateUpdated(updated);
    }

    /**
     * @return Can the underlying notification be cleared? This can be different from whether the
     *         notification can be dismissed in case notifications are sensitive on the lockscreen.
Loading