Fix bug in car-compat-message-notification criteria

REPLY is not required action for message notifications. Previously it was.
If REPLY ~is~ given in the notification, we check to see it has at least one
RemoteInput. However, when we removed the requirement, we didn't gate the
RemoteInput check based on the presence of REPLY. Therefore, even if a notification
meets our new requirements when not having REPLY, it will still fail this
classification, because the RemoteInput check will still require REPLY action.

Bug: 137654440
Test: manually verified that message notifications are classified correctly
 by having Messenger App send notifications without/with REPLY action.

Change-Id: I5679c1427b5b32e592ff23c9ba6f7bccdf78b45d
diff --git a/car-assist-client-lib/src/com/android/car/assist/client/CarAssistUtils.java b/car-assist-client-lib/src/com/android/car/assist/client/CarAssistUtils.java
index a4a95a9..1ef55cc 100644
--- a/car-assist-client-lib/src/com/android/car/assist/client/CarAssistUtils.java
+++ b/car-assist-client-lib/src/com/android/car/assist/client/CarAssistUtils.java
@@ -161,7 +161,8 @@
     public static boolean isCarCompatibleMessagingNotification(StatusBarNotification sbn) {
         return hasMessagingStyle(sbn)
                 && hasRequiredAssistantCallbacks(sbn)
-                && replyCallbackHasRemoteInput(sbn)
+                && ((getReplyAction(sbn.getNotification()) == null)
+                    || replyCallbackHasRemoteInput(sbn))
                 && assistantCallbacksShowNoUi(sbn);
     }
 
@@ -224,6 +225,21 @@
     }
 
     /**
+     * Retrieves the {@link NotificationCompat.Action} containing the
+     * {@link NotificationCompat.Action#SEMANTIC_ACTION_REPLY} semantic action.
+     */
+    @Nullable
+    private static NotificationCompat.Action getReplyAction(Notification notification) {
+        for (NotificationCompat.Action action : getAllActions(notification)) {
+            if (action.getSemanticAction()
+                    == NotificationCompat.Action.SEMANTIC_ACTION_REPLY) {
+                return action;
+            }
+        }
+        return null;
+    }
+
+    /**
      * Returns true if the reply callback has at least one {@link RemoteInput}.
      * <p/>
      * Precondition: There exists only one reply callback.