• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 com.android.internal.statusbar.NotificationVisibility
20 import com.android.systemui.statusbar.notification.collection.notifcollection.DismissedByUserStats
21 
22 /**
23  * A holder class for a [NotificationEntry] and an associated [DismissedByUserStats], used by
24  * [NotifCollection] for handling dismissal.
25  */
26 data class EntryWithDismissStats(val entry: NotificationEntry?,
27                                  val stats: DismissedByUserStats,
28                                  val key: String,
29                                  val entryHashCode: Int) {
30     /**
31      * Creates deep a copy of this object, but with the entry, key and rank updated to correspond to
32      * the given entry.
33      */
copyForEntrynull34     fun copyForEntry(newEntry: NotificationEntry) =
35         EntryWithDismissStats(
36             entry = newEntry,
37             stats =
38                 DismissedByUserStats(
39                     stats.dismissalSurface,
40                     stats.dismissalSentiment,
41                     NotificationVisibility.obtain(
42                         newEntry.key,
43                         newEntry.ranking.rank,
44                         stats.notificationVisibility.count,
45                         /* visible= */ false,
46                     ),
47                 ),
48             key = newEntry.key,
49             entryHashCode = newEntry.hashCode()
50         )
51 }
52