• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.statusbar.notification.collection;
18 
19 import static com.android.systemui.statusbar.notification.stack.NotificationPriorityBucketKt.BUCKET_ALERTING;
20 
21 import androidx.annotation.NonNull;
22 import androidx.annotation.Nullable;
23 
24 import com.android.systemui.statusbar.notification.collection.listbuilder.NotifSection;
25 import com.android.systemui.statusbar.notification.stack.PriorityBucket;
26 
27 /**
28  * Class to represent a notification, group, or bundle in the pipeline.
29  */
30 public abstract class PipelineEntry {
31 
32     final String mKey;
33     final ListAttachState mAttachState = ListAttachState.create();
34     final ListAttachState mPreviousAttachState = ListAttachState.create();
35     protected int mBucket = BUCKET_ALERTING;
36 
PipelineEntry(String key)37     public PipelineEntry(String key) {
38         this.mKey = key;
39     }
40 
41     /**
42      * Key of the representative entry.
43      */
getKey()44     public @NonNull String getKey() {
45         return mKey;
46     }
47 
48     /**
49      * @return The representative NotificationEntry:
50      *      for NotificationEntry, return itself
51      *      for GroupEntry, return the summary NotificationEntry, or null if it does not exist
52      *      for BundleEntry, return null
53      */
getRepresentativeEntry()54     public abstract @Nullable NotificationEntry getRepresentativeEntry();
55 
56     /**
57      * @return NotifSection that ShadeListBuilder assigned to this PipelineEntry.
58      */
getSection()59     @Nullable public NotifSection getSection() {
60         return mAttachState.getSection();
61     }
62 
63     /**
64      * @return True if this entry was attached in the last pass, else false.
65      */
wasAttachedInPreviousPass()66     public boolean wasAttachedInPreviousPass() {
67         return getPreviousAttachState().getParent() != null;
68     }
69 
70     /**
71      * @return Index of section assigned to this entry.
72      */
getSectionIndex()73     public int getSectionIndex() {
74         return mAttachState.getSection() != null ? mAttachState.getSection().getIndex() : -1;
75     }
76 
77     /**
78      * @return Parent PipelineEntry
79      */
getParent()80     public abstract @Nullable PipelineEntry getParent();
81 
82     /**
83      * @return Current state that ShadeListBuilder assigned to this PipelineEntry.
84      */
getAttachState()85     final ListAttachState getAttachState() {
86         return mAttachState;
87     }
88 
89     /**
90      * @return Previous state that ShadeListBuilder assigned to this PipelineEntry.
91      */
getPreviousAttachState()92     final ListAttachState getPreviousAttachState() {
93         return mPreviousAttachState;
94     }
95 
96     @PriorityBucket
getBucket()97     public int getBucket() {
98         return mBucket;
99     }
100 
setBucket(@riorityBucket int bucket)101     public void setBucket(@PriorityBucket int bucket) {
102         mBucket = bucket;
103     }
104 
105     /**
106      * Stores the current attach state into {@link #getPreviousAttachState()}} and then starts a
107      * fresh attach state (all entries will be null/default-initialized).
108      */
beginNewAttachState()109     void beginNewAttachState() {
110         mPreviousAttachState.clone(mAttachState);
111         mAttachState.reset();
112     }
113 }
114