diff options
| -rw-r--r-- | api/current.txt | 6 | ||||
| -rw-r--r-- | api/system-current.txt | 6 | ||||
| -rw-r--r-- | api/test-current.txt | 6 | ||||
| -rw-r--r-- | core/java/android/app/Notification.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/AsyncPlayer.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/AudioTrack.java | 12 | ||||
| -rw-r--r-- | media/java/android/media/MediaPlayer.java | 12 | ||||
| -rw-r--r-- | media/java/android/media/PlayerBase.java | 24 | ||||
| -rw-r--r-- | media/java/android/media/Ringtone.java | 1 | ||||
| -rw-r--r-- | media/java/android/media/RingtoneManager.java | 4 | ||||
| -rw-r--r-- | media/java/android/media/SoundPool.java | 2 |
11 files changed, 60 insertions, 17 deletions
diff --git a/api/current.txt b/api/current.txt index 304ccf836d8a..bab071b549cd 100644 --- a/api/current.txt +++ b/api/current.txt @@ -20199,8 +20199,8 @@ package android.media { } public class AudioTrack implements android.media.AudioRouting { - ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; - ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException; method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler); method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler); @@ -21489,7 +21489,7 @@ package android.media { method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; method public void setAudioSessionId(int) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; - method public void setAudioStreamType(int); + method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; diff --git a/api/system-current.txt b/api/system-current.txt index d54e6a9bf05a..4a2f2d5966ca 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -21766,8 +21766,8 @@ package android.media { } public class AudioTrack implements android.media.AudioRouting { - ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; - ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException; method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler); method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler); @@ -23056,7 +23056,7 @@ package android.media { method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; method public void setAudioSessionId(int) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; - method public void setAudioStreamType(int); + method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; diff --git a/api/test-current.txt b/api/test-current.txt index f2694791cce9..b888911e25b8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -20286,8 +20286,8 @@ package android.media { } public class AudioTrack implements android.media.AudioRouting { - ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; - ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException; + ctor public deprecated AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException; ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException; method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler); method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler); @@ -21576,7 +21576,7 @@ package android.media { method public void selectTrack(int) throws java.lang.IllegalStateException; method public void setAudioAttributes(android.media.AudioAttributes) throws java.lang.IllegalArgumentException; method public void setAudioSessionId(int) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException; - method public void setAudioStreamType(int); + method public deprecated void setAudioStreamType(int); method public void setAuxEffectSendLevel(float); method public void setDataSource(android.content.Context, android.net.Uri) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; method public void setDataSource(android.content.Context, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>) throws java.io.IOException, java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.lang.SecurityException; diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 1fd082f4683e..c1e20726dff8 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -37,6 +37,7 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.Icon; import android.media.AudioAttributes; import android.media.AudioManager; +import android.media.PlayerBase; import android.media.session.MediaSession; import android.net.Uri; import android.os.BadParcelableException; @@ -2821,6 +2822,7 @@ public class Notification implements Parcelable */ @Deprecated public Builder setSound(Uri sound, int streamType) { + PlayerBase.deprecateStreamTypeForPlayback(streamType, "Notification", "setSound()"); mN.sound = sound; mN.audioStreamType = streamType; return this; diff --git a/media/java/android/media/AsyncPlayer.java b/media/java/android/media/AsyncPlayer.java index dd5f6bafd975..c1a178a2bf83 100644 --- a/media/java/android/media/AsyncPlayer.java +++ b/media/java/android/media/AsyncPlayer.java @@ -18,6 +18,7 @@ package android.media; import android.annotation.NonNull; import android.content.Context; +import android.media.PlayerBase; import android.net.Uri; import android.os.PowerManager; import android.os.SystemClock; @@ -163,6 +164,7 @@ public class AsyncPlayer { * @deprecated use {@link #play(Context, Uri, boolean, AudioAttributes)} instead */ public void play(Context context, Uri uri, boolean looping, int stream) { + PlayerBase.deprecateStreamTypeForPlayback(stream, "AsyncPlayer", "play()"); if (context == null || uri == null) { return; } diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 43fb4b9d87a2..16b331560d2a 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -359,6 +359,9 @@ public class AudioTrack extends PlayerBase * for an AudioTrack instance in streaming mode. * @param mode streaming or static buffer. See {@link #MODE_STATIC} and {@link #MODE_STREAM} * @throws java.lang.IllegalArgumentException + * @deprecated use {@link Builder} or + * {@link #AudioTrack(AudioAttributes, AudioFormat, int, int, int)} to specify the + * {@link AudioAttributes} instead of the stream type which is only for volume control. */ public AudioTrack(int streamType, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, int mode) @@ -414,6 +417,9 @@ public class AudioTrack extends PlayerBase * @param mode streaming or static buffer. See {@link #MODE_STATIC} and {@link #MODE_STREAM} * @param sessionId Id of audio session the AudioTrack must be attached to * @throws java.lang.IllegalArgumentException + * @deprecated use {@link Builder} or + * {@link #AudioTrack(AudioAttributes, AudioFormat, int, int, int)} to specify the + * {@link AudioAttributes} instead of the stream type which is only for volume control. */ public AudioTrack(int streamType, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, int mode, int sessionId) @@ -429,6 +435,7 @@ public class AudioTrack extends PlayerBase .build(), bufferSizeInBytes, mode, sessionId); + deprecateStreamTypeForPlayback(streamType, "AudioTrack", "AudioTrack()"); } /** @@ -1044,11 +1051,12 @@ public class AudioTrack extends PlayerBase } /** - * Returns the type of audio stream this AudioTrack is configured for. + * Returns the volume stream type of this AudioTrack. * Compare the result against {@link AudioManager#STREAM_VOICE_CALL}, * {@link AudioManager#STREAM_SYSTEM}, {@link AudioManager#STREAM_RING}, * {@link AudioManager#STREAM_MUSIC}, {@link AudioManager#STREAM_ALARM}, - * {@link AudioManager#STREAM_NOTIFICATION}, or {@link AudioManager#STREAM_DTMF}. + * {@link AudioManager#STREAM_NOTIFICATION}, {@link AudioManager#STREAM_DTMF} or + * {@link AudioManager#STREAM_ACCESSIBILITY}. */ public int getStreamType() { return mStreamType; diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index eff5aac0ad2d..78da59c35754 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -124,7 +124,7 @@ import java.lang.ref.WeakReference; * is called. It is a programming error to invoke methods such * as {@link #getCurrentPosition()}, * {@link #getDuration()}, {@link #getVideoHeight()}, - * {@link #getVideoWidth()}, {@link #setAudioStreamType(int)}, + * {@link #getVideoWidth()}, {@link #setAudioAttributes(AudioAttributes)}, * {@link #setLooping(boolean)}, * {@link #setVolume(float, float)}, {@link #pause()}, {@link #start()}, * {@link #stop()}, {@link #seekTo(int, int)}, {@link #prepare()} or @@ -410,7 +410,7 @@ import java.lang.ref.WeakReference; * Error} </p></td> * <td>This method must be called in idle state as the audio session ID must be known before * calling setDataSource. Calling it does not change the object state. </p></td></tr> - * <tr><td>setAudioStreamType </p></td> + * <tr><td>setAudioStreamType (deprecated)</p></td> * <td>{Idle, Initialized, Stopped, Prepared, Started, Paused, * PlaybackCompleted}</p></td> * <td>{Error}</p></td> @@ -822,7 +822,7 @@ public class MediaPlayer extends PlayerBase * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> * <p>Note that since {@link #prepare()} is called automatically in this method, - * you cannot change the audio stream type (see {@link #setAudioStreamType(int)}), audio + * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * (see {@link #setAudioAttributes(AudioAttributes)} of the new MediaPlayer.</p> * @@ -841,7 +841,7 @@ public class MediaPlayer extends PlayerBase * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> * <p>Note that since {@link #prepare()} is called automatically in this method, - * you cannot change the audio stream type (see {@link #setAudioStreamType(int)}), audio + * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * (see {@link #setAudioAttributes(AudioAttributes)} of the new MediaPlayer.</p> * @@ -904,7 +904,7 @@ public class MediaPlayer extends PlayerBase * to free the resources. If not released, too many MediaPlayer instances will * result in an exception.</p> * <p>Note that since {@link #prepare()} is called automatically in this method, - * you cannot change the audio stream type (see {@link #setAudioStreamType(int)}), audio + * you cannot change the audio * session ID (see {@link #setAudioSessionId(int)}) or audio attributes * (see {@link #setAudioAttributes(AudioAttributes)} of the new MediaPlayer.</p> * @@ -1843,9 +1843,11 @@ public class MediaPlayer extends PlayerBase * thereafter. * * @param streamtype the audio stream type + * @deprecated use {@link #setAudioAttributes(AudioAttributes)} * @see android.media.AudioManager */ public void setAudioStreamType(int streamtype) { + deprecateStreamTypeForPlayback(streamtype, "MediaPlayer", "setAudioStreamType()"); baseUpdateAudioAttributes( new AudioAttributes.Builder().setInternalLegacyStreamType(streamtype).build()); _setAudioStreamType(streamtype); diff --git a/media/java/android/media/PlayerBase.java b/media/java/android/media/PlayerBase.java index 690a553849e3..42f6b830126d 100644 --- a/media/java/android/media/PlayerBase.java +++ b/media/java/android/media/PlayerBase.java @@ -236,4 +236,28 @@ public abstract class PlayerBase { */ abstract void playerSetVolume(boolean muting, float leftVolume, float rightVolume); abstract int playerSetAuxEffectSendLevel(boolean muting, float level); + + //===================================================================== + // Utilities + + /** + * Use to generate warning or exception in legacy code paths that allowed passing stream types + * to qualify audio playback. + * @param streamType the stream type to check + * @throws IllegalArgumentException + */ + public static void deprecateStreamTypeForPlayback(int streamType, String className, + String opName) throws IllegalArgumentException { + // STREAM_ACCESSIBILITY was introduced at the same time the use of stream types + // for audio playback was deprecated, so it is not allowed at all to qualify a playback + // use case + if (streamType == AudioManager.STREAM_ACCESSIBILITY) { + throw new IllegalArgumentException("Use of STREAM_ACCESSIBILITY is reserved for " + + "volume control"); + } + Log.e(className, "Use of stream types is deprecated for operations other than " + + "volume control."); + Log.e(className, "See the documentation of " + opName + " for what to use instead with " + + "android.media.AudioAttributes to qualify your playback use case"); + } } diff --git a/media/java/android/media/Ringtone.java b/media/java/android/media/Ringtone.java index 77677124d8dc..209ec42dfb0b 100644 --- a/media/java/android/media/Ringtone.java +++ b/media/java/android/media/Ringtone.java @@ -103,6 +103,7 @@ public class Ringtone { */ @Deprecated public void setStreamType(int streamType) { + PlayerBase.deprecateStreamTypeForPlayback(streamType, "Ringtone", "setStreamType()"); setAudioAttributes(new AudioAttributes.Builder() .setInternalLegacyStreamType(streamType) .build()); diff --git a/media/java/android/media/RingtoneManager.java b/media/java/android/media/RingtoneManager.java index 3cb01de7513d..de9f0202a44c 100644 --- a/media/java/android/media/RingtoneManager.java +++ b/media/java/android/media/RingtoneManager.java @@ -297,7 +297,7 @@ public class RingtoneManager { } /** - * Infers the playback stream type based on what type of ringtones this + * Infers the volume stream type based on what type of ringtones this * manager is returning. * * @return The stream type. @@ -616,6 +616,7 @@ public class RingtoneManager { return getRingtone(context, ringtoneUri, -1); } + //FIXME bypass the notion of stream types within the class /** * Returns a {@link Ringtone} for a given sound URI on the given stream * type. Normally, if you change the stream type on the returned @@ -630,6 +631,7 @@ public class RingtoneManager { try { final Ringtone r = new Ringtone(context, true); if (streamType >= 0) { + //FIXME deprecated call r.setStreamType(streamType); } r.setUri(ringtoneUri); diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java index b429e22135be..838767ce137e 100644 --- a/media/java/android/media/SoundPool.java +++ b/media/java/android/media/SoundPool.java @@ -24,6 +24,7 @@ import android.app.ActivityThread; import android.app.AppOpsManager; import android.content.Context; import android.content.res.AssetFileDescriptor; +import android.media.PlayerBase; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -146,6 +147,7 @@ public class SoundPool extends PlayerBase { public SoundPool(int maxStreams, int streamType, int srcQuality) { this(maxStreams, new AudioAttributes.Builder().setInternalLegacyStreamType(streamType).build()); + PlayerBase.deprecateStreamTypeForPlayback(streamType, "SoundPool", "SoundPool()"); } private SoundPool(int maxStreams, AudioAttributes attributes) { |