1 package com.android.systemui.statusbar
2 
3 import com.android.systemui.dagger.SysUISingleton
4 import com.android.systemui.statusbar.notification.collection.NotificationEntry
5 import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
6 import javax.inject.Inject
7 
8 /**
9  * Class to track user interaction with notifications. It's a glorified map of key : bool that can
10  * merge multiple "user interacted with notification" signals into a single place.
11  */
12 @SysUISingleton
13 class NotificationInteractionTracker @Inject constructor(
14     clicker: NotificationClickNotifier,
15 ) : NotifCollectionListener, NotificationInteractionListener {
16     private val interactions = mutableMapOf<String, Boolean>()
17 
18     init {
19         clicker.addNotificationInteractionListener(this)
20     }
21 
hasUserInteractedWithnull22     fun hasUserInteractedWith(key: String): Boolean {
23         return interactions[key] ?: false
24     }
25 
onEntryAddednull26     override fun onEntryAdded(entry: NotificationEntry) {
27         interactions[entry.key] = false
28     }
29 
onEntryCleanUpnull30     override fun onEntryCleanUp(entry: NotificationEntry) {
31         interactions.remove(entry.key)
32     }
33 
onNotificationInteractionnull34     override fun onNotificationInteraction(key: String) {
35         interactions[key] = true
36     }
37 }
38