public class AudioService
extends IAudioService.Stub
This implementation focuses on delivering a responsive UI. Most methods are asynchronous to external calls. For example, the task of setting a volume will update our internal state, but in a separate thread will set the system volume and later persist to the database. Similarly, setting the ringer mode will update the state and broadcast a change and in a separate thread later persist the ringer mode.
Modifier and Type | Class and Description |
---|---|
class |
AudioService.AudioPolicyProxy
This internal class inherits from AudioPolicyConfig, each instance contains all the
mixes of an AudioPolicy and their configurations.
|
static class |
AudioService.Lifecycle |
static class |
AudioService.VolumeController |
class |
AudioService.VolumeStreamState |
Modifier and Type | Field and Description |
---|---|
static String |
CONNECT_INTENT_KEY_ADDRESS |
static String |
CONNECT_INTENT_KEY_DEVICE_CLASS |
static String |
CONNECT_INTENT_KEY_HAS_CAPTURE |
static String |
CONNECT_INTENT_KEY_HAS_MIDI |
static String |
CONNECT_INTENT_KEY_HAS_PLAYBACK |
static String |
CONNECT_INTENT_KEY_PORT_NAME |
static String |
CONNECT_INTENT_KEY_STATE |
protected static boolean |
DEBUG_AP
Debug audio policy feature
|
protected static boolean |
DEBUG_DEVICES
debug calls to devices APIs
|
protected static boolean |
DEBUG_MODE
Debug audio mode
|
protected static boolean |
DEBUG_VOL
Debug volumes
|
Constructor and Description |
---|
AudioService(Context context) |
Modifier and Type | Method and Description |
---|---|
int |
abandonAudioFocus(IAudioFocusDispatcher fd,
String clientId,
AudioAttributes aa) |
void |
adjustStreamVolume(int streamType,
int direction,
int flags,
String callingPackage) |
void |
adjustSuggestedStreamVolume(int direction,
int suggestedStreamType,
int flags,
String callingPackage,
String caller) |
void |
avrcpSupportsAbsoluteVolume(String address,
boolean support) |
void |
clearAllScoClients(int exceptPid,
boolean stopSco) |
void |
disableSafeMediaVolume(String callingPackage) |
protected void |
dump(FileDescriptor fd,
PrintWriter pw,
String[] args) |
void |
forceRemoteSubmixFullVolume(boolean startForcing,
IBinder cb) |
void |
forceVolumeControlStream(int streamType,
IBinder cb) |
List<AudioRecordingConfiguration> |
getActiveRecordingConfigurations() |
int |
getCurrentAudioFocus() |
int |
getLastAudibleStreamVolume(int streamType)
Get last audible volume before stream was muted.
|
int |
getMode() |
int |
getRingerModeExternal() |
int |
getRingerModeInternal() |
IRingtonePlayer |
getRingtonePlayer() |
int |
getStreamMaxVolume(int streamType) |
int |
getStreamMinVolume(int streamType) |
int |
getStreamVolume(int streamType) |
int |
getUiSoundsStreamType() |
int |
getVibrateSetting(int vibrateType) |
boolean |
isBluetoothA2dpOn() |
boolean |
isBluetoothScoOn() |
boolean |
isCameraSoundForced() |
boolean |
isHdmiSystemAudioSupported() |
boolean |
isMasterMute()
get master mute state.
|
boolean |
isSpeakerphoneOn() |
boolean |
isStreamAffectedByMute(int streamType) |
boolean |
isStreamAffectedByRingerMode(int streamType) |
boolean |
isStreamMute(int streamType)
get stream mute state.
|
boolean |
isValidRingerMode(int ringerMode) |
boolean |
loadSoundEffects()
Loads samples into the soundpool.
|
static String |
makeAlsaAddressString(int card,
int device) |
void |
notifyVolumeControllerVisible(IVolumeController controller,
boolean visible) |
void |
onAudioServerDied() |
void |
onSystemReady() |
void |
playSoundEffect(int effectType) |
void |
playSoundEffectVolume(int effectType,
float volume) |
String |
registerAudioPolicy(AudioPolicyConfig policyConfig,
IAudioPolicyCallback pcb,
boolean hasFocusListener) |
void |
registerRecordingCallback(IRecordingConfigDispatcher rcdb) |
void |
reloadAudioSettings() |
int |
requestAudioFocus(AudioAttributes aa,
int durationHint,
IBinder cb,
IAudioFocusDispatcher fd,
String clientId,
String callingPackageName,
int flags,
IAudioPolicyCallback pcb) |
int |
setBluetoothA2dpDeviceConnectionState(BluetoothDevice device,
int state,
int profile) |
void |
setBluetoothA2dpOn(boolean on) |
void |
setBluetoothA2dpOnInt(boolean on) |
void |
setBluetoothScoOn(boolean on) |
void |
setBluetoothScoOnInt(boolean on) |
int |
setFocusPropertiesForPolicy(int duckingBehavior,
IAudioPolicyCallback pcb) |
int |
setHdmiSystemAudioSupported(boolean on) |
void |
setMasterMute(boolean mute,
int flags,
String callingPackage,
int userId) |
void |
setMicrophoneMute(boolean on,
String callingPackage,
int userId) |
void |
setMode(int mode,
IBinder cb,
String callingPackage) |
void |
setRingerModeExternal(int ringerMode,
String caller) |
void |
setRingerModeInternal(int ringerMode,
String caller) |
void |
setRingtonePlayer(IRingtonePlayer player) |
void |
setSpeakerphoneOn(boolean on) |
void |
setStreamVolume(int streamType,
int index,
int flags,
String callingPackage) |
void |
setVibrateSetting(int vibrateType,
int vibrateSetting) |
void |
setVolumeController(IVolumeController controller) |
void |
setVolumePolicy(VolumePolicy policy) |
void |
setWiredDeviceConnectionState(int type,
int state,
String address,
String name,
String caller) |
boolean |
shouldVibrate(int vibrateType) |
void |
startBluetoothSco(IBinder cb,
int targetSdkVersion) |
void |
startBluetoothScoVirtualCall(IBinder cb) |
AudioRoutesInfo |
startWatchingRoutes(IAudioRoutesObserver observer) |
void |
stopBluetoothSco(IBinder cb) |
void |
systemReady() |
void |
unloadSoundEffects()
Unloads samples from the sound pool.
|
void |
unregisterAudioFocusClient(String clientId) |
void |
unregisterAudioPolicyAsync(IAudioPolicyCallback pcb) |
void |
unregisterRecordingCallback(IRecordingConfigDispatcher rcdb) |
protected static final boolean DEBUG_MODE
protected static final boolean DEBUG_AP
protected static final boolean DEBUG_VOL
protected static final boolean DEBUG_DEVICES
public static final String CONNECT_INTENT_KEY_PORT_NAME
public static final String CONNECT_INTENT_KEY_STATE
public static final String CONNECT_INTENT_KEY_ADDRESS
public static final String CONNECT_INTENT_KEY_HAS_PLAYBACK
public static final String CONNECT_INTENT_KEY_HAS_CAPTURE
public static final String CONNECT_INTENT_KEY_HAS_MIDI
public static final String CONNECT_INTENT_KEY_DEVICE_CLASS
public AudioService(Context context)
public static String makeAlsaAddressString(int card, int device)
public void systemReady()
public void onSystemReady()
public void onAudioServerDied()
public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, String callingPackage, String caller)
AudioManager.adjustVolume(int, int)
public void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage)
public void setStreamVolume(int streamType, int index, int flags, String callingPackage)
public void forceVolumeControlStream(int streamType, IBinder cb)
public boolean isStreamMute(int streamType)
public void forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb)
public boolean isMasterMute()
public void setMasterMute(boolean mute, int flags, String callingPackage, int userId)
public int getStreamVolume(int streamType)
AudioManager.getStreamVolume(int)
public int getStreamMaxVolume(int streamType)
AudioManager.getStreamMaxVolume(int)
public int getStreamMinVolume(int streamType)
AudioManager.getStreamMinVolume(int)
public int getLastAudibleStreamVolume(int streamType)
public int getUiSoundsStreamType()
AudioManager.getUiSoundsStreamType()
public void setMicrophoneMute(boolean on, String callingPackage, int userId)
AudioManager.setMicrophoneMute(boolean)
public int getRingerModeExternal()
public int getRingerModeInternal()
public boolean isValidRingerMode(int ringerMode)
AudioManager.isValidRingerMode(int)
public void setRingerModeExternal(int ringerMode, String caller)
public void setRingerModeInternal(int ringerMode, String caller)
public boolean shouldVibrate(int vibrateType)
AudioManager.shouldVibrate(int)
public int getVibrateSetting(int vibrateType)
AudioManager.getVibrateSetting(int)
public void setVibrateSetting(int vibrateType, int vibrateSetting)
AudioManager.setVibrateSetting(int, int)
public void setMode(int mode, IBinder cb, String callingPackage)
AudioManager.setMode(int)
public int getMode()
AudioManager.getMode()
public void playSoundEffect(int effectType)
AudioManager.playSoundEffect(int)
public void playSoundEffectVolume(int effectType, float volume)
AudioManager.playSoundEffect(int, float)
public boolean loadSoundEffects()
public void unloadSoundEffects()
public void reloadAudioSettings()
AudioManager.reloadAudioSettings()
public void setSpeakerphoneOn(boolean on)
AudioManager.setSpeakerphoneOn(boolean)
public boolean isSpeakerphoneOn()
AudioManager.isSpeakerphoneOn()
public void setBluetoothScoOn(boolean on)
AudioManager.setBluetoothScoOn(boolean)
public void setBluetoothScoOnInt(boolean on)
public boolean isBluetoothScoOn()
AudioManager.isBluetoothScoOn()
public void setBluetoothA2dpOn(boolean on)
AudioManager.setBluetoothA2dpOn(boolean)
public boolean isBluetoothA2dpOn()
AudioManager.isBluetoothA2dpOn()
public void startBluetoothSco(IBinder cb, int targetSdkVersion)
AudioManager.startBluetoothSco()
public void startBluetoothScoVirtualCall(IBinder cb)
public void stopBluetoothSco(IBinder cb)
AudioManager.stopBluetoothSco()
public void clearAllScoClients(int exceptPid, boolean stopSco)
public boolean isStreamAffectedByRingerMode(int streamType)
public boolean isStreamAffectedByMute(int streamType)
public void setWiredDeviceConnectionState(int type, int state, String address, String name, String caller)
public int setBluetoothA2dpDeviceConnectionState(BluetoothDevice device, int state, int profile)
public void avrcpSupportsAbsoluteVolume(String address, boolean support)
public int requestAudioFocus(AudioAttributes aa, int durationHint, IBinder cb, IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags, IAudioPolicyCallback pcb)
public int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, AudioAttributes aa)
public void unregisterAudioFocusClient(String clientId)
public int getCurrentAudioFocus()
public void setBluetoothA2dpOnInt(boolean on)
public void setRingtonePlayer(IRingtonePlayer player)
public IRingtonePlayer getRingtonePlayer()
public AudioRoutesInfo startWatchingRoutes(IAudioRoutesObserver observer)
public void disableSafeMediaVolume(String callingPackage)
public int setHdmiSystemAudioSupported(boolean on)
public boolean isHdmiSystemAudioSupported()
public boolean isCameraSoundForced()
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args)
public void setVolumeController(IVolumeController controller)
public void notifyVolumeControllerVisible(IVolumeController controller, boolean visible)
public void setVolumePolicy(VolumePolicy policy)
public String registerAudioPolicy(AudioPolicyConfig policyConfig, IAudioPolicyCallback pcb, boolean hasFocusListener)
public void unregisterAudioPolicyAsync(IAudioPolicyCallback pcb)
public int setFocusPropertiesForPolicy(int duckingBehavior, IAudioPolicyCallback pcb)
public void registerRecordingCallback(IRecordingConfigDispatcher rcdb)
public void unregisterRecordingCallback(IRecordingConfigDispatcher rcdb)
public List<AudioRecordingConfiguration> getActiveRecordingConfigurations()