Android - VolumeProvider and mute callback

    Android's VolumeProvider has callbacks for volume changes. onSetVolumeTo is invoked when volume is set to a particular value and onAdjustVolume is invoked when the volume is just increased or decreased. However, there isn't any callback whatsoever when the volume is muted. Why would this be ignored? In fact, the VolumeProvider when used with MediaSession enables remote stream in framework's volume panel. It uses different drawable resources for enabled and mute state.

RemoteStream(STREAM_REMOTE_MUSIC
    R.string.volume_icon_description_media, //FIXME should have its own description
    R.drawable.ic_media_route_on_holo_dark,
    R.drawable.ic_media_route_disabled_holo_dark,
    false);// will be dynamically updated

Mute state is represented by the disabled cast icon.

   

   Yet, this resource isn't used even when the volume is reduced all the way to zero and the icon isn't even clickable. Why would the platform have a partial support and not expose an API to use the same? Turns out that, the mute support for remote stream is not supported on purpose as a TODO item.

private boolean isMuted(int streamType) {
    if (streamType == STREAM_MASTER) {
        return mAudioManager.isMasterMute();
    } else if (streamType == STREAM_REMOTE_MUSIC) {
        // TODO do we need to support a distinct mute property for remote?
        return false;
    } else {
        return mAudioManager.isStreamMute(streamType);
    }
}

No comments: