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

Commit 1c8ed43c authored by Jeff DeCew's avatar Jeff DeCew
Browse files

New Pipeline: LockscreenUserManager now uses the CommonNotifCollection for queries

Fixes: 204764178
Test: atest NotificationLockscreenUserManagerTest NotificationLockscreenUserManagerGoogleTest
Change-Id: I456135f23ee0949faec0202250e26a632dc8a5c5
parent b8da5df6
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -51,12 +51,12 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -89,8 +89,8 @@ public class NotificationLockscreenUserManagerImpl implements
    // Lazy
    private NotificationEntryManager mEntryManager;

    private final FeatureFlags mFeatureFlags;
    private final Lazy<NotificationVisibilityProvider> mVisibilityProviderLazy;
    private final Lazy<CommonNotifCollection> mCommonNotifCollectionLazy;
    private final DevicePolicyManager mDevicePolicyManager;
    private final SparseBooleanArray mLockscreenPublicMode = new SparseBooleanArray();
    private final SparseBooleanArray mUsersWithSeperateWorkChallenge = new SparseBooleanArray();
@@ -195,11 +195,11 @@ public class NotificationLockscreenUserManagerImpl implements

    @Inject
    public NotificationLockscreenUserManagerImpl(Context context,
            FeatureFlags featureFlags,
            BroadcastDispatcher broadcastDispatcher,
            DevicePolicyManager devicePolicyManager,
            UserManager userManager,
            Lazy<NotificationVisibilityProvider> visibilityProviderLazy,
            Lazy<CommonNotifCollection> commonNotifCollectionLazy,
            NotificationClickNotifier clickNotifier,
            KeyguardManager keyguardManager,
            StatusBarStateController statusBarStateController,
@@ -208,12 +208,12 @@ public class NotificationLockscreenUserManagerImpl implements
            KeyguardStateController keyguardStateController,
            DumpManager dumpManager) {
        mContext = context;
        mFeatureFlags = featureFlags;
        mMainHandler = mainHandler;
        mDevicePolicyManager = devicePolicyManager;
        mUserManager = userManager;
        mCurrentUserId = ActivityManager.getCurrentUser();
        mVisibilityProviderLazy = visibilityProviderLazy;
        mCommonNotifCollectionLazy = commonNotifCollectionLazy;
        mClickNotifier = clickNotifier;
        statusBarStateController.addCallback(this);
        mLockPatternUtils = new LockPatternUtils(context);
@@ -339,22 +339,18 @@ public class NotificationLockscreenUserManagerImpl implements
     * package-specific override.
     */
    public boolean shouldHideNotifications(String key) {
        // TODO(b/204764178): support new pipeline
        mFeatureFlags.checkLegacyPipelineEnabled();
        if (getEntryManager() == null) {
            Log.wtf(TAG, "mEntryManager was null!", new Throwable());
        if (mCommonNotifCollectionLazy.get() == null) {
            Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable());
            return true;
        }
        NotificationEntry visibleEntry = getEntryManager().getActiveNotificationUnfiltered(key);
        NotificationEntry visibleEntry = mCommonNotifCollectionLazy.get().getEntry(key);
        return isLockscreenPublicMode(mCurrentUserId) && visibleEntry != null
                && visibleEntry.getRanking().getLockscreenVisibilityOverride() == VISIBILITY_SECRET;
    }

    public boolean shouldShowOnKeyguard(NotificationEntry entry) {
        // TODO(b/204764178): support new pipeline
        mFeatureFlags.checkLegacyPipelineEnabled();
        if (getEntryManager() == null) {
            Log.wtf(TAG, "mEntryManager was null!", new Throwable());
        if (mCommonNotifCollectionLazy.get() == null) {
            Log.wtf(TAG, "mCommonNotifCollectionLazy was null!", new Throwable());
            return false;
        }
        for (int i = 0; i < mKeyguardSuppressors.size(); i++) {
@@ -526,13 +522,11 @@ public class NotificationLockscreenUserManagerImpl implements
    }

    private boolean packageHasVisibilityOverride(String key) {
        // TODO(b/204764178): support new pipeline
        mFeatureFlags.checkLegacyPipelineEnabled();
        if (getEntryManager() == null) {
        if (mCommonNotifCollectionLazy.get() == null) {
            Log.wtf(TAG, "mEntryManager was null!", new Throwable());
            return true;
        }
        NotificationEntry entry = getEntryManager().getActiveNotificationUnfiltered(key);
        NotificationEntry entry = mCommonNotifCollectionLazy.get().getEntry(key);
        return entry != null
                && entry.getRanking().getLockscreenVisibilityOverride() 
                == Notification.VISIBILITY_PRIVATE;
+14 −2
Original line number Diff line number Diff line
@@ -721,8 +721,12 @@ public class NotificationEntryManager implements
     * @param reason why the notifications are updating
     */
    public void updateNotifications(String reason) {
        if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            mLogger.logUseWhileNewPipelineActive("updateNotifications", reason);
            return;
        }
        reapplyFilterAndSort(reason);
        if (mPresenter != null && !mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
        if (mPresenter != null) {
            mPresenter.updateNotificationViews(reason);
        }
    }
@@ -880,11 +884,19 @@ public class NotificationEntryManager implements

    /** Resorts / filters the current notification set with the current RankingMap */
    public void reapplyFilterAndSort(String reason) {
        if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            mLogger.logUseWhileNewPipelineActive("reapplyFilterAndSort", reason);
            return;
        }
        updateRankingAndSort(mRanker.getRankingMap(), reason);
    }

    /** Calls to NotificationRankingManager and updates mSortedAndFiltered */
    private void updateRankingAndSort(@NonNull RankingMap rankingMap, String reason) {
        if (mFeatureFlags.isNewNotifPipelineRenderingEnabled()) {
            mLogger.logUseWhileNewPipelineActive("updateRankingAndSort", reason);
            return;
        }
        mSortedAndFiltered.clear();
        mSortedAndFiltered.addAll(mRanker.updateRanking(
                rankingMap, mActiveNotifications.values(), reason));
@@ -892,7 +904,7 @@ public class NotificationEntryManager implements

    /** dump the current active notification list. Called from StatusBar */
    public void dump(PrintWriter pw, String indent) {
        pw.println("NotificationEntryManager");
        pw.println("NotificationEntryManager (Legacy)");
        int filteredLen = mSortedAndFiltered.size();
        pw.print(indent);
        pw.println("active notifications: " + filteredLen);
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogLevel.DEBUG
import com.android.systemui.log.LogLevel.INFO
import com.android.systemui.log.LogLevel.WARNING
import com.android.systemui.log.dagger.NotificationLog
import javax.inject.Inject

@@ -95,6 +96,15 @@ class NotificationEntryManagerLogger @Inject constructor(
            "FILTER AND SORT reason=$str1"
        })
    }

    fun logUseWhileNewPipelineActive(method: String, reason: String) {
        buffer.log(TAG, WARNING, {
            str1 = method
            str2 = reason
        }, {
            "While running New Pipeline: $str1(reason=$str2)"
        })
    }
}

private const val TAG = "NotificationEntryMgr"
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -57,12 +57,12 @@ import com.android.systemui.Dependency;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationLockscreenUserManager.KeyguardNotificationSuppressor;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -90,6 +90,8 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    @Mock
    private NotificationEntryManager mEntryManager;
    @Mock
    private CommonNotifCollection mNotifCollection;
    @Mock
    private DevicePolicyManager mDevicePolicyManager;
    @Mock
    private NotificationClickNotifier mClickNotifier;
@@ -100,8 +102,6 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
    @Mock
    private StatusBarStateController mStatusBarStateController;
    @Mock
    private FeatureFlags mFeatureFlags;
    @Mock
    private BroadcastDispatcher mBroadcastDispatcher;
    @Mock
    private KeyguardStateController mKeyguardStateController;
@@ -422,11 +422,11 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
        public TestNotificationLockscreenUserManager(Context context) {
            super(
                    context,
                    mFeatureFlags,
                    mBroadcastDispatcher,
                    mDevicePolicyManager,
                    mUserManager,
                    (() -> mVisibilityProvider),
                    (() -> mNotifCollection),
                    mClickNotifier,
                    NotificationLockscreenUserManagerTest.this.mKeyguardManager,
                    mStatusBarStateController,