Class ShadowAudioManager

    • Constructor Detail

      • ShadowAudioManager

        public ShadowAudioManager()
    • Method Detail

      • getStreamMaxVolume

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

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

        @Implementation(minSdk=28)
        protected float getStreamVolumeDb​(int streamType,
                                          int index,
                                          int deviceType)
      • setStreamVolume

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

        @Implementation
        protected boolean isBluetoothScoAvailableOffCall()
      • requestAudioFocus

        @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.
      • abandonAudioFocusRequest

        @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.
      • 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()
      • setParameters

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

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

        For testing purposes this method call always returns null.

      • 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​(AudioManager.AudioPlaybackCallback cb)
        Unregisters callback listening to changes made to list of active playback configurations.
      • setDevicesForAttributes

        public void setDevicesForAttributes​(AudioAttributes attributes,
                                            com.google.common.collect.ImmutableList<Object> devices)
        Sets the devices associated with the given audio stream.
      • setDefaultDevicesForAttributes

        public void setDefaultDevicesForAttributes​(com.google.common.collect.ImmutableList<Object> devices)
        Sets the devices to use as default for all audio streams.
      • setIsMusicActive

        public void setIsMusicActive​(boolean isMusicActive)
      • setNextFocusRequestResponse

        public void setNextFocusRequestResponse​(int nextResponseValue)
      • getLastAbandonedAudioFocusRequest

        public AudioFocusRequest getLastAbandonedAudioFocusRequest()
      • unregisterAudioRecordingCallback

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

        @HiddenApi
        @Implementation(minSdk=28)
        protected int registerAudioPolicy​(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​(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.