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

Commit f48d39fe authored by Ned Burns's avatar Ned Burns Committed by Automerger Merge Worker
Browse files

Merge changes from topic "dedupe-lockscreen" into sc-dev am: f540d787

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14473079

Change-Id: Iab80fff9ee6e1c23ad3bda5ba2ad607ec92d7432
parents fc253d84 f540d787
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -49,4 +49,6 @@
    <bool name="flag_ongoing_call_status_bar_chip">true</bool>

    <bool name="flag_smartspace">false</bool>

    <bool name="flag_smartspace_deduping">true</bool>
</resources>
+4 −0
Original line number Diff line number Diff line
@@ -92,4 +92,8 @@ public class FeatureFlags {
    public boolean isSmartspaceEnabled() {
        return mFlagReader.isEnabled(R.bool.flag_smartspace);
    }

    public boolean isSmartspaceDedupingEnabled() {
        return isSmartspaceEnabled() && mFlagReader.isEnabled(R.bool.flag_smartspace_deduping);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -49,6 +49,12 @@ public interface NotificationLockscreenUserManager {
    /** Adds a listener to be notified when the current user changes. */
    void addUserChangedListener(UserChangedListener listener);

    /**
     * Registers a [KeyguardNotificationSuppressor] that will be consulted during
     * {@link #shouldShowOnKeyguard(NotificationEntry)}
     */
    void addKeyguardNotificationSuppressor(KeyguardNotificationSuppressor suppressor);

    /**
     * Removes a listener previously registered with
     * {@link #addUserChangedListener(UserChangedListener)}
@@ -88,4 +94,9 @@ public interface NotificationLockscreenUserManager {
        default void onUserChanged(int userId) {}
        default void onCurrentProfilesChanged(SparseArray<UserInfo> currentProfiles) {}
    }

    /** Used to hide notifications on the lockscreen */
    interface KeyguardNotificationSuppressor {
        boolean shouldSuppressOnKeyguard(NotificationEntry entry);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public class NotificationLockscreenUserManagerImpl implements
    private LockPatternUtils mLockPatternUtils;
    protected KeyguardManager mKeyguardManager;
    private int mState = StatusBarState.SHADE;
    private List<KeyguardNotificationSuppressor> mKeyguardSuppressors = new ArrayList<>();

    protected final BroadcastReceiver mAllUsersReceiver = new BroadcastReceiver() {
        @Override
@@ -343,6 +344,11 @@ public class NotificationLockscreenUserManagerImpl implements
            Log.wtf(TAG, "mEntryManager was null!", new Throwable());
            return false;
        }
        for (int i = 0; i < mKeyguardSuppressors.size(); i++) {
            if (mKeyguardSuppressors.get(i).shouldSuppressOnKeyguard(entry)) {
                return false;
            }
        }
        boolean exceedsPriorityThreshold;
        if (hideSilentNotificationsOnLockscreen()) {
            exceedsPriorityThreshold =
@@ -620,6 +626,11 @@ public class NotificationLockscreenUserManagerImpl implements
        mListeners.add(listener);
    }

    @Override
    public void addKeyguardNotificationSuppressor(KeyguardNotificationSuppressor suppressor) {
        mKeyguardSuppressors.add(suppressor);
    }

    @Override
    public void removeUserChangedListener(UserChangedListener listener) {
        mListeners.remove(listener);
+11 −19
Original line number Diff line number Diff line
@@ -46,8 +46,9 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationRemoveInterceptor;
import com.android.systemui.statusbar.NotificationUiAdjustment;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
import com.android.systemui.statusbar.notification.collection.legacy.LegacyNotificationRanker;
import com.android.systemui.statusbar.notification.collection.legacy.LegacyNotificationRankerStub;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
@@ -138,12 +139,11 @@ public class NotificationEntryManager implements
    private final LeakDetector mLeakDetector;
    private final List<NotifCollectionListener> mNotifCollectionListeners = new ArrayList<>();

    private final KeyguardEnvironment mKeyguardEnvironment;
    private final NotificationGroupManagerLegacy mGroupManager;
    private final Lazy<NotificationRankingManager> mRankingManager;
    private final FeatureFlags mFeatureFlags;
    private final ForegroundServiceDismissalFeatureController mFgsFeatureController;

    private LegacyNotificationRanker mRanker = new LegacyNotificationRankerStub();
    private NotificationPresenter mPresenter;
    private RankingMap mLatestRankingMap;

@@ -200,8 +200,6 @@ public class NotificationEntryManager implements
    public NotificationEntryManager(
            NotificationEntryManagerLogger logger,
            NotificationGroupManagerLegacy groupManager,
            Lazy<NotificationRankingManager> rankingManager,
            KeyguardEnvironment keyguardEnvironment,
            FeatureFlags featureFlags,
            Lazy<NotificationRowBinder> notificationRowBinderLazy,
            Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
@@ -211,8 +209,6 @@ public class NotificationEntryManager implements
    ) {
        mLogger = logger;
        mGroupManager = groupManager;
        mRankingManager = rankingManager;
        mKeyguardEnvironment = keyguardEnvironment;
        mFeatureFlags = featureFlags;
        mNotificationRowBinderLazy = notificationRowBinderLazy;
        mRemoteInputManagerLazy = notificationRemoteInputManagerLazy;
@@ -226,6 +222,10 @@ public class NotificationEntryManager implements
        notificationListener.addNotificationHandler(mNotifListener);
    }

    public void setRanker(LegacyNotificationRanker ranker) {
        mRanker = ranker;
    }

    /** Adds a {@link NotificationEntryListener}. */
    public void addNotificationEntryListener(NotificationEntryListener listener) {
        mNotificationEntryListeners.add(listener);
@@ -419,7 +419,7 @@ public class NotificationEntryManager implements

        mActiveNotifications.put(entry.getKey(), entry);
        mGroupManager.onEntryAdded(entry);
        updateRankingAndSort(mRankingManager.get().getRankingMap(), "addEntryInternalInternal");
        updateRankingAndSort(mRanker.getRankingMap(), "addEntryInternalInternal");
    }

    /**
@@ -698,13 +698,6 @@ public class NotificationEntryManager implements

        updateNotifications("updateNotificationInternal");

        if (DEBUG) {
            // Is this for you?
            boolean isForCurrentUser = mKeyguardEnvironment
                    .isNotificationForCurrentProfiles(notification);
            Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
        }

        for (NotificationEntryListener listener : mNotificationEntryListeners) {
            listener.onPostEntryUpdated(entry);
        }
@@ -862,8 +855,7 @@ public class NotificationEntryManager implements
        final int len = mActiveNotifications.size();
        for (int i = 0; i < len; i++) {
            NotificationEntry entry = mActiveNotifications.valueAt(i);
            final StatusBarNotification sbn = entry.getSbn();
            if (!mKeyguardEnvironment.isNotificationForCurrentProfiles(sbn)) {
            if (!mRanker.isNotificationForCurrentProfiles(entry)) {
                continue;
            }
            filtered.add(entry);
@@ -886,13 +878,13 @@ public class NotificationEntryManager implements

    /** Resorts / filters the current notification set with the current RankingMap */
    public void reapplyFilterAndSort(String reason) {
        updateRankingAndSort(mRankingManager.get().getRankingMap(), reason);
        updateRankingAndSort(mRanker.getRankingMap(), reason);
    }

    /** Calls to NotificationRankingManager and updates mSortedAndFiltered */
    private void updateRankingAndSort(@NonNull RankingMap rankingMap, String reason) {
        mSortedAndFiltered.clear();
        mSortedAndFiltered.addAll(mRankingManager.get().updateRanking(
        mSortedAndFiltered.addAll(mRanker.updateRanking(
                rankingMap, mActiveNotifications.values(), reason));
    }

Loading