summaryrefslogtreecommitdiff
path: root/services/people
diff options
context:
space:
mode:
authorDanning Chen <danningc@google.com>2020-02-14 10:36:10 -0800
committerDanning Chen <danningc@google.com>2020-02-14 10:59:52 -0800
commit7af601e8ed63c0435e3bbfc440bc463f7db8ca6b (patch)
treefe716118cee25ea8fe797d70cd6282118948c110 /services/people
parent94580df0a81fd658dbd3263ec02914ad23b4d4bc (diff)
Listen to the notification posted events from NotificationListenerService instead
UsageStats NOTIFICATION_INTERRUPTION events are only created if a conversation has its own conversation-specific notification channel created. Switch to NotificationListenerService so that we could get the notification posted events from all conversations. Bug: 146522621 Test: atest com.android.server.people.data.DataManagerTest Test: atest com.android.server.people.data.UsageStatsQueryHelperTest Change-Id: Iaa120567891144a952707deb5cea1321aa28341c
Diffstat (limited to 'services/people')
-rw-r--r--services/people/java/com/android/server/people/data/DataManager.java8
-rw-r--r--services/people/java/com/android/server/people/data/UsageStatsQueryHelper.java17
2 files changed, 8 insertions, 17 deletions
diff --git a/services/people/java/com/android/server/people/data/DataManager.java b/services/people/java/com/android/server/people/data/DataManager.java
index 2d7c937975bd..39a26662da4b 100644
--- a/services/people/java/com/android/server/people/data/DataManager.java
+++ b/services/people/java/com/android/server/people/data/DataManager.java
@@ -640,6 +640,14 @@ public class DataManager {
private class NotificationListener extends NotificationListenerService {
@Override
+ public void onNotificationPosted(StatusBarNotification sbn) {
+ EventHistoryImpl eventHistory = getEventHistoryIfEligible(sbn);
+ if (eventHistory != null) {
+ eventHistory.addEvent(new Event(sbn.getPostTime(), Event.TYPE_NOTIFICATION_POSTED));
+ }
+ }
+
+ @Override
public void onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap,
int reason) {
if (reason != REASON_CLICK) {
diff --git a/services/people/java/com/android/server/people/data/UsageStatsQueryHelper.java b/services/people/java/com/android/server/people/data/UsageStatsQueryHelper.java
index 6dcfaa00dfd5..72f1abb70e34 100644
--- a/services/people/java/com/android/server/people/data/UsageStatsQueryHelper.java
+++ b/services/people/java/com/android/server/people/data/UsageStatsQueryHelper.java
@@ -80,10 +80,6 @@ class UsageStatsQueryHelper {
addEventByShortcutId(packageData, e.getShortcutId(),
new Event(e.getTimeStamp(), Event.TYPE_SHORTCUT_INVOCATION));
break;
- case UsageEvents.Event.NOTIFICATION_INTERRUPTION:
- addEventByNotificationChannelId(packageData, e.getNotificationChannelId(),
- new Event(e.getTimeStamp(), Event.TYPE_NOTIFICATION_POSTED));
- break;
case UsageEvents.Event.LOCUS_ID_SET:
onInAppConversationEnded(packageData, e);
LocusId locusId = e.getLocusId() != null ? new LocusId(e.getLocusId()) : null;
@@ -142,17 +138,4 @@ class UsageStatsQueryHelper {
EventStore.CATEGORY_LOCUS_ID_BASED, locusId.getId());
eventHistory.addEvent(event);
}
-
- private void addEventByNotificationChannelId(PackageData packageData,
- String notificationChannelId, Event event) {
- ConversationInfo conversationInfo =
- packageData.getConversationStore().getConversationByNotificationChannelId(
- notificationChannelId);
- if (conversationInfo == null) {
- return;
- }
- EventHistoryImpl eventHistory = packageData.getEventStore().getOrCreateEventHistory(
- EventStore.CATEGORY_SHORTCUT_BASED, conversationInfo.getShortcutId());
- eventHistory.addEvent(event);
- }
}