Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4197cb60 authored by RoboErik's avatar RoboErik
Browse files

Move mute/unmute handling to adjust volume paths

This deprecates the setStreamMute and setStreamSolo APIs. Soloing is no
longer supported and muting is redirected through the adjust volume APIs.

Also updates the hidden master versions of these APIs.

Change-Id: I65d2a5d5fc15b386bd497abf8ca6869fec75a26a
parent 8bd95f16
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -14129,6 +14129,7 @@ package android.media {
    method public boolean isMicrophoneMute();
    method public boolean isMicrophoneMute();
    method public boolean isMusicActive();
    method public boolean isMusicActive();
    method public boolean isSpeakerphoneOn();
    method public boolean isSpeakerphoneOn();
    method public boolean isStreamMute(int);
    method public boolean isVolumeFixed();
    method public boolean isVolumeFixed();
    method public deprecated boolean isWiredHeadsetOn();
    method public deprecated boolean isWiredHeadsetOn();
    method public void loadSoundEffects();
    method public void loadSoundEffects();
@@ -14147,8 +14148,8 @@ package android.media {
    method public void setRingerMode(int);
    method public void setRingerMode(int);
    method public deprecated void setRouting(int, int, int);
    method public deprecated void setRouting(int, int, int);
    method public void setSpeakerphoneOn(boolean);
    method public void setSpeakerphoneOn(boolean);
    method public void setStreamMute(int, boolean);
    method public deprecated void setStreamMute(int, boolean);
    method public void setStreamSolo(int, boolean);
    method public deprecated void setStreamSolo(int, boolean);
    method public void setStreamVolume(int, int, int);
    method public void setStreamVolume(int, int, int);
    method public deprecated void setVibrateSetting(int, int);
    method public deprecated void setVibrateSetting(int, int);
    method public deprecated void setWiredHeadsetOn(boolean);
    method public deprecated void setWiredHeadsetOn(boolean);
@@ -14166,8 +14167,11 @@ package android.media {
    field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED";
    field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED";
    field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED";
    field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED";
    field public static final int ADJUST_LOWER = -1; // 0xffffffff
    field public static final int ADJUST_LOWER = -1; // 0xffffffff
    field public static final int ADJUST_MUTE = -100; // 0xffffff9c
    field public static final int ADJUST_RAISE = 1; // 0x1
    field public static final int ADJUST_RAISE = 1; // 0x1
    field public static final int ADJUST_SAME = 0; // 0x0
    field public static final int ADJUST_SAME = 0; // 0x0
    field public static final int ADJUST_TOGGLE_MUTE = 101; // 0x65
    field public static final int ADJUST_UNMUTE = 100; // 0x64
    field public static final int AUDIOFOCUS_GAIN = 1; // 0x1
    field public static final int AUDIOFOCUS_GAIN = 1; // 0x1
    field public static final int AUDIOFOCUS_GAIN_TRANSIENT = 2; // 0x2
    field public static final int AUDIOFOCUS_GAIN_TRANSIENT = 2; // 0x2
    field public static final int AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE = 4; // 0x4
    field public static final int AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE = 4; // 0x4
+6 −2
Original line number Original line Diff line number Diff line
@@ -15107,6 +15107,7 @@ package android.media {
    method public boolean isMicrophoneMute();
    method public boolean isMicrophoneMute();
    method public boolean isMusicActive();
    method public boolean isMusicActive();
    method public boolean isSpeakerphoneOn();
    method public boolean isSpeakerphoneOn();
    method public boolean isStreamMute(int);
    method public boolean isVolumeFixed();
    method public boolean isVolumeFixed();
    method public deprecated boolean isWiredHeadsetOn();
    method public deprecated boolean isWiredHeadsetOn();
    method public void loadSoundEffects();
    method public void loadSoundEffects();
@@ -15128,8 +15129,8 @@ package android.media {
    method public void setRingerMode(int);
    method public void setRingerMode(int);
    method public deprecated void setRouting(int, int, int);
    method public deprecated void setRouting(int, int, int);
    method public void setSpeakerphoneOn(boolean);
    method public void setSpeakerphoneOn(boolean);
    method public void setStreamMute(int, boolean);
    method public deprecated void setStreamMute(int, boolean);
    method public void setStreamSolo(int, boolean);
    method public deprecated void setStreamSolo(int, boolean);
    method public void setStreamVolume(int, int, int);
    method public void setStreamVolume(int, int, int);
    method public deprecated void setVibrateSetting(int, int);
    method public deprecated void setVibrateSetting(int, int);
    method public deprecated void setWiredHeadsetOn(boolean);
    method public deprecated void setWiredHeadsetOn(boolean);
@@ -15148,8 +15149,11 @@ package android.media {
    field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED";
    field public static final deprecated java.lang.String ACTION_SCO_AUDIO_STATE_CHANGED = "android.media.SCO_AUDIO_STATE_CHANGED";
    field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED";
    field public static final java.lang.String ACTION_SCO_AUDIO_STATE_UPDATED = "android.media.ACTION_SCO_AUDIO_STATE_UPDATED";
    field public static final int ADJUST_LOWER = -1; // 0xffffffff
    field public static final int ADJUST_LOWER = -1; // 0xffffffff
    field public static final int ADJUST_MUTE = -100; // 0xffffff9c
    field public static final int ADJUST_RAISE = 1; // 0x1
    field public static final int ADJUST_RAISE = 1; // 0x1
    field public static final int ADJUST_SAME = 0; // 0x0
    field public static final int ADJUST_SAME = 0; // 0x0
    field public static final int ADJUST_TOGGLE_MUTE = 101; // 0x65
    field public static final int ADJUST_UNMUTE = 100; // 0x64
    field public static final int AUDIOFOCUS_FLAG_DELAY_OK = 1; // 0x1
    field public static final int AUDIOFOCUS_FLAG_DELAY_OK = 1; // 0x1
    field public static final int AUDIOFOCUS_FLAG_LOCK = 4; // 0x4
    field public static final int AUDIOFOCUS_FLAG_LOCK = 4; // 0x4
    field public static final int AUDIOFOCUS_FLAG_PAUSES_ON_DUCKABLE_LOSS = 2; // 0x2
    field public static final int AUDIOFOCUS_FLAG_PAUSES_ON_DUCKABLE_LOSS = 2; // 0x2
+10 −2
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.ServiceConnection;
import android.media.AudioManager;
import android.os.IBinder;
import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.RemoteException;
@@ -415,9 +416,16 @@ public final class BluetoothA2dp implements BluetoothProfile {
    }
    }


    /**
    /**
     * Tells remote device to adjust volume. Only if absolute volume is supported.
     * Tells remote device to adjust volume. Only if absolute volume is
     * supported. Uses the following values:
     * <ul>
     * <li>{@link AudioManager#ADJUST_LOWER}</li>
     * <li>{@link AudioManager#ADJUST_RAISE}</li>
     * <li>{@link AudioManager#ADJUST_MUTE}</li>
     * <li>{@link AudioManager#ADJUST_UNMUTE}</li>
     * </ul>
     *
     *
     * @param direction 1 to increase volume, or -1 to decrease volume
     * @param direction One of the supported adjust values.
     * @hide
     * @hide
     */
     */
    public void adjustAvrcpAbsoluteVolume(int direction) {
    public void adjustAvrcpAbsoluteVolume(int direction) {
+88 −78
Original line number Original line Diff line number Diff line
@@ -346,6 +346,31 @@ public class AudioManager {
     */
     */
    public static final int ADJUST_SAME = 0;
    public static final int ADJUST_SAME = 0;


    /**
     * Mute the volume. Has no effect if the stream is already muted.
     *
     * @see #adjustVolume(int, int)
     * @see #adjustStreamVolume(int, int, int)
     */
    public static final int ADJUST_MUTE = -100;

    /**
     * Unmute the volume. Has no effect if the stream is not muted.
     *
     * @see #adjustVolume(int, int)
     * @see #adjustStreamVolume(int, int, int)
     */
    public static final int ADJUST_UNMUTE = 100;

    /**
     * Toggle the mute state. If muted the stream will be unmuted. If not muted
     * the stream will be muted.
     *
     * @see #adjustVolume(int, int)
     * @see #adjustStreamVolume(int, int, int)
     */
    public static final int ADJUST_TOGGLE_MUTE = 101;

    // Flags should be powers of 2!
    // Flags should be powers of 2!


    /**
    /**
@@ -777,13 +802,17 @@ public class AudioManager {
     * screen is showing. Another example, if music is playing in the background
     * screen is showing. Another example, if music is playing in the background
     * and a call is not active, the music stream will be adjusted.
     * and a call is not active, the music stream will be adjusted.
     * <p>
     * <p>
     * This method should only be used by applications that replace the platform-wide
     * This method should only be used by applications that replace the
     * management of audio settings or the main telephony application.
     * platform-wide management of audio settings or the main telephony
     * <p>This method has no effect if the device implements a fixed volume policy
     * application.
     * <p>
     * This method has no effect if the device implements a fixed volume policy
     * as indicated by {@link #isVolumeFixed()}.
     * as indicated by {@link #isVolumeFixed()}.
     *
     * @param direction The direction to adjust the volume. One of
     * @param direction The direction to adjust the volume. One of
     *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or
     *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE},
     *            {@link #ADJUST_SAME}.
     *            {@link #ADJUST_SAME}, {@link #ADJUST_MUTE},
     *            {@link #ADJUST_UNMUTE}, or {@link #ADJUST_TOGGLE_MUTE}.
     * @param flags One or more flags.
     * @param flags One or more flags.
     * @see #adjustSuggestedStreamVolume(int, int, int)
     * @see #adjustSuggestedStreamVolume(int, int, int)
     * @see #adjustStreamVolume(int, int, int)
     * @see #adjustStreamVolume(int, int, int)
@@ -808,16 +837,20 @@ public class AudioManager {
     * Adjusts the volume of the most relevant stream, or the given fallback
     * Adjusts the volume of the most relevant stream, or the given fallback
     * stream.
     * stream.
     * <p>
     * <p>
     * This method should only be used by applications that replace the platform-wide
     * This method should only be used by applications that replace the
     * management of audio settings or the main telephony application.
     * platform-wide management of audio settings or the main telephony
     *
     * application.
     * <p>This method has no effect if the device implements a fixed volume policy
     * <p>
     * This method has no effect if the device implements a fixed volume policy
     * as indicated by {@link #isVolumeFixed()}.
     * as indicated by {@link #isVolumeFixed()}.
     *
     * @param direction The direction to adjust the volume. One of
     * @param direction The direction to adjust the volume. One of
     *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE}, or
     *            {@link #ADJUST_LOWER}, {@link #ADJUST_RAISE},
     *            {@link #ADJUST_SAME}.
     *            {@link #ADJUST_SAME}, {@link #ADJUST_MUTE},
     *            {@link #ADJUST_UNMUTE}, or {@link #ADJUST_TOGGLE_MUTE}.
     * @param suggestedStreamType The stream type that will be used if there
     * @param suggestedStreamType The stream type that will be used if there
     *            isn't a relevant stream. {@link #USE_DEFAULT_STREAM_TYPE} is valid here.
     *            isn't a relevant stream. {@link #USE_DEFAULT_STREAM_TYPE} is
     *            valid here.
     * @param flags One or more flags.
     * @param flags One or more flags.
     * @see #adjustVolume(int, int)
     * @see #adjustVolume(int, int)
     * @see #adjustStreamVolume(int, int, int)
     * @see #adjustStreamVolume(int, int, int)
@@ -1088,72 +1121,72 @@ public class AudioManager {
    }
    }


    /**
    /**
     * Solo or unsolo a particular stream. All other streams are muted.
     * Solo or unsolo a particular stream.
     * <p>
     * The solo command is protected against client process death: if a process
     * with an active solo request on a stream dies, all streams that were muted
     * because of this request will be unmuted automatically.
     * <p>
     * The solo requests for a given stream are cumulative: the AudioManager
     * can receive several solo requests from one or more clients and the stream
     * will be unsoloed only when the same number of unsolo requests are received.
     * <p>
     * <p>
     * For a better user experience, applications MUST unsolo a soloed stream
     * Do not use. This method has been deprecated and is now a no-op.
     * in onPause() and solo is again in onResume() if appropriate.
     * {@link #requestAudioFocus} should be used for exclusive audio playback.
     * <p>This method has no effect if the device implements a fixed volume policy
     * as indicated by {@link #isVolumeFixed()}.
     *
     *
     * @param streamType The stream to be soloed/unsoloed.
     * @param streamType The stream to be soloed/unsoloed.
     * @param state The required solo state: true for solo ON, false for solo OFF
     * @param state The required solo state: true for solo ON, false for solo
     *
     *            OFF
     * @see #isVolumeFixed()
     * @see #isVolumeFixed()
     * @deprecated Do not use. If you need exclusive audio playback use
     *             {@link #requestAudioFocus}.
     */
     */
    @Deprecated
    public void setStreamSolo(int streamType, boolean state) {
    public void setStreamSolo(int streamType, boolean state) {
        IAudioService service = getService();
        Log.w(TAG, "setStreamSolo has been deprecated. Do not use.");
        try {
            service.setStreamSolo(streamType, state, mICallBack);
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in setStreamSolo", e);
        }
    }
    }


    /**
    /**
     * Mute or unmute an audio stream.
     * Mute or unmute an audio stream.
     * <p>
     * <p>
     * The mute command is protected against client process death: if a process
     * This method should only be used by applications that replace the
     * with an active mute request on a stream dies, this stream will be unmuted
     * platform-wide management of audio settings or the main telephony
     * automatically.
     * application.
     * <p>
     * The mute requests for a given stream are cumulative: the AudioManager
     * can receive several mute requests from one or more clients and the stream
     * will be unmuted only when the same number of unmute requests are received.
     * <p>
     * For a better user experience, applications MUST unmute a muted stream
     * in onPause() and mute is again in onResume() if appropriate.
     * <p>
     * <p>
     * This method should only be used by applications that replace the platform-wide
     * This method has no effect if the device implements a fixed volume policy
     * management of audio settings or the main telephony application.
     * <p>This method has no effect if the device implements a fixed volume policy
     * as indicated by {@link #isVolumeFixed()}.
     * as indicated by {@link #isVolumeFixed()}.
     * <p>
     * This method was deprecated in API level 22. Prior to API level 22 this
     * method had significantly different behavior and should be used carefully.
     * The following applies only to pre-22 platforms:
     * <ul>
     * <li>The mute command is protected against client process death: if a
     * process with an active mute request on a stream dies, this stream will be
     * unmuted automatically.</li>
     * <li>The mute requests for a given stream are cumulative: the AudioManager
     * can receive several mute requests from one or more clients and the stream
     * will be unmuted only when the same number of unmute requests are
     * received.</li>
     * <li>For a better user experience, applications MUST unmute a muted stream
     * in onPause() and mute is again in onResume() if appropriate.</li>
     * </ul>
     *
     *
     * @param streamType The stream to be muted/unmuted.
     * @param streamType The stream to be muted/unmuted.
     * @param state The required mute state: true for mute ON, false for mute OFF
     * @param state The required mute state: true for mute ON, false for mute
     *
     *            OFF
     * @see #isVolumeFixed()
     * @see #isVolumeFixed()
     * @deprecated Use {@link #adjustStreamVolume(int, int, int)} with
     *             {@link #ADJUST_MUTE} or {@link #ADJUST_UNMUTE} instead.
     */
     */
    @Deprecated
    public void setStreamMute(int streamType, boolean state) {
    public void setStreamMute(int streamType, boolean state) {
        IAudioService service = getService();
        Log.w(TAG, "setStreamMute is deprecated. adjustStreamVolume should be used instead.");
        try {
        int direction = state ? ADJUST_MUTE : ADJUST_UNMUTE;
            service.setStreamMute(streamType, state, mICallBack);
        if (streamType == AudioManager.USE_DEFAULT_STREAM_TYPE) {
        } catch (RemoteException e) {
            adjustSuggestedStreamVolume(direction, streamType, 0);
            Log.e(TAG, "Dead object in setStreamMute", e);
        } else {
            adjustStreamVolume(streamType, direction, 0);
        }
        }
    }
    }


    /**
    /**
     * get stream mute state.
     * Returns the current mute state for a particular stream.
     *
     *
     * @hide
     * @param streamType The stream to get mute state for.
     * @return The mute state for the given stream.
     * @see #adjustStreamVolume(int, int, int)
     */
     */
    public boolean isStreamMute(int streamType) {
    public boolean isStreamMute(int streamType) {
        IAudioService service = getService();
        IAudioService service = getService();
@@ -1165,29 +1198,6 @@ public class AudioManager {
        }
        }
    }
    }


    /**
     * set master mute state.
     *
     * @hide
     */
    public void setMasterMute(boolean state) {
        setMasterMute(state, FLAG_SHOW_UI);
    }

    /**
     * set master mute state with optional flags.
     *
     * @hide
     */
    public void setMasterMute(boolean state, int flags) {
        IAudioService service = getService();
        try {
            service.setMasterMute(state, flags, mContext.getOpPackageName(), mICallBack);
        } catch (RemoteException e) {
            Log.e(TAG, "Dead object in setMasterMute", e);
        }
    }

    /**
    /**
     * get master mute state.
     * get master mute state.
     *
     *
+0 −3
Original line number Original line Diff line number Diff line
@@ -41,9 +41,6 @@ public abstract class AudioManagerInternal {
    public abstract void adjustMasterVolumeForUid(int steps, int flags, String callingPackage,
    public abstract void adjustMasterVolumeForUid(int steps, int flags, String callingPackage,
            int uid);
            int uid);


    public abstract void setMasterMuteForUid(boolean state, int flags, String callingPackage,
            IBinder cb, int uid);

    public abstract void setRingerModeDelegate(RingerModeDelegate delegate);
    public abstract void setRingerModeDelegate(RingerModeDelegate delegate);


    public abstract int getRingerModeInternal();
    public abstract int getRingerModeInternal();
Loading