Add boolean to Exception bundle, to indicate if Fallback is enabled

Fix: 142153888
Test: mma

Change-Id: Ib82c8c23c4e0658e277bc7e9efec7fc30f2ea6c6
diff --git a/car-assist-client-lib/src/com/android/car/assist/client/BundleBuilder.java b/car-assist-client-lib/src/com/android/car/assist/client/BundleBuilder.java
index 742eca6..9428247 100644
--- a/car-assist-client-lib/src/com/android/car/assist/client/BundleBuilder.java
+++ b/car-assist-client-lib/src/com/android/car/assist/client/BundleBuilder.java
@@ -17,6 +17,7 @@
 
 import static com.android.car.assist.CarVoiceInteractionSession.KEY_ACTION;
 import static com.android.car.assist.CarVoiceInteractionSession.KEY_EXCEPTION;
+import static com.android.car.assist.CarVoiceInteractionSession.KEY_FALLBACK_ASSISTANT_ENABLED;
 import static com.android.car.assist.CarVoiceInteractionSession.KEY_NOTIFICATION;
 import static com.android.car.assist.CarVoiceInteractionSession.VOICE_ACTION_HANDLE_EXCEPTION;
 import static com.android.car.assist.CarVoiceInteractionSession.VOICE_ACTION_READ_NOTIFICATION;
@@ -66,10 +67,12 @@
      * @return The bundle that can be sent to Assistant.
      */
     static Bundle buildAssistantHandleExceptionBundle(
-            @ExceptionValue String exception) {
+            @ExceptionValue String exception,
+            boolean fallbackAssistantEnabled) {
         Bundle args = new Bundle();
         args.putString(KEY_ACTION, VOICE_ACTION_HANDLE_EXCEPTION);
         args.putString(KEY_EXCEPTION, exception);
+        args.putBoolean(KEY_FALLBACK_ASSISTANT_ENABLED, fallbackAssistantEnabled);
         return args;
     }
 }
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 029467e..1f9d915 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
@@ -346,7 +346,8 @@
                 // If there is an active assistant, alert them to request permissions.
                 Bundle handleExceptionBundle = BundleBuilder
                         .buildAssistantHandleExceptionBundle(
-                                EXCEPTION_NOTIFICATION_LISTENER_PERMISSIONS_MISSING);
+                                EXCEPTION_NOTIFICATION_LISTENER_PERMISSIONS_MISSING,
+                                /* fallbackAssistantEnabled */ false);
                 fireAssistantAction(CarVoiceInteractionSession.VOICE_ACTION_HANDLE_EXCEPTION,
                         handleExceptionBundle, callback);
             }
@@ -390,8 +391,13 @@
                 final String fallbackActionResult = hasError ? ActionRequestCallback.RESULT_FAILED
                         : ActionRequestCallback.RESULT_SUCCESS;
                 if (hasActiveAssistant()) {
+                    // If there is an active assistant, alert them to request permissions.
+                    Bundle handleExceptionBundle = BundleBuilder
+                            .buildAssistantHandleExceptionBundle(
+                                    EXCEPTION_NOTIFICATION_LISTENER_PERMISSIONS_MISSING,
+                                    /* fallbackAssistantEnabled */ true);
                     fireAssistantAction(CarVoiceInteractionSession.VOICE_ACTION_HANDLE_EXCEPTION,
-                            null, new ActionRequestCallback() {
+                            handleExceptionBundle, new ActionRequestCallback() {
                                 @Override
                                 public void onResult(String requestActionFromAssistantResult) {
                                     if (fallbackActionResult.equals(
diff --git a/car-assist-lib/src/com/android/car/assist/CarVoiceInteractionSession.java b/car-assist-lib/src/com/android/car/assist/CarVoiceInteractionSession.java
index cd58229..6c16fdc 100644
--- a/car-assist-lib/src/com/android/car/assist/CarVoiceInteractionSession.java
+++ b/car-assist-lib/src/com/android/car/assist/CarVoiceInteractionSession.java
@@ -42,6 +42,13 @@
     public static final String KEY_EXCEPTION = "KEY_EXCEPTION";
 
     /**
+     * The key used for the {@link CarVoiceInteractionSession#VOICE_ACTION_HANDLE_EXCEPTION} payload
+     * {@link Bundle}. Must map to a boolean. If value is true, the Fallback Assistant that can
+     * handle the user's request has been disabled.
+     */
+    public static final String KEY_FALLBACK_ASSISTANT_ENABLED = "KEY_FALLBACK_ASSISTANT_ENABLED";
+
+    /**
      * The key used for the payload {@link Bundle}, if a {@link StatusBarNotification} is used as
      * the payload.
      */