From 6303141f400c641285ca9aea7552cd888f6dec48 Mon Sep 17 00:00:00 2001 From: Yuri Lin Date: Thu, 6 Oct 2022 16:44:02 -0400 Subject: [PATCH] Fix existing dismissal surfaces, add one for lockscreen DISMISSAL_BUBBLE previously had the same value as DISMISSAL_SHADE, so bubble dismissals weren't getting counted correctly. It also needed to be added as a new UiEvent on the logging side so that the dismissal surface could be handled correctly. This dismissal surface is getting set by BubbleManager already, so the necessary changes should be limited to the logging side. This change also adds a new dismissal surface for the lockscreen, in conjunction with the already existing UiEvent enum for NOTIFICATION_CANCEL_USER_LOCKSCREEN. However, this change does not yet add correct handling of new dismissal surface on the side where notifications get dismissed; that will be in an upcoming change. Bug: 234507856 Fixes: 252821281 Test: statsd_testdrive Change-Id: Ib8fe37dc1277c55de1c26a5e2b3835b3a9f3c941 --- .../service/notification/NotificationStats.java | 10 ++++++++-- .../server/notification/NotificationRecordLogger.java | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/java/android/service/notification/NotificationStats.java b/core/java/android/service/notification/NotificationStats.java index 206e4fa4fb11f..e5ad85cb526f4 100644 --- a/core/java/android/service/notification/NotificationStats.java +++ b/core/java/android/service/notification/NotificationStats.java @@ -42,7 +42,8 @@ public final class NotificationStats implements Parcelable { /** @hide */ @IntDef(prefix = { "DISMISSAL_SURFACE_" }, value = { - DISMISSAL_NOT_DISMISSED, DISMISSAL_OTHER, DISMISSAL_PEEK, DISMISSAL_AOD, DISMISSAL_SHADE + DISMISSAL_NOT_DISMISSED, DISMISSAL_OTHER, DISMISSAL_PEEK, DISMISSAL_AOD, + DISMISSAL_SHADE, DISMISSAL_BUBBLE, DISMISSAL_LOCKSCREEN }) @Retention(RetentionPolicy.SOURCE) public @interface DismissalSurface {} @@ -75,7 +76,12 @@ public final class NotificationStats implements Parcelable { * Notification has been dismissed as a bubble. * @hide */ - public static final int DISMISSAL_BUBBLE = 3; + public static final int DISMISSAL_BUBBLE = 4; + /** + * Notification has been dismissed from the lock screen. + * @hide + */ + public static final int DISMISSAL_LOCKSCREEN = 5; /** @hide */ @IntDef(prefix = { "DISMISS_SENTIMENT_" }, value = { diff --git a/services/core/java/com/android/server/notification/NotificationRecordLogger.java b/services/core/java/com/android/server/notification/NotificationRecordLogger.java index 9a89efabc6893..232a69b2d109d 100644 --- a/services/core/java/com/android/server/notification/NotificationRecordLogger.java +++ b/services/core/java/com/android/server/notification/NotificationRecordLogger.java @@ -177,11 +177,13 @@ public interface NotificationRecordLogger { NOTIFICATION_CANCEL_USER_PEEK(190), @UiEvent(doc = "Notification was canceled due to user dismissal from the always-on display") NOTIFICATION_CANCEL_USER_AOD(191), + @UiEvent(doc = "Notification was canceled due to user dismissal from a bubble") + NOTIFICATION_CANCEL_USER_BUBBLE(1228), + @UiEvent(doc = "Notification was canceled due to user dismissal from the lockscreen") + NOTIFICATION_CANCEL_USER_LOCKSCREEN(193), @UiEvent(doc = "Notification was canceled due to user dismissal from the notification" + " shade.") NOTIFICATION_CANCEL_USER_SHADE(192), - @UiEvent(doc = "Notification was canceled due to user dismissal from the lockscreen") - NOTIFICATION_CANCEL_USER_LOCKSCREEN(193), @UiEvent(doc = "Notification was canceled due to an assistant adjustment update.") NOTIFICATION_CANCEL_ASSISTANT(906); @@ -232,6 +234,10 @@ public interface NotificationRecordLogger { return NOTIFICATION_CANCEL_USER_AOD; case NotificationStats.DISMISSAL_SHADE: return NOTIFICATION_CANCEL_USER_SHADE; + case NotificationStats.DISMISSAL_BUBBLE: + return NOTIFICATION_CANCEL_USER_BUBBLE; + case NotificationStats.DISMISSAL_LOCKSCREEN: + return NOTIFICATION_CANCEL_USER_LOCKSCREEN; default: if (NotificationManagerService.DBG) { throw new IllegalArgumentException("Unexpected surface for user-dismiss "