@Implements(value=android.media.AudioManager.class) public class ShadowAudioManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ShadowAudioManager.AudioFocusRequest |
Modifier and Type | Field and Description |
---|---|
static int[] |
ALL_STREAMS |
static int |
DEFAULT_MAX_VOLUME |
static int |
DEFAULT_VOLUME |
static int |
FLAG_NO_ACTION |
static int |
INVALID_VOLUME |
static int |
MAX_VOLUME_MUSIC_DTMF |
Constructor and Description |
---|
ShadowAudioManager() |
Modifier and Type | Method and Description |
---|---|
protected int |
abandonAudioFocus(AudioManager.OnAudioFocusChangeListener l) |
protected int |
abandonAudioFocusRequest(AudioFocusRequest audioFocusRequest)
Provides a mock like interface for the abandonAudioFocusRequest method by storing the request object for later inspection and returning the value specified in setNextFocusRequestResponse.
|
protected void |
adjustStreamVolume(int streamType,
int direction,
int flags)
Implements
AudioManager.adjustStreamVolume(int, int, int) . |
protected List<AudioPlaybackConfiguration> |
getActivePlaybackConfigurations() |
AudioManager.OnAudioFocusChangeListener |
getLastAbandonedAudioFocusListener() |
AudioFocusRequest |
getLastAbandonedAudioFocusRequest() |
ShadowAudioManager.AudioFocusRequest |
getLastAudioFocusRequest() |
protected int |
getMode() |
String |
getParameter(String key)
Returns a single parameter that was set via
setParameters(String) . |
protected String |
getParameters(String keys)
The expected composition for keys is not well defined.
|
protected int |
getRingerMode() |
protected int |
getStreamMaxVolume(int streamType) |
protected int |
getStreamVolume(int streamType) |
protected boolean |
isBluetoothA2dpOn() |
protected boolean |
isBluetoothScoOn() |
protected boolean |
isMicrophoneMute() |
protected boolean |
isMusicActive() |
protected boolean |
isSpeakerphoneOn() |
protected boolean |
isStreamMute(int streamType) |
static boolean |
isValidRingerMode(int ringerMode) |
protected boolean |
isWiredHeadsetOn() |
protected int |
requestAudioFocus(AudioFocusRequest audioFocusRequest)
Provides a mock like interface for the requestAudioFocus method by storing the request object for later inspection and returning the value specified in setNextFocusRequestResponse.
|
protected int |
requestAudioFocus(AudioManager.OnAudioFocusChangeListener l,
int streamType,
int durationHint) |
void |
setActivePlaybackConfigurationsFor(List<AudioAttributes> audioAttributes)
Sets active playback configurations that will be served by
AudioManager.getActivePlaybackConfigurations() . |
protected void |
setBluetoothA2dpOn(boolean on) |
protected void |
setBluetoothScoOn(boolean isBluetoothScoOn) |
void |
setIsMusicActive(boolean isMusicActive) |
void |
setIsStreamMute(int streamType,
boolean isMuted) |
protected void |
setMicrophoneMute(boolean on) |
protected void |
setMode(int mode) |
void |
setNextFocusRequestResponse(int nextResponseValue) |
protected void |
setParameters(String keyValuePairs) |
protected void |
setRingerMode(int ringerMode) |
protected void |
setSpeakerphoneOn(boolean on) |
void |
setStreamMaxVolume(int streamMaxVolume) |
void |
setStreamVolume(int streamVolume) |
protected void |
setStreamVolume(int streamType,
int index,
int flags) |
protected void |
setWiredHeadsetOn(boolean on) |
public static final int MAX_VOLUME_MUSIC_DTMF
public static final int DEFAULT_MAX_VOLUME
public static final int DEFAULT_VOLUME
public static final int INVALID_VOLUME
public static final int FLAG_NO_ACTION
public static final int[] ALL_STREAMS
@Implementation protected int getStreamMaxVolume(int streamType)
@Implementation protected int getStreamVolume(int streamType)
@Implementation protected void setStreamVolume(int streamType, int index, int flags)
@Implementation protected int requestAudioFocus(AudioManager.OnAudioFocusChangeListener l, int streamType, int durationHint)
@Implementation(minSdk=26) protected int requestAudioFocus(AudioFocusRequest audioFocusRequest)
Provides a mock like interface for the requestAudioFocus method by storing the request object for later inspection and returning the value specified in setNextFocusRequestResponse.
@Implementation protected int abandonAudioFocus(AudioManager.OnAudioFocusChangeListener l)
@Implementation(minSdk=26) protected int abandonAudioFocusRequest(AudioFocusRequest audioFocusRequest)
Provides a mock like interface for the abandonAudioFocusRequest method by storing the request object for later inspection and returning the value specified in setNextFocusRequestResponse.
@Implementation protected int getRingerMode()
@Implementation protected void setRingerMode(int ringerMode)
public static boolean isValidRingerMode(int ringerMode)
@Implementation protected void setMode(int mode)
@Implementation protected int getMode()
public void setStreamMaxVolume(int streamMaxVolume)
public void setStreamVolume(int streamVolume)
@Implementation protected void setWiredHeadsetOn(boolean on)
@Implementation protected boolean isWiredHeadsetOn()
@Implementation protected void setBluetoothA2dpOn(boolean on)
@Implementation protected boolean isBluetoothA2dpOn()
@Implementation protected void setSpeakerphoneOn(boolean on)
@Implementation protected boolean isSpeakerphoneOn()
@Implementation protected void setMicrophoneMute(boolean on)
@Implementation protected boolean isMicrophoneMute()
@Implementation protected boolean isBluetoothScoOn()
@Implementation protected void setBluetoothScoOn(boolean isBluetoothScoOn)
@Implementation protected boolean isMusicActive()
@Implementation(minSdk=26) protected List<AudioPlaybackConfiguration> getActivePlaybackConfigurations()
@Implementation protected void setParameters(String keyValuePairs)
@Implementation protected String getParameters(String keys)
The expected composition for keys is not well defined.
For testing purposes this method call always returns null.
public String getParameter(String key)
Returns a single parameter that was set via setParameters(String)
.
@Implementation protected void adjustStreamVolume(int streamType, int direction, int flags)
Implements AudioManager.adjustStreamVolume(int, int, int)
.
Currently supports only the directions AudioManager.ADJUST_MUTE
and AudioManager.ADJUST_UNMUTE
.
@Implementation(minSdk=23) protected boolean isStreamMute(int streamType)
public void setIsStreamMute(int streamType, boolean isMuted)
public void setActivePlaybackConfigurationsFor(List<AudioAttributes> audioAttributes)
Sets active playback configurations that will be served by AudioManager.getActivePlaybackConfigurations()
.
Note that there is no public AudioPlaybackConfiguration
constructor, so the configurations returned are specified by their audio attributes only.
public void setIsMusicActive(boolean isMusicActive)
public ShadowAudioManager.AudioFocusRequest getLastAudioFocusRequest()
public void setNextFocusRequestResponse(int nextResponseValue)
public AudioManager.OnAudioFocusChangeListener getLastAbandonedAudioFocusListener()
public AudioFocusRequest getLastAbandonedAudioFocusRequest()