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

Commit 8c6945bd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "b204183781_notif_vis_provider_master"

* changes:
  New Pipeline: Update NotificationLogger to use NotifPipeline
  New Pipeline: LockscreenUserManager now uses the CommonNotifCollection for queries
  New Pipeline: Add a NotificationVisibilityProvider to support both pipelines
parents b9e6bf9b 5385b5c7
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinderImpl;
import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
import com.android.systemui.statusbar.notification.people.PeopleHubModule;
import com.android.systemui.statusbar.notification.row.dagger.ExpandableNotificationRowComponent;
@@ -206,7 +207,9 @@ public abstract class SystemUIModule {
            NotificationShadeWindowController notificationShadeWindowController,
            StatusBarStateController statusBarStateController, ShadeController shadeController,
            ConfigurationController configurationController,
            @Nullable IStatusBarService statusBarService, INotificationManager notificationManager,
            @Nullable IStatusBarService statusBarService,
            INotificationManager notificationManager,
            NotificationVisibilityProvider visibilityProvider,
            NotificationInterruptStateProvider interruptionStateProvider,
            ZenModeController zenModeController, NotificationLockscreenUserManager notifUserManager,
            NotificationGroupManagerLegacy groupManager, NotificationEntryManager entryManager,
@@ -215,6 +218,7 @@ public abstract class SystemUIModule {
        return Optional.ofNullable(BubblesManager.create(context, bubblesOptional,
                notificationShadeWindowController, statusBarStateController, shadeController,
                configurationController, statusBarService, notificationManager,
                visibilityProvider,
                interruptionStateProvider, zenModeController, notifUserManager,
                groupManager, entryManager, notifPipeline, sysUiState, featureFlags, dumpManager,
                sysuiMainExecutor));
+18 −14
Original line number Diff line number Diff line
@@ -36,8 +36,9 @@ import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.people.PeopleSpaceUtils;
import com.android.systemui.statusbar.CommandQueue;
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.wmshell.BubblesManager;
import com.android.wm.shell.bubbles.Bubble;

@@ -50,7 +51,8 @@ public class LaunchConversationActivity extends Activity {
    private static final String TAG = "PeopleSpaceLaunchConv";
    private static final boolean DEBUG = PeopleSpaceUtils.DEBUG;
    private UiEventLogger mUiEventLogger = new UiEventLoggerImpl();
    private NotificationEntryManager mNotificationEntryManager;
    private NotificationVisibilityProvider mVisibilityProvider;
    private CommonNotifCollection mCommonNotifCollection;
    private final Optional<BubblesManager> mBubblesManagerOptional;
    private final UserManager mUserManager;
    private boolean mIsForTesting;
@@ -60,11 +62,16 @@ public class LaunchConversationActivity extends Activity {
    private NotificationEntry mEntryToBubble;

    @Inject
    public LaunchConversationActivity(NotificationEntryManager notificationEntryManager,
            Optional<BubblesManager> bubblesManagerOptional, UserManager userManager,
            CommandQueue commandQueue) {
    public LaunchConversationActivity(
            NotificationVisibilityProvider visibilityProvider,
            CommonNotifCollection commonNotifCollection,
            Optional<BubblesManager> bubblesManagerOptional,
            UserManager userManager,
            CommandQueue commandQueue
    ) {
        super();
        mNotificationEntryManager = notificationEntryManager;
        mVisibilityProvider = visibilityProvider;
        mCommonNotifCollection = commonNotifCollection;
        mBubblesManagerOptional = bubblesManagerOptional;
        mUserManager = userManager;
        mCommandQueue = commandQueue;
@@ -128,8 +135,7 @@ public class LaunchConversationActivity extends Activity {
                // shortcutId, fallback to notificationKey if it exists.
                if (mBubblesManagerOptional.isPresent()) {
                    mBubble = mBubblesManagerOptional.get().getBubbleWithShortcutId(tileId);
                    NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(
                            notificationKey);
                    NotificationEntry entry = mCommonNotifCollection.getEntry(notificationKey);
                    if (mBubble != null || (entry != null && entry.canBubble())) {
                        mEntryToBubble = entry;
                        if (DEBUG) {
@@ -167,14 +173,14 @@ public class LaunchConversationActivity extends Activity {
        }

        try {
            if (mIStatusBarService == null || mNotificationEntryManager == null) {
            if (mIStatusBarService == null || mCommonNotifCollection == null) {
                if (DEBUG) {
                    Log.d(TAG, "Skipping clear notification: null services, key: " + notifKey);
                }
                return;
            }

            NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(notifKey);
            NotificationEntry entry = mCommonNotifCollection.getEntry(notifKey);
            if (entry == null || entry.getRanking() == null) {
                if (DEBUG) {
                    Log.d(TAG, "Skipping clear notification: NotificationEntry or its Ranking"
@@ -183,10 +189,8 @@ public class LaunchConversationActivity extends Activity {
                return;
            }

            int count = mNotificationEntryManager.getActiveNotificationsCount();
            int rank = entry.getRanking().getRank();
            NotificationVisibility notifVisibility = NotificationVisibility.obtain(notifKey,
                    rank, count, true);
            NotificationVisibility notifVisibility = mVisibilityProvider.obtain(entry, true);
            int rank = notifVisibility.rank;

            if (DEBUG) Log.d(TAG, "Clearing notification, key: " + notifKey + ", rank: " + rank);
            mIStatusBarService.onNotificationClear(
+19 −17
Original line number Diff line number Diff line
@@ -56,7 +56,8 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController.StateList
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.logging.NotificationLogger;
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;

@@ -67,6 +68,8 @@ import java.util.List;

import javax.inject.Inject;

import dagger.Lazy;

/**
 * Handles keeping track of the current user, profiles, and various things related to hiding
 * contents, redacting notifications, and the lockscreen.
@@ -86,6 +89,8 @@ public class NotificationLockscreenUserManagerImpl implements
    // Lazy
    private NotificationEntryManager mEntryManager;

    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();
@@ -162,15 +167,8 @@ public class NotificationLockscreenUserManagerImpl implements
                        }
                    }
                    if (notificationKey != null) {
                        NotificationEntry entry =
                                getEntryManager().getActiveNotificationUnfiltered(notificationKey);
                        final int count = getEntryManager().getActiveNotificationsCount();
                        final int rank = entry != null ? entry.getRanking().getRank() : 0;
                        NotificationVisibility.NotificationLocation location =
                                NotificationLogger.getNotificationLocation(entry);
                        final NotificationVisibility nv = NotificationVisibility.obtain(
                                notificationKey,
                                rank, count, true, location);
                        final NotificationVisibility nv = mVisibilityProviderLazy.get()
                                .obtain(notificationKey, true);
                        mClickNotifier.onNotificationClick(notificationKey, nv);
                    }
                    break;
@@ -200,6 +198,8 @@ public class NotificationLockscreenUserManagerImpl implements
            BroadcastDispatcher broadcastDispatcher,
            DevicePolicyManager devicePolicyManager,
            UserManager userManager,
            Lazy<NotificationVisibilityProvider> visibilityProviderLazy,
            Lazy<CommonNotifCollection> commonNotifCollectionLazy,
            NotificationClickNotifier clickNotifier,
            KeyguardManager keyguardManager,
            StatusBarStateController statusBarStateController,
@@ -212,6 +212,8 @@ public class NotificationLockscreenUserManagerImpl implements
        mDevicePolicyManager = devicePolicyManager;
        mUserManager = userManager;
        mCurrentUserId = ActivityManager.getCurrentUser();
        mVisibilityProviderLazy = visibilityProviderLazy;
        mCommonNotifCollectionLazy = commonNotifCollectionLazy;
        mClickNotifier = clickNotifier;
        statusBarStateController.addCallback(this);
        mLockPatternUtils = new LockPatternUtils(context);
@@ -337,18 +339,18 @@ public class NotificationLockscreenUserManagerImpl implements
     * package-specific override.
     */
    public boolean shouldHideNotifications(String key) {
        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) {
        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++) {
@@ -520,11 +522,11 @@ public class NotificationLockscreenUserManagerImpl implements
    }

    private boolean packageHasVisibilityOverride(String key) {
        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;
+6 −17
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ import com.android.systemui.statusbar.notification.collection.NotifPipeline;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats;
import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.phone.BiometricUnlockController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.LockscreenWallpaper;
@@ -113,6 +113,7 @@ public class NotificationMediaManager implements Dumpable {
        PAUSED_MEDIA_STATES.add(PlaybackState.STATE_CONNECTING);
    }

    private final NotificationVisibilityProvider mVisibilityProvider;
    private final NotificationEntryManager mEntryManager;
    private final MediaDataManager mMediaDataManager;
    private final NotifPipeline mNotifPipeline;
@@ -181,6 +182,7 @@ public class NotificationMediaManager implements Dumpable {
            Context context,
            Lazy<Optional<StatusBar>> statusBarOptionalLazy,
            Lazy<NotificationShadeWindowController> notificationShadeWindowController,
            NotificationVisibilityProvider visibilityProvider,
            NotificationEntryManager notificationEntryManager,
            MediaArtworkProcessor mediaArtworkProcessor,
            KeyguardBypassController keyguardBypassController,
@@ -201,6 +203,7 @@ public class NotificationMediaManager implements Dumpable {
        // TODO: use KeyguardStateController#isOccluded to remove this dependency
        mStatusBarOptionalLazy = statusBarOptionalLazy;
        mNotificationShadeWindowController = notificationShadeWindowController;
        mVisibilityProvider = visibilityProvider;
        mEntryManager = notificationEntryManager;
        mMainExecutor = mainExecutor;
        mMediaDataManager = mediaDataManager;
@@ -351,21 +354,10 @@ public class NotificationMediaManager implements Dumpable {
    }

    private DismissedByUserStats getDismissedByUserStats(NotificationEntry entry) {
        final int activeNotificationsCount;
        if (mUsingNotifPipeline) {
            activeNotificationsCount = mNotifPipeline.getShadeListCount();
        } else {
            activeNotificationsCount = mEntryManager.getActiveNotificationsCount();
        }
        return new DismissedByUserStats(
                NotificationStats.DISMISSAL_SHADE, // Add DISMISSAL_MEDIA?
                NotificationStats.DISMISS_SENTIMENT_NEUTRAL,
                NotificationVisibility.obtain(
                        entry.getKey(),
                        entry.getRanking().getRank(),
                        activeNotificationsCount,
                        /* visible= */ true,
                        NotificationLogger.getNotificationLocation(entry)));
                mVisibilityProvider.obtain(entry, /* visible= */ true));
    }

    private void removeEntry(NotificationEntry entry) {
@@ -406,10 +398,7 @@ public class NotificationMediaManager implements Dumpable {
            return null;
        }
        if (mUsingNotifPipeline) {
            // TODO(b/169655596): Either add O(1) lookup, or cache this icon?
            return mNotifPipeline.getAllNotifs().stream()
                .filter(entry -> Objects.equals(entry.getKey(), mMediaNotificationKey))
                .findAny()
            return Optional.ofNullable(mNotifPipeline.getEntry(mMediaNotificationKey))
                .map(entry -> entry.getIcons().getShelfIcon())
                .map(StatusBarIconView::getSourceIcon)
                .orElse(null);
+5 −8
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntry.EditedSuggestionInfo;
import com.android.systemui.statusbar.notification.collection.render.NotificationVisibilityProvider;
import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -95,6 +96,7 @@ public class NotificationRemoteInputManager implements Dumpable {
    // Dependencies:
    private final NotificationLockscreenUserManager mLockscreenUserManager;
    private final SmartReplyController mSmartReplyController;
    private final NotificationVisibilityProvider mVisibilityProvider;
    private final NotificationEntryManager mEntryManager;
    private final Handler mMainHandler;
    private final ActionClickLogger mLogger;
@@ -202,14 +204,7 @@ public class NotificationRemoteInputManager implements Dumpable {
                ViewGroup actionGroup = (ViewGroup) parent;
                buttonIndex = actionGroup.indexOfChild(view);
            }
            // TODO(b/204183781): get this from the current pipeline
            final int count = mEntryManager.getActiveNotificationsCount();
            final int rank = entry.getRanking().getRank();

            NotificationVisibility.NotificationLocation location =
                    NotificationLogger.getNotificationLocation(entry);
            final NotificationVisibility nv =
                    NotificationVisibility.obtain(key, rank, count, true, location);
            final NotificationVisibility nv = mVisibilityProvider.obtain(entry, true);
            mClickNotifier.onNotificationActionClick(key, buttonIndex, action, nv, false);
        }

@@ -263,6 +258,7 @@ public class NotificationRemoteInputManager implements Dumpable {
            FeatureFlags featureFlags,
            NotificationLockscreenUserManager lockscreenUserManager,
            SmartReplyController smartReplyController,
            NotificationVisibilityProvider visibilityProvider,
            NotificationEntryManager notificationEntryManager,
            RemoteInputNotificationRebuilder rebuilder,
            Lazy<Optional<StatusBar>> statusBarOptionalLazy,
@@ -276,6 +272,7 @@ public class NotificationRemoteInputManager implements Dumpable {
        mFeatureFlags = featureFlags;
        mLockscreenUserManager = lockscreenUserManager;
        mSmartReplyController = smartReplyController;
        mVisibilityProvider = visibilityProvider;
        mEntryManager = notificationEntryManager;
        mStatusBarOptionalLazy = statusBarOptionalLazy;
        mMainHandler = mainHandler;
Loading