Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6a335de authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add logging for tap-to-edit smart replies"

parents 446105cb 13d88111
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);

+20 −3
Original line number Diff line number Diff line
@@ -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;
+6 −7
Original line number Diff line number Diff line
@@ -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
        }
+27 −0
Original line number Diff line number Diff line
@@ -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;
        }
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -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);
                }
            }
        }
Loading