• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.systemui.statusbar
2 
3 import com.android.systemui.dagger.SysUISingleton
4 import com.android.systemui.statusbar.notification.NotificationEntryManager
5 import com.android.systemui.statusbar.notification.collection.NotificationEntry
6 import com.android.systemui.statusbar.notification.collection.notifcollection.NotifCollectionListener
7 import javax.inject.Inject
8 
9 /**
10  * Class to track user interaction with notifications. It's a glorified map of key : bool that can
11  * merge multiple "user interacted with notification" signals into a single place.
12  */
13 @SysUISingleton
14 class NotificationInteractionTracker @Inject constructor(
15     private val clicker: NotificationClickNotifier,
16     private val entryManager: NotificationEntryManager
17 ) : NotifCollectionListener, NotificationInteractionListener {
18     private val interactions = mutableMapOf<String, Boolean>()
19 
20     init {
21         clicker.addNotificationInteractionListener(this)
22         entryManager.addCollectionListener(this)
23     }
24 
hasUserInteractedWithnull25     fun hasUserInteractedWith(key: String): Boolean {
26         return interactions[key] ?: false
27     }
28 
onEntryAddednull29     override fun onEntryAdded(entry: NotificationEntry) {
30         interactions[entry.key] = false
31     }
32 
onEntryCleanUpnull33     override fun onEntryCleanUp(entry: NotificationEntry) {
34         interactions.remove(entry.key)
35     }
36 
onNotificationInteractionnull37     override fun onNotificationInteraction(key: String) {
38         interactions[key] = true
39     }
40 }
41 
42 private const val TAG = "NotificationInteractionTracker"
43