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 (Reat 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_DYNAMIC_ROUTING

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

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

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_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 or AUDIO_FEATURE_VOLUME_GROUP_MUTING Value is AUDIO_FEATURE_DYNAMIC_ROUTING, or AUDIO_FEATURE_VOLUME_GROUP_MUTING

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