OSDN Git Service

Add logging for tap-to-edit smart replies
authorMilo Sredkov <miloslav@google.com>
Fri, 1 Feb 2019 12:23:24 +0000 (12:23 +0000)
committerMilo Sredkov <miloslav@google.com>
Tue, 5 Feb 2019 09:13:32 +0000 (09:13 +0000)
Log the status of getEditChoicesBeforeSending with the
SMART_REPLY_VISIBLE and SMART_REPLY_ACTION events.

Log whether the reply was changed before sending with the
SMART_REPLY_ACTION event.

Bug: 123407240
Test: atest NotificationManagerServiceTest SmartReplyControllerTest SmartReplyViewTest NotificationContentViewTest RemoteInputViewTest SmartReplyViewTest
Change-Id: I92bf9b9486f023e7a1ab553c24a9d021dc2f3133

16 files changed:
core/java/com/android/internal/statusbar/IStatusBarService.aidl
packages/SystemUI/src/com/android/systemui/statusbar/NotificationRemoteInputManager.java
packages/SystemUI/src/com/android/systemui/statusbar/SmartReplyController.java
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/SmartReplyControllerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/RemoteInputViewTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java
proto/src/metrics_constants/metrics_constants.proto
services/core/java/com/android/server/notification/NotificationDelegate.java
services/core/java/com/android/server/notification/NotificationManagerService.java
services/core/java/com/android/server/notification/NotificationRecord.java
services/core/java/com/android/server/statusbar/StatusBarManagerService.java
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java

index 9df37ad..bfb5084 100644 (file)
@@ -69,8 +69,9 @@ interface IStatusBarService
     void onNotificationExpansionChanged(in String key, in boolean userAction, in boolean expanded, in int notificationLocation);
     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, in int notificationLocation);
+            boolean generatedByAsssistant, boolean editBeforeSending);
+    void onNotificationSmartReplySent(in String key, in int replyIndex, in CharSequence reply,
+            in int notificationLocation, boolean modifiedBeforeSending);
     void onNotificationSettingsViewed(String key);
     void setSystemUiVisibility(int displayId, int vis, int mask, String cause);
 
index 31d1621..491f310 100644 (file)
@@ -54,6 +54,7 @@ import com.android.systemui.Dumpable;
 import com.android.systemui.statusbar.notification.NotificationEntryListener;
 import com.android.systemui.statusbar.notification.NotificationEntryManager;
 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry.EditedSuggestionInfo;
 import com.android.systemui.statusbar.notification.logging.NotificationLogger;
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
 import com.android.systemui.statusbar.phone.ShadeController;
@@ -231,7 +232,8 @@ public class NotificationRemoteInputManager implements Dumpable {
                 return false;
             }
 
-            return activateRemoteInput(view, inputs, input, pendingIntent);
+            return activateRemoteInput(view, inputs, input, pendingIntent,
+                    null /* editedSuggestionInfo */);
         }
     };
 
@@ -291,6 +293,19 @@ public class NotificationRemoteInputManager implements Dumpable {
                 }
                 try {
                     mBarService.onNotificationDirectReplied(entry.notification.getKey());
+                    if (entry.editedSuggestionInfo != null) {
+                        boolean modifiedBeforeSending =
+                                !TextUtils.equals(entry.remoteInputText,
+                                        entry.editedSuggestionInfo.originalText);
+                        mBarService.onNotificationSmartReplySent(
+                                entry.notification.getKey(),
+                                entry.editedSuggestionInfo.index,
+                                entry.editedSuggestionInfo.originalText,
+                                NotificationLogger
+                                        .getNotificationLocation(entry)
+                                        .toMetricsEventEnum(),
+                                modifiedBeforeSending);
+                    }
                 } catch (RemoteException e) {
                     // Nothing to do, system going down
                 }
@@ -310,10 +325,12 @@ public class NotificationRemoteInputManager implements Dumpable {
      * @param inputs The remote inputs that need to be sent to the app.
      * @param input The remote input that needs to be activated.
      * @param pendingIntent The pending intent to be sent to the app.
+     * @param editedSuggestionInfo The smart reply that should be inserted in the remote input, or
+     *         {@code null} if the user is not editing a smart reply.
      * @return Whether the {@link RemoteInput} was activated.
      */
     public boolean activateRemoteInput(View view, RemoteInput[] inputs, RemoteInput input,
-            PendingIntent pendingIntent) {
+            PendingIntent pendingIntent, @Nullable EditedSuggestionInfo editedSuggestionInfo) {
 
         ViewParent p = view.getParent();
         RemoteInputView riv = null;
@@ -386,7 +403,7 @@ public class NotificationRemoteInputManager implements Dumpable {
 
         riv.setRevealParameters(cx, cy, r);
         riv.setPendingIntent(pendingIntent);
-        riv.setRemoteInput(inputs, input);
+        riv.setRemoteInput(inputs, input, editedSuggestionInfo);
         riv.focusAnimated();
 
         return true;
index 5a8f71d..736b9eb 100644 (file)
@@ -56,13 +56,12 @@ public class SmartReplyController {
      * Notifies StatusBarService a smart reply is sent.
      */
     public void smartReplySent(NotificationEntry entry, int replyIndex, CharSequence reply,
-            boolean generatedByAssistant, int notificationLocation) {
+            int notificationLocation, boolean modifiedBeforeSending) {
         mCallback.onSmartReplySent(entry, reply);
         mSendingKeys.add(entry.key);
         try {
-            mBarService.onNotificationSmartReplySent(
-                    entry.notification.getKey(), replyIndex, reply, generatedByAssistant,
-                    notificationLocation);
+            mBarService.onNotificationSmartReplySent(entry.notification.getKey(), replyIndex, reply,
+                    notificationLocation, modifiedBeforeSending);
         } catch (RemoteException e) {
             // Nothing to do, system going down
         }
@@ -100,10 +99,10 @@ public class SmartReplyController {
      * Smart Replies and Actions have been added to the UI.
      */
     public void smartSuggestionsAdded(final NotificationEntry entry, int replyCount,
-            int actionCount, boolean generatedByAssistant) {
+            int actionCount, boolean generatedByAssistant, boolean editBeforeSending) {
         try {
-            mBarService.onNotificationSmartSuggestionsAdded(
-                    entry.notification.getKey(), replyCount, actionCount, generatedByAssistant);
+            mBarService.onNotificationSmartSuggestionsAdded(entry.notification.getKey(), replyCount,
+                    actionCount, generatedByAssistant, editBeforeSending);
         } catch (RemoteException e) {
             // Nothing to do, system going down
         }
index db9fcc8..9f1693c 100644 (file)
@@ -105,6 +105,14 @@ public final class NotificationEntry {
     /** Smart replies provided by the NotificationAssistantService. */
     @NonNull
     public CharSequence[] systemGeneratedSmartReplies = new CharSequence[0];
+
+    /**
+     * If {@link android.app.RemoteInput#getEditChoicesBeforeSending} is enabled, and the user is
+     * currently editing a choice (smart reply), then this field contains the information about the
+     * suggestion being edited. Otherwise <code>null</code>.
+     */
+    public EditedSuggestionInfo editedSuggestionInfo;
+
     @VisibleForTesting
     public int suppressedVisualEffects;
     public boolean suspended;
@@ -746,4 +754,23 @@ public final class NotificationEntry {
     private static boolean isCategory(String category, Notification n) {
         return Objects.equals(n.category, category);
     }
+
+    /** Information about a suggestion that is being edited. */
+    public static class EditedSuggestionInfo {
+
+        /**
+         * The value of the suggestion (before any user edits).
+         */
+        public final CharSequence originalText;
+
+        /**
+         * The index of the suggestion that is being edited.
+         */
+        public final int index;
+
+        public EditedSuggestionInfo(CharSequence originalText, int index) {
+            this.originalText = originalText;
+            this.index = index;
+        }
+    }
 }
index 878d533..8095615 100644 (file)
@@ -1509,8 +1509,13 @@ public class NotificationContentView extends FrameLayout {
                     boolean fromAssistant = smartRepliesAndActions.smartReplies == null
                             ? smartRepliesAndActions.smartActions.fromAssistant
                             : smartRepliesAndActions.smartReplies.fromAssistant;
+                    boolean editBeforeSending = smartRepliesAndActions.smartReplies != null
+                            && mSmartReplyConstants.getEffectiveEditChoicesBeforeSending(
+                                    smartRepliesAndActions.smartReplies.remoteInput
+                                            .getEditChoicesBeforeSending());
+
                     mSmartReplyController.smartSuggestionsAdded(entry, numSmartReplies,
-                            numSmartActions, fromAssistant);
+                            numSmartActions, fromAssistant, editBeforeSending);
                 }
             }
         }
index 7881df9..1e09063 100644 (file)
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.policy;
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
+import android.annotation.Nullable;
 import android.app.ActivityManager;
 import android.app.Notification;
 import android.app.PendingIntent;
@@ -59,6 +60,7 @@ import com.android.systemui.Interpolators;
 import com.android.systemui.R;
 import com.android.systemui.statusbar.RemoteInputController;
 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
+import com.android.systemui.statusbar.notification.collection.NotificationEntry.EditedSuggestionInfo;
 import com.android.systemui.statusbar.notification.row.wrapper.NotificationViewWrapper;
 import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
 
@@ -269,10 +271,24 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
         mPendingIntent = pendingIntent;
     }
 
-    public void setRemoteInput(RemoteInput[] remoteInputs, RemoteInput remoteInput) {
+    /**
+     * Sets the remote input for this view.
+     *
+     * @param remoteInputs The remote inputs that need to be sent to the app.
+     * @param remoteInput The remote input that needs to be activated.
+     * @param editedSuggestionInfo The smart reply that should be inserted in the remote input, or
+     *         {@code null} if the user is not editing a smart reply.
+     */
+    public void setRemoteInput(RemoteInput[] remoteInputs, RemoteInput remoteInput,
+            @Nullable EditedSuggestionInfo editedSuggestionInfo) {
         mRemoteInputs = remoteInputs;
         mRemoteInput = remoteInput;
         mEditText.setHint(mRemoteInput.getLabel());
+
+        mEntry.editedSuggestionInfo = editedSuggestionInfo;
+        if (editedSuggestionInfo != null) {
+            mEntry.remoteInputText = editedSuggestionInfo.originalText;
+        }
     }
 
     public void focusAnimated() {
@@ -389,7 +405,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
     public void stealFocusFrom(RemoteInputView other) {
         other.close();
         setPendingIntent(other.mPendingIntent);
-        setRemoteInput(other.mRemoteInputs, other.mRemoteInput);
+        setRemoteInput(other.mRemoteInputs, other.mRemoteInput, mEntry.editedSuggestionInfo);
         setRevealParameters(other.mRevealCx, other.mRevealCy, other.mRevealR);
         focus();
     }
@@ -429,7 +445,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
                 continue;
             }
             setPendingIntent(a.actionIntent);
-            setRemoteInput(inputs, input);
+            setRemoteInput(inputs, input, null /* editedSuggestionInfo*/);
             return true;
         }
         return false;
index 1d2d6f7..45d215e 100644 (file)
@@ -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.collection.NotificationEntry.EditedSuggestionInfo;
 import com.android.systemui.statusbar.notification.logging.NotificationLogger;
 import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
 
@@ -252,16 +253,17 @@ public class SmartReplyView extends ViewGroup {
         OnDismissAction action = () -> {
             if (mConstants.getEffectiveEditChoicesBeforeSending(
                     smartReplies.remoteInput.getEditChoicesBeforeSending())) {
-                entry.remoteInputText = choice;
+                EditedSuggestionInfo editedSuggestionInfo =
+                        new EditedSuggestionInfo(choice, replyIndex);
                 mRemoteInputManager.activateRemoteInput(b,
                         new RemoteInput[] { smartReplies.remoteInput }, smartReplies.remoteInput,
-                        smartReplies.pendingIntent);
+                        smartReplies.pendingIntent, editedSuggestionInfo);
                 return false;
             }
 
             smartReplyController.smartReplySent(entry, replyIndex, b.getText(),
-                    smartReplies.fromAssistant,
-                    NotificationLogger.getNotificationLocation(entry).toMetricsEventEnum());
+                    NotificationLogger.getNotificationLocation(entry).toMetricsEventEnum(),
+                    false /* modifiedBeforeSending */);
             Bundle results = new Bundle();
             results.putString(smartReplies.remoteInput.getResultKey(), choice.toString());
             Intent intent = new Intent().addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
index f34e1a6..31cd280 100644 (file)
@@ -98,8 +98,8 @@ public class SmartReplyControllerTest extends SysuiTestCase {
 
     @Test
     public void testSendSmartReply_updatesRemoteInput() {
-        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
-                MetricsEvent.LOCATION_UNKNOWN);
+        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT,
+                MetricsEvent.LOCATION_UNKNOWN, false /* modifiedBeforeSending */);
 
         // Sending smart reply should make calls to NotificationEntryManager
         // to update the notification with reply and spinner.
@@ -109,48 +109,49 @@ public class SmartReplyControllerTest extends SysuiTestCase {
 
     @Test
     public void testSendSmartReply_logsToStatusBar() throws RemoteException {
-        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
-                MetricsEvent.LOCATION_UNKNOWN);
+        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT,
+                MetricsEvent.LOCATION_UNKNOWN, false /* modifiedBeforeSending */);
 
         // Check we log the result to the status bar service.
         verify(mIStatusBarService).onNotificationSmartReplySent(mSbn.getKey(),
-                TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false, MetricsEvent.LOCATION_UNKNOWN);
+                TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, MetricsEvent.LOCATION_UNKNOWN, false);
     }
 
 
     @Test
-    public void testSendSmartReply_logsToStatusBar_generatedByAssistant() throws RemoteException {
-        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true,
-                MetricsEvent.LOCATION_UNKNOWN);
+    public void testSendSmartReply_logsToStatusBar_modifiedBeforeSending() throws RemoteException {
+        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT,
+                MetricsEvent.LOCATION_UNKNOWN, true /* modifiedBeforeSending */);
 
         // Check we log the result to the status bar service.
         verify(mIStatusBarService).onNotificationSmartReplySent(mSbn.getKey(),
-                TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, true, MetricsEvent.LOCATION_UNKNOWN);
+                TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, MetricsEvent.LOCATION_UNKNOWN, true);
     }
 
     @Test
     public void testShowSmartSuggestions_logsToStatusBar() throws RemoteException {
         final boolean generatedByAsssistant = true;
+        final boolean editBeforeSending = true;
         mSmartReplyController.smartSuggestionsAdded(mEntry, TEST_CHOICE_COUNT, TEST_ACTION_COUNT,
-                generatedByAsssistant);
+                generatedByAsssistant, editBeforeSending);
 
         // Check we log the result to the status bar service.
         verify(mIStatusBarService).onNotificationSmartSuggestionsAdded(mSbn.getKey(),
-                TEST_CHOICE_COUNT, TEST_ACTION_COUNT, generatedByAsssistant);
+                TEST_CHOICE_COUNT, TEST_ACTION_COUNT, generatedByAsssistant, editBeforeSending);
     }
 
     @Test
     public void testSendSmartReply_reportsSending() {
-        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
-                MetricsEvent.LOCATION_UNKNOWN);
+        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT,
+                MetricsEvent.LOCATION_UNKNOWN, false /* modifiedBeforeSending */);
 
         assertTrue(mSmartReplyController.isSendingSmartReply(mSbn.getKey()));
     }
 
     @Test
     public void testSendingSmartReply_afterRemove_shouldReturnFalse() {
-        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT, false,
-                MetricsEvent.LOCATION_UNKNOWN);
+        mSmartReplyController.smartReplySent(mEntry, TEST_CHOICE_INDEX, TEST_CHOICE_TEXT,
+                MetricsEvent.LOCATION_UNKNOWN, false /* modifiedBeforeSending */);
         mSmartReplyController.stopSending(mEntry);
 
         assertFalse(mSmartReplyController.isSendingSmartReply(mSbn.getKey()));
index ed98c62..568ff55 100644 (file)
@@ -96,7 +96,7 @@ public class RemoteInputViewTest extends SysuiTestCase {
         RemoteInput input = new RemoteInput.Builder(TEST_RESULT_KEY).build();
 
         view.setPendingIntent(pendingIntent);
-        view.setRemoteInput(new RemoteInput[]{input}, input);
+        view.setRemoteInput(new RemoteInput[]{input}, input, null /* editedSuggestionInfo */);
     }
 
     @Test
index 5570122..6793eca 100644 (file)
@@ -191,15 +191,7 @@ public class SmartReplyViewTest extends SysuiTestCase {
         setSmartReplies(TEST_CHOICES);
         mView.getChildAt(2).performClick();
         verify(mLogger).smartReplySent(mEntry, 2, TEST_CHOICES[2],
-                false /* generatedByAsssitant */, MetricsEvent.LOCATION_UNKNOWN);
-    }
-
-    @Test
-    public void testSendSmartReply_controllerCalled_generatedByAssistant() {
-        setSmartReplies(TEST_CHOICES, true);
-        mView.getChildAt(2).performClick();
-        verify(mLogger).smartReplySent(mEntry, 2, TEST_CHOICES[2],
-                true /* generatedByAsssitant */, MetricsEvent.LOCATION_UNKNOWN);
+                MetricsEvent.LOCATION_UNKNOWN, false /* modifiedBeforeSending */);
     }
 
     @Test
index 76bb24d..eb8710d 100644 (file)
@@ -6936,6 +6936,19 @@ message MetricsEvent {
     // OS: Q
     ACTION_SET_NEW_PARENT_PROFILE_PASSWORD = 1646;
 
+    // Tagged data for SMART_REPLY_VISIBLE and SMART_REPLY_ACTION.
+    // Whether the smart reply was / is to be sent via direct reply because
+    // getEditChoicesBeforeSending was enabled.
+    // OS: Q
+    NOTIFICATION_SMART_REPLY_EDIT_BEFORE_SENDING = 1647;
+
+    // Tagged data for SMART_REPLY_ACTION.
+    // Whether the smart reply was modified by the user via the direct reply field (implies that
+    // getEditChoicesBeforeSending was enabled).
+    // actions/replies.
+    // OS: Q
+    NOTIFICATION_SMART_REPLY_MODIFIED_BEFORE_SENDING = 1648;
+
     // ---- End Q Constants, all Q constants go above this line ----
     // Add new aosp constants above this line.
     // END OF AOSP CONSTANTS
index be15fda..b85abd9 100644 (file)
@@ -51,7 +51,7 @@ public interface NotificationDelegate {
      * Notifies that smart replies and actions have been added to the UI.
      */
     void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount, int smartActionCount,
-            boolean generatedByAssistant);
+            boolean generatedByAssistant, boolean editBeforeSending);
 
     /**
      * Notifies a smart reply is sent.
@@ -59,9 +59,9 @@ public interface NotificationDelegate {
      * @param key the notification key
      * @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
+     * @param modifiedBeforeSending whether the user changed the smart reply before sending
      */
     void onNotificationSmartReplySent(String key, int clickedIndex, CharSequence reply,
-            boolean generatedByAssistant, int notificationLocation);
+            int notificationLocation, boolean modifiedBeforeSending);
 }
index ba187c0..34a6663 100644 (file)
@@ -917,20 +917,21 @@ public class NotificationManagerService extends SystemService {
 
         @Override
         public void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount,
-                int smartActionCount, boolean generatedByAssistant) {
+                int smartActionCount, boolean generatedByAssistant, boolean editBeforeSending) {
             synchronized (mNotificationLock) {
                 NotificationRecord r = mNotificationsByKey.get(key);
                 if (r != null) {
                     r.setNumSmartRepliesAdded(smartReplyCount);
                     r.setNumSmartActionsAdded(smartActionCount);
                     r.setSuggestionsGeneratedByAssistant(generatedByAssistant);
+                    r.setEditChoicesBeforeSending(editBeforeSending);
                 }
             }
         }
 
         @Override
         public void onNotificationSmartReplySent(String key, int replyIndex, CharSequence reply,
-                boolean generatedByAssistant, int notificationLocation) {
+                int notificationLocation, boolean modifiedBeforeSending) {
 
             synchronized (mNotificationLock) {
                 NotificationRecord r = mNotificationsByKey.get(key);
@@ -940,14 +941,20 @@ public class NotificationManagerService extends SystemService {
                             .setSubtype(replyIndex)
                             .addTaggedData(
                                     MetricsEvent.NOTIFICATION_SMART_SUGGESTION_ASSISTANT_GENERATED,
-                                    generatedByAssistant ? 1 : 0)
+                                    r.getSuggestionsGeneratedByAssistant() ? 1 : 0)
                             .addTaggedData(MetricsEvent.NOTIFICATION_LOCATION,
-                                    notificationLocation);
+                                    notificationLocation)
+                            .addTaggedData(
+                                    MetricsEvent.NOTIFICATION_SMART_REPLY_EDIT_BEFORE_SENDING,
+                                    r.getEditChoicesBeforeSending() ? 1 : 0)
+                            .addTaggedData(
+                                    MetricsEvent.NOTIFICATION_SMART_REPLY_MODIFIED_BEFORE_SENDING,
+                                    modifiedBeforeSending ? 1 : 0);
                     mMetricsLogger.write(logMaker);
                     // Treat clicking on a smart reply as a user interaction.
                     reportUserInteraction(r);
                     mAssistants.notifyAssistantSuggestedReplySent(
-                            r.sbn, reply, generatedByAssistant);
+                            r.sbn, reply, r.getSuggestionsGeneratedByAssistant());
                 }
             }
         }
@@ -981,7 +988,10 @@ public class NotificationManagerService extends SystemService {
                             r.getSuggestionsGeneratedByAssistant() ? 1 : 0)
                     // The fields in the NotificationVisibility.NotificationLocation enum map
                     // directly to the fields in the MetricsEvent.NotificationLocation enum.
-                    .addTaggedData(MetricsEvent.NOTIFICATION_LOCATION, notificationLocation);
+                    .addTaggedData(MetricsEvent.NOTIFICATION_LOCATION, notificationLocation)
+                    .addTaggedData(
+                            MetricsEvent.NOTIFICATION_SMART_REPLY_EDIT_BEFORE_SENDING,
+                            r.getEditChoicesBeforeSending() ? 1 : 0);
             mMetricsLogger.write(logMaker);
         }
     }
index ab49ebb..b3394b4 100644 (file)
@@ -178,6 +178,7 @@ public final class NotificationRecord {
     private int mNumberOfSmartRepliesAdded;
     private int mNumberOfSmartActionsAdded;
     private boolean mSuggestionsGeneratedByAssistant;
+    private boolean mEditChoicesBeforeSending;
     private boolean mHasSeenSmartReplies;
     /**
      * Whether this notification (and its channels) should be considered user locked. Used in
@@ -1136,6 +1137,14 @@ public final class NotificationRecord {
         return mSuggestionsGeneratedByAssistant;
     }
 
+    public boolean getEditChoicesBeforeSending() {
+        return mEditChoicesBeforeSending;
+    }
+
+    public void setEditChoicesBeforeSending(boolean editChoicesBeforeSending) {
+        mEditChoicesBeforeSending = editChoicesBeforeSending;
+    }
+
     public boolean hasSeenSmartReplies() {
         return mHasSeenSmartReplies;
     }
index d932a40..0493ae9 100644 (file)
@@ -1280,12 +1280,12 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
 
     @Override
     public void onNotificationSmartSuggestionsAdded(String key, int smartReplyCount,
-            int smartActionCount, boolean generatedByAssistant) {
+            int smartActionCount, boolean generatedByAssistant, boolean editBeforeSending) {
         enforceStatusBarService();
         long identity = Binder.clearCallingIdentity();
         try {
             mNotificationDelegate.onNotificationSmartSuggestionsAdded(key, smartReplyCount,
-                    smartActionCount, generatedByAssistant);
+                    smartActionCount, generatedByAssistant, editBeforeSending);
         } finally {
             Binder.restoreCallingIdentity(identity);
         }
@@ -1293,13 +1293,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
 
     @Override
     public void onNotificationSmartReplySent(
-            String key, int replyIndex, CharSequence reply, boolean generatedByAssistant,
-            int notificationLocation) throws RemoteException {
+            String key, int replyIndex, CharSequence reply, int notificationLocation,
+            boolean modifiedBeforeSending) throws RemoteException {
         enforceStatusBarService();
         long identity = Binder.clearCallingIdentity();
         try {
             mNotificationDelegate.onNotificationSmartReplySent(key, replyIndex, reply,
-                    generatedByAssistant, notificationLocation);
+                    notificationLocation, modifiedBeforeSending);
         } finally {
             Binder.restoreCallingIdentity(identity);
         }
index 4cae3b3..72aa0f2 100644 (file)
@@ -3925,13 +3925,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
     public void testOnNotificationSmartReplySent() {
         final int replyIndex = 2;
         final String reply = "Hello";
+        final boolean modifiedBeforeSending = true;
         final boolean generatedByAssistant = true;
 
         NotificationRecord r = generateNotificationRecord(mTestNotificationChannel);
+        r.setSuggestionsGeneratedByAssistant(generatedByAssistant);
         mService.addNotification(r);
 
         mService.mNotificationDelegate.onNotificationSmartReplySent(
-                r.getKey(), replyIndex, reply, generatedByAssistant, NOTIFICATION_LOCATION_UNKNOWN);
+                r.getKey(), replyIndex, reply, NOTIFICATION_LOCATION_UNKNOWN,
+                modifiedBeforeSending);
         verify(mAssistants).notifyAssistantSuggestedReplySent(
                 eq(r.sbn), eq(reply), eq(generatedByAssistant));
     }