summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBarService.aidl2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java20
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java5
-rw-r--r--services/core/java/com/android/server/notification/NotificationDelegate.java3
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java9
-rw-r--r--services/core/java/com/android/server/statusbar/StatusBarManagerService.java6
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java2
9 files changed, 37 insertions, 21 deletions
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index d61f10e7a195..d355745f03ad 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -69,7 +69,7 @@ interface IStatusBarService
void onNotificationDirectReplied(String key);
void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
boolean generatedByAsssistant);
- void onNotificationSmartReplySent(in String key, in int replyIndex, in CharSequence reply, boolean generatedByAssistant);
+ void onNotificationSmartReplySent(in String key, in int replyIndex, in CharSequence reply, boolean generatedByAssistant, in int notificationLocation);
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 a2abcd2f9c8f..5a8f71d6627d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
@@ -56,12 +56,13 @@ public class SmartReplyController {
* Notifies StatusBarService a smart reply is sent.
*/
public void smartReplySent(NotificationEntry entry, int replyIndex, CharSequence reply,
- boolean generatedByAssistant) {
+ boolean generatedByAssistant, int notificationLocation) {
mCallback.onSmartReplySent(entry, reply);
mSendingKeys.add(entry.key);
try {
mBarService.onNotificationSmartReplySent(
- entry.notification.getKey(), replyIndex, reply, generatedByAssistant);
+ entry.notification.getKey(), replyIndex, reply, generatedByAssistant,
+ notificationLocation);
} catch (RemoteException e) {
// Nothing to do, system going down
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index 07c6587c56e1..1708bb2eddac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -38,6 +38,7 @@ import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.SmartReplyController;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.logging.NotificationLogger;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import java.text.BreakIterator;
@@ -258,8 +259,9 @@ public class SmartReplyView extends ViewGroup {
return false;
}
- smartReplyController.smartReplySent(
- entry, replyIndex, b.getText(), smartReplies.fromAssistant);
+ smartReplyController.smartReplySent(entry, replyIndex, b.getText(),
+ smartReplies.fromAssistant,
+ NotificationLogger.getNotificationLocation(entry).toMetricsEventEnum());
Bundle results = new Bundle();
results.putString(smartReplies.remoteInput.getResultKey(), choice.toString());
Intent intent = new Intent().addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
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 6cca434bd8cb..f34e1a6b01e7 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
@@ -33,6 +33,7 @@ import android.support.test.filters.SmallTest;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.statusbar.IStatusBarService;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
@@ -97,7 +98,8 @@ public class SmartReplyControllerTest extends SysuiTestCase {
@Test
public void testSendSmartReply_updatesRemoteInput() {
- mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false);
+ mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
+ MetricsEvent.LOCATION_UNKNOWN);
// Sending smart reply should make calls to NotificationEntryManager
// to update the notification with reply and spinner.
@@ -107,21 +109,23 @@ public class SmartReplyControllerTest extends SysuiTestCase {
@Test
public void testSendSmartReply_logsToStatusBar() throws RemoteException {
- mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false);
+ mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
+ MetricsEvent.LOCATION_UNKNOWN);
// Check we log the result to the status bar service.
verify(mIStatusBarService).onNotificationSmartReplySent(mSbn.getKey(),
- TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false);
+ TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false, MetricsEvent.LOCATION_UNKNOWN);
}
@Test
public void testSendSmartReply_logsToStatusBar_generatedByAssistant() throws RemoteException {
- mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true);
+ mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true,
+ MetricsEvent.LOCATION_UNKNOWN);
// Check we log the result to the status bar service.
verify(mIStatusBarService).onNotificationSmartReplySent(mSbn.getKey(),
- TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true);
+ TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true, MetricsEvent.LOCATION_UNKNOWN);
}
@Test
@@ -137,14 +141,16 @@ public class SmartReplyControllerTest extends SysuiTestCase {
@Test
public void testSendSmartReply_reportsSending() {
- mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false);
+ mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
+ MetricsEvent.LOCATION_UNKNOWN);
assertTrue(mSmartReplyController.isSendingSmartReply(mSbn.getKey()));
}
@Test
public void testSendingSmartReply_afterRemove_shouldReturnFalse() {
- mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false);
+ mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
+ MetricsEvent.LOCATION_UNKNOWN);
mSmartReplyController.stopSending(mEntry);
assertFalse(mSmartReplyController.isSendingSmartReply(mSbn.getKey()));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
index d1c4d0134f6c..739c82a0ba02 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
@@ -45,6 +45,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.ActivityStarter;
@@ -189,7 +190,7 @@ public class SmartReplyViewTest extends SysuiTestCase {
setSmartReplies(TEST_CHOICES);
mView.getChildAt(2).performClick();
verify(mLogger).smartReplySent(mEntry, 2, TEST_CHOICES[2],
- false /* generatedByAsssitant */);
+ false /* generatedByAsssitant */, MetricsEvent.LOCATION_UNKNOWN);
}
@Test
@@ -197,7 +198,7 @@ public class SmartReplyViewTest extends SysuiTestCase {
setSmartReplies(TEST_CHOICES, true);
mView.getChildAt(2).performClick();
verify(mLogger).smartReplySent(mEntry, 2, TEST_CHOICES[2],
- true /* generatedByAsssitant */);
+ true /* generatedByAsssitant */, MetricsEvent.LOCATION_UNKNOWN);
}
@Test
diff --git a/services/core/java/com/android/server/notification/NotificationDelegate.java b/services/core/java/com/android/server/notification/NotificationDelegate.java
index c2dc554321c2..be15fdaf5abe 100644
--- a/services/core/java/com/android/server/notification/NotificationDelegate.java
+++ b/services/core/java/com/android/server/notification/NotificationDelegate.java
@@ -60,7 +60,8 @@ public interface NotificationDelegate {
* @param clickedIndex the index of clicked reply
* @param reply the reply that is sent
* @param generatedByAssistant specifies is the reply generated by NAS
+ * @param notificationLocation the location of the notification containing the smart reply
*/
void onNotificationSmartReplySent(String key, int clickedIndex, CharSequence reply,
- boolean generatedByAssistant);
+ boolean generatedByAssistant, int notificationLocation);
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index de3f50ad8c2c..295cd15b923e 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -925,14 +925,19 @@ public class NotificationManagerService extends SystemService {
@Override
public void onNotificationSmartReplySent(String key, int replyIndex, CharSequence reply,
- boolean generatedByAssistant) {
+ boolean generatedByAssistant, int notificationLocation) {
synchronized (mNotificationLock) {
NotificationRecord r = mNotificationsByKey.get(key);
if (r != null) {
LogMaker logMaker = r.getLogMaker()
.setCategory(MetricsEvent.SMART_REPLY_ACTION)
- .setSubtype(replyIndex);
+ .setSubtype(replyIndex)
+ .addTaggedData(
+ MetricsEvent.NOTIFICATION_SMART_SUGGESTION_ASSISTANT_GENERATED,
+ generatedByAssistant ? 1 : 0)
+ .addTaggedData(MetricsEvent.NOTIFICATION_LOCATION,
+ notificationLocation);
mMetricsLogger.write(logMaker);
// Treat clicking on a smart reply as a user interaction.
reportUserInteraction(r);
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 7e87c29e7a58..9617529dea39 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -1266,13 +1266,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void onNotificationSmartReplySent(
- String key, int replyIndex, CharSequence reply, boolean generatedByAssistant)
- throws RemoteException {
+ String key, int replyIndex, CharSequence reply, boolean generatedByAssistant,
+ int notificationLocation) throws RemoteException {
enforceStatusBarService();
long identity = Binder.clearCallingIdentity();
try {
mNotificationDelegate.onNotificationSmartReplySent(key, replyIndex, reply,
- generatedByAssistant);
+ generatedByAssistant, notificationLocation);
} finally {
Binder.restoreCallingIdentity(identity);
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 9c6ab0ab9aa9..a09e730bc8ad 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -3842,7 +3842,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
mService.addNotification(r);
mService.mNotificationDelegate.onNotificationSmartReplySent(
- r.getKey(), replyIndex, reply, generatedByAssistant);
+ r.getKey(), replyIndex, reply, generatedByAssistant, NOTIFICATION_LOCATION_UNKNOWN);
verify(mAssistants).notifyAssistantSuggestedReplySent(
eq(r.sbn), eq(reply), eq(generatedByAssistant));
}