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

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

Merge changes from topic "alert-group-transfer-fix"

* changes:
  Fix GroupAlertTransferHelper logic on update.
  Fix heads up/ambient content inflation w/ groups.
parents 0a91bc97 4b8bbda2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.LockscreenWallpaper;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
import com.android.systemui.statusbar.phone.ScrimController;
@@ -138,6 +139,8 @@ public class SystemUIFactory {
                () -> new NotificationLockscreenUserManagerImpl(context));
        providers.put(VisualStabilityManager.class, VisualStabilityManager::new);
        providers.put(NotificationGroupManager.class, NotificationGroupManager::new);
        providers.put(NotificationGroupAlertTransferHelper.class,
                NotificationGroupAlertTransferHelper::new);
        providers.put(NotificationMediaManager.class, () -> new NotificationMediaManager(context));
        providers.put(NotificationGutsManager.class, () -> new NotificationGutsManager(context));
        providers.put(AmbientPulseManager.class, () -> new AmbientPulseManager(context));
+21 −13
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar;

import static com.android.systemui.statusbar.notification.NotificationData.Entry;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Handler;
@@ -27,7 +29,7 @@ import android.util.Log;
import android.view.accessibility.AccessibilityEvent;

import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;

import java.util.stream.Stream;

@@ -46,8 +48,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
     * NotificationManagerService side, but we keep it to prevent the UI from looking weird and
     * will remove when possible. See {@link NotificationLifetimeExtender}
     */
    protected final ArraySet<NotificationData.Entry> mExtendedLifetimeAlertEntries =
            new ArraySet<>();
    protected final ArraySet<Entry> mExtendedLifetimeAlertEntries = new ArraySet<>();

    protected NotificationSafeToRemoveCallback mNotificationLifetimeFinishedCallback;
    protected int mMinimumDisplayTime;
@@ -60,7 +61,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
     * Adds the notification to be managed.
     * @param entry entry to show
     */
    public void showNotification(@NonNull NotificationData.Entry entry) {
    public void showNotification(@NonNull Entry entry) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "showNotification");
        }
@@ -139,7 +140,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
     * @return the entry
     */
    @Nullable
    public NotificationData.Entry getEntry(@NonNull String key) {
    public Entry getEntry(@NonNull String key) {
        AlertEntry entry = mAlertEntries.get(key);
        return entry != null ? entry.mEntry : null;
    }
@@ -149,7 +150,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
     * @return all entries
     */
    @NonNull
    public Stream<NotificationData.Entry> getAllEntries() {
    public Stream<Entry> getAllEntries() {
        return mAlertEntries.values().stream().map(headsUpEntry -> headsUpEntry.mEntry);
    }

@@ -169,11 +170,18 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
        return mAlertEntries.containsKey(key);
    }

    /**
     * Gets the flag corresponding to the notification content view this alert manager will show.
     *
     * @return flag corresponding to the content view
     */
    public abstract @InflationFlag int getContentFlag();

    /**
     * Add a new entry and begin managing it.
     * @param entry the entry to add
     */
    protected final void addAlertEntry(@NonNull NotificationData.Entry entry) {
    protected final void addAlertEntry(@NonNull Entry entry) {
        AlertEntry alertEntry = createAlertEntry();
        alertEntry.setEntry(entry);
        mAlertEntries.put(entry.key, alertEntry);
@@ -196,7 +204,7 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
        if (alertEntry == null) {
            return;
        }
        NotificationData.Entry entry = alertEntry.mEntry;
        Entry entry = alertEntry.mEntry;
        mAlertEntries.remove(key);
        onAlertEntryRemoved(alertEntry);
        entry.row.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
@@ -243,12 +251,12 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
    }

    @Override
    public boolean shouldExtendLifetime(NotificationData.Entry entry) {
    public boolean shouldExtendLifetime(Entry entry) {
        return !canRemoveImmediately(entry.key);
    }

    @Override
    public void setShouldManageLifetime(NotificationData.Entry entry, boolean shouldExtend) {
    public void setShouldManageLifetime(Entry entry, boolean shouldExtend) {
        if (shouldExtend) {
            mExtendedLifetimeAlertEntries.add(entry);
        } else {
@@ -258,17 +266,17 @@ public abstract class AlertingNotificationManager implements NotificationLifetim
    ///////////////////////////////////////////////////////////////////////////////////////////////

    protected class AlertEntry implements Comparable<AlertEntry> {
        @Nullable public NotificationData.Entry mEntry;
        @Nullable public Entry mEntry;
        public long mPostTime;
        public long mEarliestRemovaltime;

        @Nullable protected Runnable mRemoveAlertRunnable;

        public void setEntry(@NonNull final NotificationData.Entry entry) {
        public void setEntry(@NonNull final Entry entry) {
            setEntry(entry, () -> removeAlertEntry(entry.key));
        }

        public void setEntry(@NonNull final NotificationData.Entry entry,
        public void setEntry(@NonNull final Entry entry,
                @Nullable Runnable removeAlertRunnable) {
            mEntry = entry;
            mRemoveAlertRunnable = removeAlertRunnable;
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.util.ArraySet;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.NotificationData;
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;

/**
 * Manager which handles high priority notifications that should "pulse" in when the device is
@@ -71,6 +72,10 @@ public final class AmbientPulseManager extends AlertingNotificationManager {
        topEntry.extendPulse();
    }

    public @InflationFlag int getContentFlag() {
        return FLAG_CONTENT_VIEW_AMBIENT;
    }

    @Override
    protected void onAlertEntryAdded(AlertEntry alertEntry) {
        NotificationData.Entry entry = alertEntry.mEntry;
+25 −11
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ import com.android.systemui.statusbar.notification.row.NotificationInflater;
import com.android.systemui.statusbar.notification.row.NotificationInflater.InflationFlag;
import com.android.systemui.statusbar.notification.row.RowInflaterTask;
import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -117,6 +118,8 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.

    private final NotificationGroupManager mGroupManager =
            Dependency.get(NotificationGroupManager.class);
    private final NotificationGroupAlertTransferHelper mGroupAlertTransferHelper =
            Dependency.get(NotificationGroupAlertTransferHelper.class);
    private final NotificationGutsManager mGutsManager =
            Dependency.get(NotificationGutsManager.class);
    private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
@@ -247,7 +250,8 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    }

    private void onPostInit() {
        mGroupManager.setPendingEntries(mPendingNotifications);
        mGroupAlertTransferHelper.setPendingEntries(mPendingNotifications);
        mGroupManager.addOnGroupChangeListener(mGroupAlertTransferHelper);
    }

    /**
@@ -554,14 +558,19 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        mPendingNotifications.remove(entry.key);
        // If there was an async task started after the removal, we don't want to add it back to
        // the list, otherwise we might get leaks.
        if (!entry.row.isRemoved()) {
            boolean isNew = mNotificationData.get(entry.key) == null;
        if (isNew && !entry.row.isRemoved()) {
            if (isNew) {
                showAlertingView(entry, inflatedFlags);
                addEntry(entry);
        } else if (!isNew && entry.row.hasLowPriorityStateUpdated()) {
            } else {
                if (entry.row.hasLowPriorityStateUpdated()) {
                    mVisualStabilityManager.onLowPriorityUpdated(entry);
                    mPresenter.updateNotificationViews();
                }
                mGroupAlertTransferHelper.onInflationFinished(entry);
            }
        }
        entry.row.setLowPriorityStateUpdated(false);
    }

@@ -573,6 +582,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
    private void removeNotificationInternal(String key,
            @Nullable NotificationListenerService.RankingMap ranking, boolean forceRemove) {
        abortExistingInflation(key);
        mGroupAlertTransferHelper.cleanUpPendingAlertInfo(key);

        // Attempt to remove notifications from their alert managers (heads up, ambient pulse).
        // Though the remove itself may fail, it lets the manager know to remove as soon as
@@ -734,8 +744,12 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
        row.setUseIncreasedHeadsUpHeight(useIncreasedHeadsUp);
        row.setEntry(entry);

        row.updateInflationFlag(FLAG_CONTENT_VIEW_HEADS_UP, shouldHeadsUp(entry));
        row.updateInflationFlag(FLAG_CONTENT_VIEW_AMBIENT, shouldPulse(entry));
        if (shouldHeadsUp(entry)) {
            row.updateInflationFlag(FLAG_CONTENT_VIEW_HEADS_UP, true /* shouldInflate */);
        }
        if (shouldPulse(entry)) {
            row.updateInflationFlag(FLAG_CONTENT_VIEW_AMBIENT, true /* shouldInflate */);
        }
        row.setNeedsRedaction(
                Dependency.get(NotificationLockscreenUserManager.class).needsRedaction(entry));
        row.inflateViews();
@@ -823,7 +837,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
                mNotificationData.getImportance(key));

        mPendingNotifications.put(key, shadeEntry);
        mGroupManager.onPendingEntryAdded(shadeEntry);
        mGroupAlertTransferHelper.onPendingEntryAdded(shadeEntry);
    }

    @VisibleForTesting
+11 −1
Original line number Diff line number Diff line
@@ -510,6 +510,16 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        mNotificationInflater.updateInflationFlag(flag, shouldInflate);
    }

    /**
     * Whether or not a content view should be inflated.
     *
     * @param flag the flag corresponding to the content view
     * @return true if the flag is set, false otherwise
     */
    public boolean isInflationFlagSet(@InflationFlag int flag) {
        return mNotificationInflater.isInflationFlagSet(flag);
    }

    /**
     * Caches whether or not this row contains a system notification. Note, this is only cached
     * once per notification as the packageInfo can't technically change for a notification row.
Loading