@@ -292,7 +360,7 @@ public class SmartActionsHelper { mTextClassifier.onTextClassifierEvent(textClassifierEvent); } - private Notification.Action createNotificationAction( + private Notification.Action createNotificationActionFromRemoteAction( RemoteAction remoteAction, String actionType, float score) { Icon icon = remoteAction.shouldShowIcon() ? remoteAction.getIcon() diff --git a/packages/ExtServices/tests/src/android/ext/services/notification/SmartActionsHelperTest.java b/packages/ExtServices/tests/src/android/ext/services/notification/SmartActionsHelperTest.java index a1fbc7bef1342..3a7d799ea2ebb 100644 --- a/packages/ExtServices/tests/src/android/ext/services/notification/SmartActionsHelperTest.java +++ b/packages/ExtServices/tests/src/android/ext/services/notification/SmartActionsHelperTest.java @@ -36,6 +36,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.IPackageManager; import android.graphics.drawable.Icon; +import android.os.Bundle; import android.os.Process; import android.service.notification.NotificationAssistantService; import android.service.notification.StatusBarNotification; @@ -419,6 +420,31 @@ public class SmartActionsHelperTest { assertTextClassifierEvent(events.get(1), TextClassifierEvent.TYPE_ACTIONS_SHOWN); } + @Test + public void testCopyAction() { + Bundle extras = new Bundle(); + Bundle entitiesExtras = new Bundle(); + entitiesExtras.putString(SmartActionsHelper.KEY_TEXT, "12345"); + extras.putParcelable(SmartActionsHelper.ENTITIES_EXTRAS, entitiesExtras); + ConversationAction conversationAction = + new ConversationAction.Builder(ConversationAction.TYPE_COPY) + .setExtras(extras) + .build(); + when(mTextClassifier.suggestConversationActions(any(ConversationActions.Request.class))) + .thenReturn( + new ConversationActions( + Collections.singletonList(conversationAction), null)); + + Notification notification = createMessageNotification(); + when(mStatusBarNotification.getNotification()).thenReturn(notification); + SmartActionsHelper.SmartSuggestions suggestions = + mSmartActionsHelper.suggest(createNotificationEntry()); + + assertThat(suggestions.actions).hasSize(1); + Notification.Action action = suggestions.actions.get(0); + assertThat(action.title).isEqualTo("12345"); + } + private ZonedDateTime createZonedDateTimeFromMsUtc(long msUtc) { return ZonedDateTime.ofInstant(Instant.ofEpochMilli(msUtc), ZoneOffset.systemDefault()); }