setAudioUsage

fun setAudioUsage(audioUsage: Int): Boolean

Set the audio usage value. This allows toggling between USAGE_MEDIA and USAGE_VOICE_COMMUNICATION. Updates the StateFlow immediately for responsive UI, then attempts to update the ADM. If the ADM update fails, the StateFlow is rolled back to the previous value.

Return

true if the update was successful, false otherwise

Parameters

audioUsage

The audio usage value to set (e.g., AudioAttributes.USAGE_MEDIA or AudioAttributes.USAGE_VOICE_COMMUNICATION)