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: ERROR(/#setAudioZoneMirrorStatusCallback(java.util.concurrent.Executor,android.car.media.AudioZonesMirrorStatusCallback)), ERROR(/#clearAudioZonesMirrorStatusCallback()), ERROR(/#canEnableAudioMirror()), ERROR(/#enableMirrorForAudioZones(java.util.List)), ERROR(/#extendAudioMirrorRequest(long,java.util.List)), ERROR(/#disableAudioMirrorForZone(int)), ERROR(/#disableAudioMirror(long)), ERROR(/#getMirrorAudioZonesForAudioZone(int)), ERROR(/#getMirrorAudioZonesForMirrorRequest(long))

    int AUDIO_FEATURE_DYNAMIC_ROUTING

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

    int AUDIO_FEATURE_MIN_MAX_ACTIVATION_VOLUME

    This is used to determine if min/max activation volume level is supported via isAudioFeatureEnabled(int)

    If enabled, the volume of the volume group with min/max activation volume setting will be set to min activation volume or max activation volume if volume during activation is lower than min activation volume or higher than max activation volume respectively.

    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_DYNAMIC_ROUTING

    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_MIN_MAX_ACTIVATION_VOLUME

    public static final int AUDIO_FEATURE_MIN_MAX_ACTIVATION_VOLUME

    This is used to determine if min/max activation volume level is supported via isAudioFeatureEnabled(int)

    If enabled, the volume of the volume group with min/max activation volume setting will be set to min activation volume or max activation volume if volume during activation is lower than min activation volume or higher than max activation volume respectively.

    Constant Value: 6 (0x00000006)

    AUDIO_FEATURE_OEM_AUDIO_SERVICE

    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

    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

    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

    public boolean isAudioFeatureEnabled (int audioFeature)

    Determines if an audio feature is enabled.

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

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

    registerCarVolumeCallback

    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

    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