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

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

Merge "Log notification location and assistant-generated when smart reply sent"

parents b278ec38 13edb497
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);

+3 −2
Original line number Diff line number Diff line
@@ -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
        }
+4 −2
Original line number Diff line number Diff line
@@ -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);
+13 −7
Original line number Diff line number Diff line
@@ -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()));
+3 −2
Original line number Diff line number Diff line
@@ -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;
@@ -190,7 +191,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
@@ -198,7 +199,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
Loading