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

Commit d25a64da authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Add logging for smart replies and actions.

Log (using TRON)
1. when smart replies and actions are shown in a notification, and
2. when a smart action is clicked.

Bug: 120767764
Test: manual - use logcat to ensure we log the correct values when a
notification is expanded / smart action is clicked.

Change-Id: I85dbc3ee355997142ad71b7b67a759e8fede94b6
parent 126a2d2c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ interface IStatusBarService
            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);
+7 −3
Original line number Diff line number Diff line
@@ -88,10 +88,14 @@ public class SmartReplyController {
        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
        }
+13 −3
Original line number Diff line number Diff line
@@ -1474,9 +1474,19 @@ public class NotificationContentView extends FrameLayout {
        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) {
+7 −4
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public class SmartReplyControllerTest extends SysuiTestCase {
    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 @@ public class SmartReplyControllerTest extends SysuiTestCase {
    }

    @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
+6 −1
Original line number Diff line number Diff line
@@ -45,7 +45,12 @@ public interface NotificationDelegate {
    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.
Loading