Merge "Add logging for smart replies and actions."
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index 5118e5f..9087dd2 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -67,7 +67,8 @@
in NotificationVisibility[] noLongerVisibleKeys);
void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded);
void onNotificationDirectReplied(String key);
- void onNotificationSmartRepliesAdded(in String key, in int replyCount);
+ void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
+ boolean generatedByAsssistant);
void onNotificationSmartReplySent(in String key, in int replyIndex, in CharSequence reply, boolean generatedByAssistant);
void onNotificationSettingsViewed(String key);
void setSystemUiVisibility(int displayId, int vis, int mask, String cause);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
index f5d6904..e31f90d5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
@@ -88,10 +88,14 @@
return mSendingKeys.contains(key);
}
- public void smartRepliesAdded(final NotificationData.Entry entry, int replyCount) {
+ /**
+ * Smart Replies and Actions have been added to the UI.
+ */
+ public void smartSuggestionsAdded(final NotificationData.Entry entry, int replyCount,
+ int actionCount, boolean generatedByAssistant) {
try {
- mBarService.onNotificationSmartRepliesAdded(entry.notification.getKey(),
- replyCount);
+ mBarService.onNotificationSmartSuggestionsAdded(
+ entry.notification.getKey(), replyCount, actionCount, generatedByAssistant);
} catch (RemoteException e) {
// Nothing to do, system going down
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
index 6bc39c8..02a310c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
@@ -1474,9 +1474,19 @@
if (mExpandedChild != null) {
mExpandedSmartReplyView =
applySmartReplyView(mExpandedChild, smartRepliesAndActions, entry);
- if (mExpandedSmartReplyView != null && smartRepliesAndActions.smartReplies != null) {
- mSmartReplyController.smartRepliesAdded(
- entry, smartRepliesAndActions.smartReplies.choices.length);
+ if (mExpandedSmartReplyView != null) {
+ if (smartRepliesAndActions.smartReplies != null
+ || smartRepliesAndActions.smartActions != null) {
+ int numSmartReplies = smartRepliesAndActions.smartReplies == null
+ ? 0 : smartRepliesAndActions.smartReplies.choices.length;
+ int numSmartActions = smartRepliesAndActions.smartActions == null
+ ? 0 : smartRepliesAndActions.smartActions.actions.size();
+ boolean fromAssistant = smartRepliesAndActions.smartReplies == null
+ ? smartRepliesAndActions.smartActions.fromAssistant
+ : smartRepliesAndActions.smartReplies.fromAssistant;
+ mSmartReplyController.smartSuggestionsAdded(entry, numSmartReplies,
+ numSmartActions, fromAssistant);
+ }
}
}
if (mHeadsUpChild != null) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
index 8d52ccd..14e611a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
@@ -51,6 +51,7 @@
private static final String TEST_CHOICE_TEXT = "A Reply";
private static final int TEST_CHOICE_INDEX = 2;
private static final int TEST_CHOICE_COUNT = 4;
+ private static final int TEST_ACTION_COUNT = 3;
private Notification mNotification;
private NotificationData.Entry mEntry;
@@ -117,12 +118,14 @@
}
@Test
- public void testShowSmartReply_logsToStatusBar() throws RemoteException {
- mSmartReplyController.smartRepliesAdded(mEntry, TEST_CHOICE_COUNT);
+ public void testShowSmartSuggestions_logsToStatusBar() throws RemoteException {
+ final boolean generatedByAsssistant = true;
+ mSmartReplyController.smartSuggestionsAdded(mEntry, TEST_CHOICE_COUNT, TEST_ACTION_COUNT,
+ generatedByAsssistant);
// Check we log the result to the status bar service.
- verify(mIStatusBarService).onNotificationSmartRepliesAdded(mSbn.getKey(),
- TEST_CHOICE_COUNT);
+ verify(mIStatusBarService).onNotificationSmartSuggestionsAdded(mSbn.getKey(),
+ TEST_CHOICE_COUNT, TEST_ACTION_COUNT, generatedByAsssistant);
}
@Test
diff --git a/services/core/java/com/android/server/notification/NotificationDelegate.java b/services/core/java/com/android/server/notification/NotificationDelegate.java
index 84bb13e..ee60daa 100644
--- a/services/core/java/com/android/server/notification/NotificationDelegate.java
+++ b/services/core/java/com/android/server/notification/NotificationDelegate.java
@@ -45,7 +45,12 @@
void onNotificationExpansionChanged(String key, boolean userAction, boolean expanded);
void onNotificationDirectReplied(String key);
void onNotificationSettingsViewed(String key);
- void onNotificationSmartRepliesAdded(String key, int replyCount);
+
+ /**
+ * Notifies that smart replies and actions have been added to the UI.
+ */
+ void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
+ boolean generatedByAssistant);
/**
* Notifies a smart reply is sent.
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index bad259b..405edd2 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -762,7 +762,13 @@
.setType(MetricsEvent.TYPE_ACTION)
.setSubtype(actionIndex)
.addTaggedData(MetricsEvent.NOTIFICATION_SHADE_INDEX, nv.rank)
- .addTaggedData(MetricsEvent.NOTIFICATION_SHADE_COUNT, nv.count));
+ .addTaggedData(MetricsEvent.NOTIFICATION_SHADE_COUNT, nv.count)
+ .addTaggedData(MetricsEvent.NOTIFICATION_ACTION_IS_SMART,
+ (Notification.Action.SEMANTIC_ACTION_CONTEXTUAL_SUGGESTION
+ == action.getSemanticAction()) ? 1 : 0)
+ .addTaggedData(
+ MetricsEvent.NOTIFICATION_SMART_SUGGESTION_ASSISTANT_GENERATED,
+ generatedByAssistant ? 1 : 0));
EventLogTags.writeNotificationActionClicked(key, actionIndex,
r.getLifespanMs(now), r.getFreshnessMs(now), r.getExposureMs(now),
nv.rank, nv.count);
@@ -837,15 +843,20 @@
if (DBG) Slog.d(TAG, "Marking notification as visible " + nv.key);
reportSeen(r);
- // If the newly visible notification has smart replies
+ // If the newly visible notification has smart suggestions
// then log that the user has seen them.
- if (r.getNumSmartRepliesAdded() > 0
+ if ((r.getNumSmartRepliesAdded() > 0 || r.getNumSmartActionsAdded() > 0)
&& !r.hasSeenSmartReplies()) {
r.setSeenSmartReplies(true);
LogMaker logMaker = r.getLogMaker()
.setCategory(MetricsEvent.SMART_REPLY_VISIBLE)
.addTaggedData(MetricsEvent.NOTIFICATION_SMART_REPLY_COUNT,
- r.getNumSmartRepliesAdded());
+ r.getNumSmartRepliesAdded())
+ .addTaggedData(MetricsEvent.NOTIFICATION_SMART_ACTION_COUNT,
+ r.getNumSmartActionsAdded())
+ .addTaggedData(
+ MetricsEvent.NOTIFICATION_SMART_SUGGESTION_ASSISTANT_GENERATED,
+ r.getSuggestionsGeneratedByAssistant());
mMetricsLogger.write(logMaker);
}
}
@@ -908,11 +919,14 @@
}
@Override
- public void onNotificationSmartRepliesAdded(String key, int replyCount) {
+ public void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount,
+ int smartActionCount, boolean generatedByAssistant) {
synchronized (mNotificationLock) {
NotificationRecord r = mNotificationsByKey.get(key);
if (r != null) {
- r.setNumSmartRepliesAdded(replyCount);
+ r.setNumSmartRepliesAdded(smartReplyCount);
+ r.setNumSmartActionsAdded(smartActionCount);
+ r.setSuggestionsGeneratedByAssistant(generatedByAssistant);
}
}
}
@@ -920,6 +934,7 @@
@Override
public void onNotificationSmartReplySent(String key, int replyIndex, CharSequence reply,
boolean generatedByAssistant) {
+
synchronized (mNotificationLock) {
NotificationRecord r = mNotificationsByKey.get(key);
if (r != null) {
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index 39451d4..89ec38d 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -178,6 +178,8 @@
private boolean mTextChanged;
private boolean mRecordedInterruption;
private int mNumberOfSmartRepliesAdded;
+ private int mNumberOfSmartActionsAdded;
+ private boolean mSuggestionsGeneratedByAssistant;
private boolean mHasSeenSmartReplies;
/**
* Whether this notification (and its channels) should be considered user locked. Used in
@@ -1140,6 +1142,22 @@
return mNumberOfSmartRepliesAdded;
}
+ public void setNumSmartActionsAdded(int noActions) {
+ mNumberOfSmartActionsAdded = noActions;
+ }
+
+ public int getNumSmartActionsAdded() {
+ return mNumberOfSmartActionsAdded;
+ }
+
+ public void setSuggestionsGeneratedByAssistant(boolean generatedByAssistant) {
+ mSuggestionsGeneratedByAssistant = generatedByAssistant;
+ }
+
+ public boolean getSuggestionsGeneratedByAssistant() {
+ return mSuggestionsGeneratedByAssistant;
+ }
+
public boolean hasSeenSmartReplies() {
return mHasSeenSmartReplies;
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 6e4c00e..02d8c0b 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -1254,12 +1254,13 @@
}
@Override
- public void onNotificationSmartRepliesAdded(String key, int replyCount)
- throws RemoteException {
+ public void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount,
+ int smartActionCount, boolean generatedByAssistant) {
enforceStatusBarService();
long identity = Binder.clearCallingIdentity();
try {
- mNotificationDelegate.onNotificationSmartRepliesAdded(key, replyCount);
+ mNotificationDelegate.onNotificationSmartSuggestionsAdded(key, smartReplyCount,
+ smartActionCount, generatedByAssistant);
} finally {
Binder.restoreCallingIdentity(identity);
}