CarAudioManager

public final class CarAudioManager
extends Object

java.lang.Object
   ↳ android.car.media.CarAudioManager


APIs for handling audio in a car.

In a car environment, we introduced the support to turn audio dynamic routing on/off by setting the "audioUseDynamicRouting" attribute in config.xml

When audio dynamic routing is enabled:

  • Audio devices are grouped into zones
  • There is at least one primary zone, and extra secondary zones such as RSE (Rear Seat Entertainment)
  • Within each zone, audio devices are grouped into volume groups for volume control
  • Audio is assigned to an audio device based on its AudioAttributes usage
  • When audio dynamic routing is disabled:

  • There is exactly one audio zone, which is the primary zone
  • Each volume group represents a controllable STREAM_TYPE, same as AudioManager
  • Summary

    Nested classes

    class CarAudioManager.CarVolumeCallback

    Callback interface to receive volume change events in a car. 

    Constants

    int AUDIO_FEATURE_AUDIO_MIRRORING

    This is used to determine if audio mirroring is supported via isAudioFeatureEnabled(int)

    If enabled, audio mirroring can be managed by using the following APIs: setAudioZoneMirrorStatusCallback(Executor, AudioZonesMirrorStatusCallback), clearAudioZonesMirrorStatusCallback(), canEnableAudioMirror(), enableMirrorForAudioZones(List), extendAudioMirrorRequest(long, List), disableAudioMirrorForZone(int), disableAudioMirror(long), getMirrorAudioZonesForAudioZone(int), getMirrorAudioZonesForMirrorRequest(long)

    int AUDIO_FEATURE_DYNAMIC_ROUTING

    This is used to determine if dynamic routing is enabled via isAudioFeatureEnabled(int)

    int AUDIO_FEATURE_OEM_AUDIO_SERVICE

    This is used to determine if the OEM audio service is enabled via isAudioFeatureEnabled(int)

    If enabled, car audio focus, car audio volume, and ducking control behaviour can change as it can be OEM dependent.

    int AUDIO_FEATURE_VOLUME_GROUP_EVENTS

    This is used to determine if volume group events is supported via isAudioFeatureEnabled(int)

    If enabled, the car volume group event callback can be used to receive event changes to volume, mute, attenuation.

    int AUDIO_FEATURE_VOLUME_GROUP_MUTING

    This is used to determine if volume group muting is enabled via isAudioFeatureEnabled(int)

    If enabled, car volume group muting APIs can be used to mute each volume group, also car volume group muting changed callback will be called upon group mute changes.

    Public methods

    boolean isAudioFeatureEnabled(int audioFeature)

    Determines if an audio feature is enabled.

    void registerCarVolumeCallback(CarAudioManager.CarVolumeCallback callback)

    Registers a CarVolumeCallback to receive volume change callbacks

    void unregisterCarVolumeCallback(CarAudioManager.CarVolumeCallback callback)

    Unregisters a CarVolumeCallback from receiving volume change callbacks

    Inherited methods

    Constants

    AUDIO_FEATURE_AUDIO_MIRRORING

    Added in API level 34
    public static final int AUDIO_FEATURE_AUDIO_MIRRORING

    This is used to determine if audio mirroring is supported via isAudioFeatureEnabled(int)

    If enabled, audio mirroring can be managed by using the following APIs: setAudioZoneMirrorStatusCallback(Executor, AudioZonesMirrorStatusCallback), clearAudioZonesMirrorStatusCallback(), canEnableAudioMirror(), enableMirrorForAudioZones(List), extendAudioMirrorRequest(long, List), disableAudioMirrorForZone(int), disableAudioMirror(long), getMirrorAudioZonesForAudioZone(int), getMirrorAudioZonesForMirrorRequest(long)

    Constant Value: 5 (0x00000005)

    AUDIO_FEATURE_DYNAMIC_ROUTING

    Added in API level 31
    public static final int AUDIO_FEATURE_DYNAMIC_ROUTING

    This is used to determine if dynamic routing is enabled via isAudioFeatureEnabled(int)

    Constant Value: 1 (0x00000001)

    AUDIO_FEATURE_OEM_AUDIO_SERVICE

    Added in API level 34
    public static final int AUDIO_FEATURE_OEM_AUDIO_SERVICE

    This is used to determine if the OEM audio service is enabled via isAudioFeatureEnabled(int)

    If enabled, car audio focus, car audio volume, and ducking control behaviour can change as it can be OEM dependent.

    Constant Value: 3 (0x00000003)

    AUDIO_FEATURE_VOLUME_GROUP_EVENTS

    Added in API level 34
    public static final int AUDIO_FEATURE_VOLUME_GROUP_EVENTS

    This is used to determine if volume group events is supported via isAudioFeatureEnabled(int)

    If enabled, the car volume group event callback can be used to receive event changes to volume, mute, attenuation. If disabled, the register/unregister APIs will return false.

    Constant Value: 4 (0x00000004)

    AUDIO_FEATURE_VOLUME_GROUP_MUTING

    Added in API level 31
    public static final int AUDIO_FEATURE_VOLUME_GROUP_MUTING

    This is used to determine if volume group muting is enabled via isAudioFeatureEnabled(int)

    If enabled, car volume group muting APIs can be used to mute each volume group, also car volume group muting changed callback will be called upon group mute changes. If disabled, car volume will toggle master mute instead.

    Constant Value: 2 (0x00000002)

    Public methods

    isAudioFeatureEnabled

    Added in API level 31
    public boolean isAudioFeatureEnabled (int audioFeature)

    Determines if an audio feature is enabled.

    Parameters
    audioFeature int: audio feature to query, can be AUDIO_FEATURE_DYNAMIC_ROUTING, AUDIO_FEATURE_VOLUME_GROUP_MUTING or AUDIO_FEATURE_VOLUME_GROUP_EVENTS Value is AUDIO_FEATURE_DYNAMIC_ROUTING, AUDIO_FEATURE_VOLUME_GROUP_MUTING, AUDIO_FEATURE_OEM_AUDIO_SERVICE, AUDIO_FEATURE_VOLUME_GROUP_EVENTS, or AUDIO_FEATURE_AUDIO_MIRRORING

    Returns
    boolean Returns true if the feature is enabled, false otherwise.

    registerCarVolumeCallback

    Added in API level 29
    public void registerCarVolumeCallback (CarAudioManager.CarVolumeCallback callback)

    Registers a CarVolumeCallback to receive volume change callbacks

    Parameters
    callback CarAudioManager.CarVolumeCallback: CarVolumeCallback instance, can not be null

    Requires permission Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME

    unregisterCarVolumeCallback

    Added in API level 29
    public void unregisterCarVolumeCallback (CarAudioManager.CarVolumeCallback callback)

    Unregisters a CarVolumeCallback from receiving volume change callbacks

    Parameters
    callback CarAudioManager.CarVolumeCallback: CarVolumeCallback instance previously registered, can not be null

    Requires permission Car.PERMISSION_CAR_CONTROL_AUDIO_VOLUME