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

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

Merge changes I9f44ed05,I8990bf48,Ib302cbc2 into rvc-dev am: bc838ca6

Change-Id: I6fa953c4fb021ec8652cb586648f53002db121d1
parents 2cfe3946 bc838ca6
Loading
Loading
Loading
Loading
+81 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.notification.collection

import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifFilter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifPromoter
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection

/**
 * Stores the state that [ShadeListBuilder] assigns to this [ListEntry]
 */
data class ListAttachState private constructor(
    /**
     * Null if not attached to the current shade list. If top-level, then the shade list root. If
     * part of a group, then that group's GroupEntry.
     */
    var parent: GroupEntry?,

    /**
     * The section that this ListEntry was sorted into. If the child of the group, this will be the
     * parent's section. Null if not attached to the list.
     */
    var section: NotifSection?,
    var sectionIndex: Int,

    /**
     * If a [NotifFilter] is excluding this entry from the list, then that filter. Always null for
     * [GroupEntry]s.
     */
    var excludingFilter: NotifFilter?,

    /**
     * The [NotifPromoter] promoting this entry to top-level, if any. Always null for [GroupEntry]s.
     */
    var promoter: NotifPromoter?
) {

    /** Copies the state of another instance. */
    fun clone(other: ListAttachState) {
        parent = other.parent
        section = other.section
        sectionIndex = other.sectionIndex
        excludingFilter = other.excludingFilter
        promoter = other.promoter
    }

    /** Resets back to a "clean" state (the same as created by the factory method) */
    fun reset() {
        parent = null
        section = null
        sectionIndex = -1
        excludingFilter = null
        promoter = null
    }

    companion object {
        @JvmStatic
        fun create(): ListAttachState {
            return ListAttachState(
                    null,
                    null,
                    -1,
                    null,
                    null)
        }
    }
}
+6 −6
Original line number Original line Diff line number Diff line
@@ -102,11 +102,11 @@ public class ListDumper {
                    .append(")");
                    .append(")");
        }
        }


        if (entry.mNotifSection != null) {
        if (entry.getNotifSection() != null) {
            sb.append(" sectionIndex=")
            sb.append(" sectionIndex=")
                    .append(entry.getSection())
                    .append(entry.getSection())
                    .append(" sectionName=")
                    .append(" sectionName=")
                    .append(entry.mNotifSection.getName());
                    .append(entry.getNotifSection().getName());
        }
        }


        if (includeRecordKeeping) {
        if (includeRecordKeeping) {
@@ -133,15 +133,15 @@ public class ListDumper {
                        .append(" ");
                        .append(" ");
            }
            }


            if (notifEntry.mExcludingFilter != null) {
            if (notifEntry.getExcludingFilter() != null) {
                rksb.append("filter=")
                rksb.append("filter=")
                        .append(notifEntry.mExcludingFilter)
                        .append(notifEntry.getExcludingFilter().getName())
                        .append(" ");
                        .append(" ");
            }
            }


            if (notifEntry.mNotifPromoter != null) {
            if (notifEntry.getNotifPromoter() != null) {
                rksb.append("promoter=")
                rksb.append("promoter=")
                        .append(notifEntry.mNotifPromoter)
                        .append(notifEntry.getNotifPromoter().getName())
                        .append(" ");
                        .append(" ");
            }
            }


+28 −16
Original line number Original line Diff line number Diff line
@@ -16,7 +16,8 @@


package com.android.systemui.statusbar.notification.collection;
package com.android.systemui.statusbar.notification.collection;


import android.annotation.Nullable;

import androidx.annotation.Nullable;


import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;
import com.android.systemui.statusbar.notification.collection.listbuilder.pluggable.NotifSection;


@@ -27,13 +28,11 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.plugga
public abstract class ListEntry {
public abstract class ListEntry {
    private final String mKey;
    private final String mKey;


    @Nullable private GroupEntry mParent;
    @Nullable private GroupEntry mPreviousParent;
    @Nullable NotifSection mNotifSection;

    private int mSection = -1;
    int mFirstAddedIteration = -1;
    int mFirstAddedIteration = -1;


    private final ListAttachState mPreviousAttachState = ListAttachState.create();
    private final ListAttachState mAttachState = ListAttachState.create();

    ListEntry(String key) {
    ListEntry(String key) {
        mKey = key;
        mKey = key;
    }
    }
@@ -51,27 +50,40 @@ public abstract class ListEntry {
    public abstract @Nullable NotificationEntry getRepresentativeEntry();
    public abstract @Nullable NotificationEntry getRepresentativeEntry();


    @Nullable public GroupEntry getParent() {
    @Nullable public GroupEntry getParent() {
        return mParent;
        return mAttachState.getParent();
    }
    }


    void setParent(@Nullable GroupEntry parent) {
    void setParent(@Nullable GroupEntry parent) {
        mParent = parent;
        mAttachState.setParent(parent);
    }
    }


    @Nullable public GroupEntry getPreviousParent() {
    @Nullable public GroupEntry getPreviousParent() {
        return mPreviousParent;
        return mPreviousAttachState.getParent();
    }

    void setPreviousParent(@Nullable GroupEntry previousParent) {
        mPreviousParent = previousParent;
    }
    }


    /** The section this notification was assigned to (0 to N-1, where N is number of sections). */
    /** The section this notification was assigned to (0 to N-1, where N is number of sections). */
    public int getSection() {
    public int getSection() {
        return mSection;
        return mAttachState.getSectionIndex();
    }

    @Nullable public NotifSection getNotifSection() {
        return mAttachState.getSection();
    }
    }


    void setSection(int section) {
    ListAttachState getAttachState() {
        mSection = section;
        return mAttachState;
    }

    ListAttachState getPreviousAttachState() {
        return mPreviousAttachState;
    }

    /**
     * Stores the current attach state into {@link #getPreviousAttachState()}} and then starts a
     * fresh attach state (all entries will be null/default-initialized).
     */
    void beginNewAttachState() {
        mPreviousAttachState.clone(mAttachState);
        mAttachState.reset();
    }
    }
}
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -504,6 +504,11 @@ public class NotifCollection implements Dumpable {
                            extender));
                            extender));
        }
        }


        mLogger.logLifetimeExtensionEnded(
                entry.getKey(),
                extender,
                entry.mLifetimeExtenders.size());

        if (!isLifetimeExtended(entry)) {
        if (!isLifetimeExtended(entry)) {
            if (tryRemoveNotification(entry)) {
            if (tryRemoveNotification(entry)) {
                dispatchEventsAndRebuildList();
                dispatchEventsAndRebuildList();
@@ -529,6 +534,7 @@ public class NotifCollection implements Dumpable {
        mAmDispatchingToOtherCode = true;
        mAmDispatchingToOtherCode = true;
        for (NotifLifetimeExtender extender : mLifetimeExtenders) {
        for (NotifLifetimeExtender extender : mLifetimeExtenders) {
            if (extender.shouldExtendLifetime(entry, entry.mCancellationReason)) {
            if (extender.shouldExtendLifetime(entry, entry.mCancellationReason)) {
                mLogger.logLifetimeExtended(entry.getKey(), extender);
                entry.mLifetimeExtenders.add(extender);
                entry.mLifetimeExtenders.add(extender);
            }
            }
        }
        }
+8 −12
Original line number Original line Diff line number Diff line
@@ -105,18 +105,6 @@ public final class NotificationEntry extends ListEntry {
    /** List of dismiss interceptors that are intercepting the dismissal of this notification. */
    /** List of dismiss interceptors that are intercepting the dismissal of this notification. */
    final List<NotifDismissInterceptor> mDismissInterceptors = new ArrayList<>();
    final List<NotifDismissInterceptor> mDismissInterceptors = new ArrayList<>();


    /** If this notification was filtered out, then the filter that did the filtering. */
    @Nullable NotifFilter mExcludingFilter;

    /**
     * The NotifFilter, if any, that was active on this notification during the previous run of
     * the list builder.
     */
    @Nullable NotifFilter mPreviousExcludingFilter;

    /** If this was a group child that was promoted to the top level, then who did the promoting. */
    @Nullable NotifPromoter mNotifPromoter;

    /**
    /**
     * If this notification was cancelled by system server, then the reason that was supplied.
     * If this notification was cancelled by system server, then the reason that was supplied.
     * Uncancelled notifications always have REASON_NOT_CANCELED. Note that lifetime-extended
     * Uncancelled notifications always have REASON_NOT_CANCELED. Note that lifetime-extended
@@ -283,6 +271,14 @@ public final class NotificationEntry extends ListEntry {
        mDismissState = requireNonNull(dismissState);
        mDismissState = requireNonNull(dismissState);
    }
    }


    @Nullable public NotifFilter getExcludingFilter() {
        return getAttachState().getExcludingFilter();
    }

    @Nullable public NotifPromoter getNotifPromoter() {
        return getAttachState().getPromoter();
    }

    /*
    /*
     * Convenience getters for SBN and Ranking members
     * Convenience getters for SBN and Ranking members
     */
     */
Loading