All the visible and invisible actions should be checked for compatibility.
Earlier only the visible actions were being checked.
Bug: 131421570
Test: Manual
Change-Id: I59ac16371df6e333b56c66fd519a6250bfb4d650
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 b6a48e2..b0b43f0 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
@@ -33,6 +33,7 @@
import com.android.car.assist.client.tts.TextToSpeechHelper;
import com.android.internal.app.AssistUtils;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -151,16 +152,26 @@
* is returned if multiple callbacks exist for any semantic action that is supported.
*/
private static boolean hasRequiredAssistantCallbacks(StatusBarNotification sbn) {
- List<Integer> semanticActionList = Arrays.stream(sbn.getNotification().actions)
- .map(Notification.Action::getSemanticAction)
+ List<Integer> semanticActionList = getAllActions(sbn.getNotification())
+ .stream()
+ .map(NotificationCompat.Action::getSemanticAction)
.filter(REQUIRED_SEMANTIC_ACTIONS::contains)
.collect(Collectors.toList());
Set<Integer> semanticActionSet = new HashSet<>(semanticActionList);
-
return semanticActionList.size() == semanticActionSet.size()
&& semanticActionSet.containsAll(REQUIRED_SEMANTIC_ACTIONS);
}
+ /** Retrieves all visible and invisible {@link Action}s from the {@link #notification}. */
+ private static List<NotificationCompat.Action> getAllActions(Notification notification) {
+ List<NotificationCompat.Action> actions = new ArrayList<>();
+ actions.addAll(NotificationCompat.getInvisibleActions(notification));
+ for (int i = 0; i < NotificationCompat.getActionCount(notification); i++) {
+ actions.add(NotificationCompat.getAction(notification, i));
+ }
+ return actions;
+ }
+
/**
* Returns true if the reply callback has at least one {@link RemoteInput}.
* <p/>