Class ShadowAudioManager


  • @Implements(value=android.media.AudioManager.class,
                looseSignatures=true)
    public class ShadowAudioManager
    extends java.lang.Object
    • Constructor Detail

      • ShadowAudioManager

        public ShadowAudioManager()
    • Method Detail

      • getStreamMaxVolume

        @Implementation
        protected int getStreamMaxVolume​(int streamType)
      • getStreamVolume

        @Implementation
        protected int getStreamVolume​(int streamType)
      • setStreamVolume

        @Implementation
        protected void setStreamVolume​(int streamType,
                                       int index,
                                       int flags)
      • isBluetoothScoAvailableOffCall

        @Implementation
        protected boolean isBluetoothScoAvailableOffCall()
      • requestAudioFocus

        @Implementation
        protected int requestAudioFocus​(android.media.AudioManager.OnAudioFocusChangeListener l,
                                        int streamType,
                                        int durationHint)
      • requestAudioFocus

        @Implementation(minSdk=26)
        protected int requestAudioFocus​(android.media.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.
      • abandonAudioFocus

        @Implementation
        protected int abandonAudioFocus​(android.media.AudioManager.OnAudioFocusChangeListener l)
      • abandonAudioFocusRequest

        @Implementation(minSdk=26)
        protected int abandonAudioFocusRequest​(android.media.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.
      • getRingerMode

        @Implementation
        protected int getRingerMode()
      • setRingerMode

        @Implementation
        protected void setRingerMode​(int ringerMode)
      • isValidRingerMode

        public static boolean isValidRingerMode​(int ringerMode)
      • setMode

        @Implementation
        protected void setMode​(int mode)
      • getMode

        @Implementation
        protected int getMode()
      • setStreamMaxVolume

        public void setStreamMaxVolume​(int streamMaxVolume)
      • setStreamVolume

        public void setStreamVolume​(int streamVolume)
      • setWiredHeadsetOn

        @Implementation
        protected void setWiredHeadsetOn​(boolean on)
      • isWiredHeadsetOn

        @Implementation
        protected boolean isWiredHeadsetOn()
      • setBluetoothA2dpOn

        @Implementation
        protected void setBluetoothA2dpOn​(boolean on)
      • isBluetoothA2dpOn

        @Implementation
        protected boolean isBluetoothA2dpOn()
      • setSpeakerphoneOn

        @Implementation
        protected void setSpeakerphoneOn​(boolean on)
      • isSpeakerphoneOn

        @Implementation
        protected boolean isSpeakerphoneOn()
      • setMicrophoneMute

        @Implementation
        protected void setMicrophoneMute​(boolean on)
      • isMicrophoneMute

        @Implementation
        protected boolean isMicrophoneMute()
      • isBluetoothScoOn

        @Implementation
        protected boolean isBluetoothScoOn()
      • setBluetoothScoOn

        @Implementation
        protected void setBluetoothScoOn​(boolean isBluetoothScoOn)
      • isMusicActive

        @Implementation
        protected boolean isMusicActive()
      • getActivePlaybackConfigurations

        @Implementation(minSdk=26)
        protected java.util.List<android.media.AudioPlaybackConfiguration> getActivePlaybackConfigurations()
      • setParameters

        @Implementation
        protected void setParameters​(java.lang.String keyValuePairs)
      • getParameters

        @Implementation
        protected java.lang.String getParameters​(java.lang.String keys)
        The expected composition for keys is not well defined.

        For testing purposes this method call always returns null.

      • getParameter

        public java.lang.String getParameter​(java.lang.String key)
        Returns a single parameter that was set via setParameters(String).
      • adjustStreamVolume

        @Implementation
        protected void adjustStreamVolume​(int streamType,
                                          int direction,
                                          int flags)
        Implements AudioManager.adjustStreamVolume(int, int, int).

        Currently supports only the directions AudioManager.ADJUST_MUTE, AudioManager.ADJUST_UNMUTE, AudioManager.ADJUST_LOWER and AudioManager.ADJUST_RAISE.

      • isStreamMute

        @Implementation(minSdk=23)
        protected boolean isStreamMute​(int streamType)
      • setIsBluetoothScoAvailableOffCall

        public void setIsBluetoothScoAvailableOffCall​(boolean isBluetoothScoAvailableOffCall)
      • setIsStreamMute

        public void setIsStreamMute​(int streamType,
                                    boolean isMuted)
      • unregisterAudioPlaybackCallback

        @Implementation(minSdk=26)
        protected void unregisterAudioPlaybackCallback​(android.media.AudioManager.AudioPlaybackCallback cb)
        Unregisters callback listening to changes made to list of active playback configurations.
      • setActivePlaybackConfigurationsFor

        public void setActivePlaybackConfigurationsFor​(java.util.List<android.media.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.

      • setActivePlaybackConfigurationsFor

        public void setActivePlaybackConfigurationsFor​(java.util.List<android.media.AudioAttributes> audioAttributes,
                                                       boolean notifyCallbackListeners)
        Same as setActivePlaybackConfigurationsFor(List), but also notifies callbacks if notifyCallbackListeners is true.
      • setIsMusicActive

        public void setIsMusicActive​(boolean isMusicActive)
      • setNextFocusRequestResponse

        public void setNextFocusRequestResponse​(int nextResponseValue)
      • getLastAbandonedAudioFocusListener

        public android.media.AudioManager.OnAudioFocusChangeListener getLastAbandonedAudioFocusListener()
      • getLastAbandonedAudioFocusRequest

        public android.media.AudioFocusRequest getLastAbandonedAudioFocusRequest()
      • unregisterAudioRecordingCallback

        @Implementation(minSdk=24)
        protected void unregisterAudioRecordingCallback​(android.media.AudioManager.AudioRecordingCallback cb)
        Unregisters callback listening to changes made to list of active recording configurations.
      • setActiveRecordingConfigurations

        public void setActiveRecordingConfigurations​(java.util.List<android.media.AudioRecordingConfiguration> activeRecordingConfigurations,
                                                     boolean notifyCallbackListeners)
        Sets active recording configurations that will be served by AudioManager.getActiveRecordingConfigurations() and notifies callback listeners about that change.
      • createActiveRecordingConfiguration

        public android.media.AudioRecordingConfiguration createActiveRecordingConfiguration​(int sessionId,
                                                                                            int audioSource,
                                                                                            java.lang.String clientPackageName)
        Creates simple active recording configuration. The resulting configuration will return null for AudioRecordingConfiguration.getAudioDevice().
      • registerAudioPolicy

        @HiddenApi
        @Implementation(minSdk=28)
        protected int registerAudioPolicy​(java.lang.Object audioPolicy)
        Registers an AudioPolicy to allow that policy to control audio routing and audio focus.

        Note: this implementation does NOT ensure that we have the permissions necessary to register the given AudioPolicy.

        Returns:
        AudioManager.ERROR if the given policy has already been registered, and AudioManager.SUCCESS otherwise.
      • unregisterAudioPolicy

        @HiddenApi
        @Implementation(minSdk=29)
        protected void unregisterAudioPolicy​(java.lang.Object audioPolicy)
      • isAnyAudioPolicyRegistered

        public boolean isAnyAudioPolicyRegistered()
        Returns true if at least one audio policy is registered with this manager, and false otherwise.
      • generateAudioSessionId

        @Implementation(minSdk=21)
        protected int generateAudioSessionId()
        Provides a mock like interface for the AudioManager.generateAudioSessionId() method by returning positive distinct values, or AudioManager.ERROR if all possible values have already been returned.