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

Commit 2b4c3a08 authored by Eliot Courtney's avatar Eliot Courtney
Browse files

Split NotificationViewHierarchyManager out of StatusBar.

NotificationViewHierarchyManager handles bundling and unbundling of
notifications. In doing so, which notifications are parents/children of
the other can change. NotificationViewHierarchyManager makes sure the
view hierarchy of the notifications matches their grouping.

Bug: 63874929
Bug: 62602530
Test: runtest systemui
Test: Compile and run
Change-Id: Ia1c8ed75d4eb8df52897c5d6aa0713f8335b2a19
parent a6d8cf29
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -32,12 +32,14 @@ import com.android.systemui.qs.QSTileHost;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationEntryManager;
import com.android.systemui.statusbar.NotificationGutsManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLogger;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.LightBarController;
@@ -122,6 +124,7 @@ public class SystemUIFactory {
            Context context) {
        providers.put(NotificationLockscreenUserManager.class,
                () -> new NotificationLockscreenUserManager(context));
        providers.put(VisualStabilityManager.class, VisualStabilityManager::new);
        providers.put(NotificationGroupManager.class, NotificationGroupManager::new);
        providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context));
        providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(
@@ -134,6 +137,12 @@ public class SystemUIFactory {
        providers.put(NotificationLogger.class, () -> new NotificationLogger(
                Dependency.get(NotificationListener.class),
                Dependency.get(UiOffloadThread.class)));
        providers.put(NotificationViewHierarchyManager.class, () ->
                new NotificationViewHierarchyManager(
                        Dependency.get(NotificationLockscreenUserManager.class),
                        Dependency.get(NotificationGroupManager.class),
                        Dependency.get(VisualStabilityManager.class),
                        context));
        providers.put(NotificationEntryManager.class, () ->
                new NotificationEntryManager(
                        Dependency.get(NotificationLockscreenUserManager.class),
@@ -145,9 +154,8 @@ public class SystemUIFactory {
                        Dependency.get(NotificationListener.class),
                        Dependency.get(MetricsLogger.class),
                        Dependency.get(DeviceProvisionedController.class),
                        Dependency.get(VisualStabilityManager.class),
                        Dependency.get(UiOffloadThread.class),
                        context));
        providers.put(NotificationListener.class, () -> new NotificationListener(
                Dependency.get(NotificationRemoteInputManager.class), context));
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;

@@ -43,10 +44,11 @@ public class CarNotificationEntryManager extends NotificationEntryManager {
            NotificationListener notificationListener,
            MetricsLogger metricsLogger,
            DeviceProvisionedController deviceProvisionedController,
            VisualStabilityManager visualStabilityManager,
            UiOffloadThread uiOffloadThread, Context context) {
        super(lockscreenUserManager, groupManager, gutsManager, remoteInputManager, mediaManager,
                foregroundServiceController, notificationListener, metricsLogger,
                deviceProvisionedController, uiOffloadThread, context);
                deviceProvisionedController, visualStabilityManager, uiOffloadThread, context);
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.volume.car.CarVolumeDialogController;
@@ -54,6 +55,7 @@ public class CarSystemUIFactory extends SystemUIFactory {
                Dependency.get(NotificationListener.class),
                Dependency.get(MetricsLogger.class),
                Dependency.get(DeviceProvisionedController.class),
                Dependency.get(VisualStabilityManager.class),
                Dependency.get(UiOffloadThread.class),
                context));
    }
+18 −15
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.util.leak.LeakDetector;

import java.io.FileDescriptor;
@@ -75,7 +74,8 @@ import java.util.List;
 * Notification.*Manager objects.
 */
public class NotificationEntryManager implements Dumpable, NotificationInflater.InflationCallback,
        ExpandableNotificationRow.ExpansionLogger, NotificationUpdateHandler {
        ExpandableNotificationRow.ExpansionLogger, NotificationUpdateHandler,
        VisualStabilityManager.Callback {
    private static final String TAG = "NotificationEntryManager";
    protected static final boolean DEBUG = false;
    protected static final boolean ENABLE_HEADS_UP = true;
@@ -90,6 +90,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    protected final NotificationMediaManager mMediaManager;
    protected final MetricsLogger mMetricsLogger;
    protected final DeviceProvisionedController mDeviceProvisionedController;
    protected final VisualStabilityManager mVisualStabilityManager;
    protected final UiOffloadThread mUiOffloadThread;
    protected final ForegroundServiceController mForegroundServiceController;
    protected final NotificationListener mNotificationListener;
@@ -100,7 +101,6 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    protected IStatusBarService mBarService;
    protected NotificationPresenter mPresenter;
    protected Callback mCallback;
    protected NotificationStackScrollLayout mStackScroller;
    protected PowerManager mPowerManager;
    protected SystemServicesProxy mSystemServicesProxy;
    protected NotificationListenerService.RankingMap mLatestRankingMap;
@@ -109,7 +109,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    protected ContentObserver mHeadsUpObserver;
    protected boolean mUseHeadsUp = false;
    protected boolean mDisableNotificationAlerts;
    protected VisualStabilityManager mVisualStabilityManager;
    protected NotificationListContainer mListContainer;

    private final class NotificationClicker implements View.OnClickListener {

@@ -214,6 +214,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
            NotificationListener notificationListener,
            MetricsLogger metricsLogger,
            DeviceProvisionedController deviceProvisionedController,
            VisualStabilityManager visualStabilityManager,
            UiOffloadThread uiOffloadThread, Context context) {
        mLockscreenUserManager = lockscreenUserManager;
        mGroupManager = groupManager;
@@ -224,6 +225,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        mNotificationListener = notificationListener;
        mMetricsLogger = metricsLogger;
        mDeviceProvisionedController = deviceProvisionedController;
        mVisualStabilityManager = visualStabilityManager;
        mUiOffloadThread = uiOffloadThread;
        mContext = context;
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
@@ -233,19 +235,15 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        mSystemServicesProxy = SystemServicesProxy.getInstance(mContext);
    }

    // TODO: Remove dependency on NotificationStackScrollLayout
    public void setUpWithPresenter(NotificationPresenter presenter,
            NotificationStackScrollLayout stackScroller,
            Callback callback,
            VisualStabilityManager visualStabilityManager,
            NotificationListContainer listContainer, Callback callback,
            HeadsUpManager headsUpManager) {
        mPresenter = presenter;
        mCallback = callback;
        mStackScroller = stackScroller;
        mVisualStabilityManager = visualStabilityManager;
        mNotificationData = new NotificationData(presenter);
        mHeadsUpManager = headsUpManager;
        mNotificationData.setHeadsUpManager(mHeadsUpManager);
        mListContainer = listContainer;

        mHeadsUpObserver = new ContentObserver(mPresenter.getHandler()) {
            @Override
@@ -301,6 +299,11 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        });
    }

    @Override
    public void onReorderingAllowed() {
        updateNotifications();
    }

    private boolean shouldSuppressFullScreenIntent(String key) {
        if (mPresenter.isDeviceInVrMode()) {
            return true;
@@ -379,7 +382,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
            int dismissalSurface = NotificationStats.DISMISSAL_SHADE;
            if (isHeadsUp(n.getKey())) {
                dismissalSurface = NotificationStats.DISMISSAL_PEEK;
            } else if (mStackScroller.hasPulsingNotifications()) {
            } else if (mListContainer.hasPulsingNotifications()) {
                dismissalSurface = NotificationStats.DISMISSAL_AOD;
            }
            mBarService.onNotificationClear(pkg, tag, id, userId, n.getKey(), dismissalSurface);
@@ -536,7 +539,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.

        if (entry != null && entry.row != null) {
            entry.row.setRemoved();
            mStackScroller.cleanUpViewState(entry.row);
            mListContainer.cleanUpViewState(entry.row);
        }
        // Let's remove the children if this was a summary
        handleGroupSummaryRemoved(key);
@@ -662,7 +665,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        Dependency.get(LeakDetector.class).trackInstance(entry);
        entry.createIcons(mContext, sbn);
        // Construct the expanded view.
        inflateViews(entry, mStackScroller);
        inflateViews(entry, mListContainer.getViewParentForNotification(entry));
        return entry;
    }

@@ -752,7 +755,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        mGroupManager.onEntryUpdated(entry, oldNotification);

        entry.updateIcons(mContext, notification);
        inflateViews(entry, mStackScroller);
        inflateViews(entry, mListContainer.getViewParentForNotification(entry));

        mForegroundServiceController.updateNotification(notification,
                mNotificationData.getImportance(key));
@@ -766,7 +769,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        if (!notification.isClearable()) {
            // The user may have performed a dismiss action on the notification, since it's
            // not clearable we should snap it back.
            mStackScroller.snapViewIfNeeded(entry.row);
            mListContainer.snapViewIfNeeded(entry.row);
        }

        if (DEBUG) {
+8 −10
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.systemui.Dumpable;
import com.android.systemui.Interpolators;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;

import java.io.FileDescriptor;
@@ -76,7 +75,7 @@ public class NotificationGutsManager implements Dumpable {

    // TODO: Create NotificationListContainer interface and use it instead of
    // NotificationStackScrollLayout here
    private NotificationStackScrollLayout mStackScroller;
    private NotificationListContainer mListContainer;
    private NotificationInfo.CheckSaveListener mCheckSaveListener;
    private OnSettingsClickListener mOnSettingsClickListener;
    private String mKeyToRemoveOnGutsClosed;
@@ -96,12 +95,11 @@ public class NotificationGutsManager implements Dumpable {
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
    }

    public void setUp(NotificationPresenter presenter,
            NotificationStackScrollLayout stackScroller,
    public void setUp(NotificationPresenter presenter, NotificationListContainer listContainer,
            NotificationInfo.CheckSaveListener checkSaveListener,
            OnSettingsClickListener onSettingsClickListener) {
        mPresenter = presenter;
        mStackScroller = stackScroller;
        mListContainer = listContainer;
        mCheckSaveListener = checkSaveListener;
        mOnSettingsClickListener = onSettingsClickListener;
    }
@@ -158,7 +156,7 @@ public class NotificationGutsManager implements Dumpable {
        final NotificationGuts guts = row.getGuts();
        guts.setClosedListener((NotificationGuts g) -> {
            if (!g.willBeRemoved() && !row.isRemoved()) {
                mStackScroller.onHeightChanged(
                mListContainer.onHeightChanged(
                        row, !mPresenter.isPresenterFullyCollapsed() /* needsAnimation */);
            }
            if (mNotificationGutsExposed == g) {
@@ -176,11 +174,11 @@ public class NotificationGutsManager implements Dumpable {
        View gutsView = item.getGutsView();
        if (gutsView instanceof NotificationSnooze) {
            NotificationSnooze snoozeGuts = (NotificationSnooze) gutsView;
            snoozeGuts.setSnoozeListener(mStackScroller.getSwipeActionHelper());
            snoozeGuts.setSnoozeListener(mListContainer.getSwipeActionHelper());
            snoozeGuts.setStatusBarNotification(sbn);
            snoozeGuts.setSnoozeOptions(row.getEntry().snoozeCriteria);
            guts.setHeightChangedListener((NotificationGuts g) -> {
                mStackScroller.onHeightChanged(row, row.isShown() /* needsAnimation */);
                mListContainer.onHeightChanged(row, row.isShown() /* needsAnimation */);
            });
        }

@@ -258,7 +256,7 @@ public class NotificationGutsManager implements Dumpable {
            mNotificationGutsExposed.closeControls(removeLeavebehinds, removeControls, x, y, force);
        }
        if (resetMenu) {
            mStackScroller.resetExposedMenuView(false /* animate */, true /* force */);
            mListContainer.resetExposedMenuView(false /* animate */, true /* force */);
        }
    }

@@ -351,7 +349,7 @@ public class NotificationGutsManager implements Dumpable {
                                !mAccessibilityManager.isTouchExplorationEnabled());
                guts.setExposed(true /* exposed */, needsFalsingProtection);
                row.closeRemoteInput();
                mStackScroller.onHeightChanged(row, true /* needsAnimation */);
                mListContainer.onHeightChanged(row, true /* needsAnimation */);
                mNotificationGutsExposed = guts;
                mGutsMenuItem = item;
            }
Loading