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

Commit c252d1c0 authored by Srini S's avatar Srini S
Browse files

Add ACTION_STOP_VOICE_COMMAND intent

Add ACTION_STOP_VOICE_COMMAND intent to stop Voice Assistant
session over Bluetooth.
This intent will be broadcasted from Bluetooth Service to
inform Assistant apps to stop Voice Assistant session.

Following extras would be part of this intent:
a. EXTRA_DEVICE indicates the BluetoothDevice which initiated this
request.
b. EXTRA_PROFILE indicates the profile (BluetoothProfile#HEADSET
or BluetoothProfile#LE_AUDIO) which triggered this request.

Assistant apps would use this new intent to end the Voice
Assistant session over Bluetooth.

If the EXTRA_PROFILE is BluetoothProfile#HEADSET, the assistant app should call BluetoothHeadset#stopVoiceRecognition to stop voice assistant session.
If the EXTRA_PROFILE is BluetoothProfile#LE_AUDIO, the app should call AudioRecord#stop() to stop voice assistant session.

Test: atest PairingTest
Flag: android.content.flags.stop_voice_command
Bug: 419049796

Change-Id: I6fb7836c663564a67882ec38c105546b124d93d0
parent 5891a5d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11688,6 +11688,7 @@ package android.content {
    field public static final String ACTION_SHOW_APP_INFO = "android.intent.action.SHOW_APP_INFO";
    field public static final String ACTION_SHOW_WORK_APPS = "android.intent.action.SHOW_WORK_APPS";
    field public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
    field @FlaggedApi("android.content.flags.stop_voice_command") public static final String ACTION_STOP_VOICE_COMMAND = "android.intent.action.STOP_VOICE_COMMAND";
    field public static final String ACTION_SYNC = "android.intent.action.SYNC";
    field public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
    field public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
+79 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content;
import static android.content.ContentProvider.maybeAddUserId;
import static android.content.flags.Flags.FLAG_STOP_VOICE_COMMAND;
import static android.os.Flags.FLAG_ALLOW_PRIVATE_PROFILE;
import static android.security.Flags.FLAG_FRP_ENFORCEMENT;
import static android.security.Flags.FLAG_PREVENT_INTENT_REDIRECT;
@@ -1577,7 +1578,53 @@ public class Intent implements Parcelable, Cloneable {
    /**
     * Activity Action: Start Voice Command.
     * <p>Input: Nothing.
     *
     * <p>
     * For apps targeting or running on devices with SDK version
     * {@link android.os.Build.VERSION_CODES#BAKLAVA} or lower, the extras
     * {@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE} and
     * {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE} are not
     * included as part of the intent.
     * For apps targeting versions higher than
     * {@link android.os.Build.VERSION_CODES#BAKLAVA}, the extras
     * {@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE} and
     * {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE} are included as
     * part of the intent.
     *
     * <p>Information about the extras is below.
     * <ul>
     *   <li><em>{@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE}</em>
     *       indicates the {@link android.bluetooth.BluetoothDevice} which
     *       initiated this request.</li>
     *   <li><em>{@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE}</em>
     *       indicates the profile (e.g., {@link android.bluetooth.BluetoothProfile#HEADSET}
     *       or {@link android.bluetooth.BluetoothProfile#LE_AUDIO}) which triggered this
     *       request.</li>
     * </ul>
     *
     * <p>
     * Additionally, if the {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE}
     * is {@link android.bluetooth.BluetoothProfile#HEADSET}, the app should call
     * the following APIs to start voice assistant session.
     * <ul>
     *   <li>{@link android.bluetooth.BluetoothHeadset#startVoiceRecognition}</li>
     *   <li>{@link android.media.AudioRecord#setPreferredDevice()} for the
     *       {@link android.media.AudioDeviceInfo#TYPE_BLUETOOTH_SCO} device
     *       whose MAC address matches the address received in
     *       {@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE}</li>
     *   <li>{@link android.media.AudioRecord#startRecording()}</li>
     * </ul>
     * <p>
     * If the {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE} is
     * {@link android.bluetooth.BluetoothProfile#LE_AUDIO}, the app should call
     * the following APIs to start voice assistant session.
     * <ul>
     *   <li>{@link android.media.AudioRecord#setPreferredDevice()} for the
     *       {@link android.media.AudioDeviceInfo#TYPE_BLE_HEADSET} device
     *       whose MAC address matches the address received in
     *       {@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE}</li>
     *   <li>{@link android.media.AudioRecord#startRecording()}</li>
     * </ul>
     * <p>Output: Nothing.
     * <p class="note">
     * In some cases, a matching Activity may not exist, so ensure you
@@ -1586,6 +1633,37 @@ public class Intent implements Parcelable, Cloneable {
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
    /**
     * Broadcast Action: Stop Voice Command.
     *
     * <p>The intent will have the following extra values.
     * <ul>
     *   <li><em>{@link android.bluetooth.BluetoothDevice#EXTRA_DEVICE}</em>
     *       indicates the BluetoothDevice which initiated this request.</li>
     *   <li><em>{@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE}</em>
     *       indicates the profile (e.g., {@link android.bluetooth.BluetoothProfile#HEADSET}
     *       or {@link android.bluetooth.BluetoothProfile#LE_AUDIO}) which
     *       triggered this request.</li>
     * </ul>
     *
     * <p>
     * Additionally, if the {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE}
     * is {@link android.bluetooth.BluetoothProfile#HEADSET}, the app should call
     * {@link android.bluetooth.BluetoothHeadset#stopVoiceRecognition} to stop
     * voice assistant session.
     * If the {@link android.bluetooth.BluetoothProfile#EXTRA_PROFILE} is
     * {@link android.bluetooth.BluetoothProfile#LE_AUDIO}, the app should call
     * {@link android.media.AudioRecord#stop()} to stop voice assistant session.
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
     */
    @FlaggedApi(FLAG_STOP_VOICE_COMMAND)
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    @BroadcastBehavior(includeBackground = true)
    public static final String ACTION_STOP_VOICE_COMMAND
            = "android.intent.action.STOP_VOICE_COMMAND";
    /**
     * Activity Action: Start action associated with long pressing on the
     * search key.
+8 −0
Original line number Diff line number Diff line
@@ -18,3 +18,11 @@ flag {
         purpose: PURPOSE_BUGFIX
     }
}

flag {
    name: "stop_voice_command"
    is_exported: true
    namespace: "bluetooth"
    description: "Feature flag to stop voice assistant session"
    bug: "419049796"
}
+3 −0
Original line number Diff line number Diff line
@@ -855,6 +855,9 @@
    <protected-broadcast android:name="android.service.ondeviceintelligence.MODEL_UNLOADED" />
    <protected-broadcast android:name="android.telephony.satellite.action.SATELLITE_START_NON_EMERGENCY_SESSION" />

    <!-- Added in 25Q4 -->
    <protected-broadcast android:name="android.intent.action.STOP_VOICE_COMMAND" />


    <!-- ====================================================================== -->
    <!--                          RUNTIME PERMISSIONS                           -->