Loading media/java/android/media/AudioManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -87,10 +87,11 @@ public class AudioManager { /** * @hide Broadcast intent when the volume for a particular stream type changes. * Includes the stream and the new volume * Includes the stream, the new volume and previous volumes * * @see #EXTRA_VOLUME_STREAM_TYPE * @see #EXTRA_VOLUME_STREAM_VALUE * @see #EXTRA_PREV_VOLUME_STREAM_VALUE */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION"; Loading Loading @@ -126,6 +127,12 @@ public class AudioManager { public static final String EXTRA_VOLUME_STREAM_VALUE = "android.media.EXTRA_VOLUME_STREAM_VALUE"; /** * @hide The previous volume associated with the stream for the volume changed intent. */ public static final String EXTRA_PREV_VOLUME_STREAM_VALUE = "android.media.EXTRA_PREV_VOLUME_STREAM_VALUE"; /** The audio stream for phone calls */ public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL; /** The audio stream for system sounds */ Loading media/java/android/media/AudioService.java +12 −8 Original line number Diff line number Diff line Loading @@ -403,31 +403,35 @@ public class AudioService extends IAudioService.Stub { // UI mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent sendVolumeUpdate(streamType); sendVolumeUpdate(streamType, oldIndex, streamState.mIndex); } /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { ensureValidStreamType(streamType); final int oldIndex = mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex; index = rescaleIndex(index * 10, streamType, STREAM_VOLUME_ALIAS[streamType]); setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType], index, false, true); // UI, etc. mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent sendVolumeUpdate(streamType); sendVolumeUpdate(streamType, oldIndex, index); } private void sendVolumeUpdate(int streamType) { private void sendVolumeUpdate(int streamType, int oldIndex, int index) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, getStreamVolume(streamType)); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index); intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); // Currently, sending the intent only when the stream is BLUETOOTH_SCO if (streamType == AudioSystem.STREAM_BLUETOOTH_SCO) { mContext.sendBroadcast(intent); } } /** * Sets the stream state's index, and posts a message to set system volume. Loading Loading
media/java/android/media/AudioManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -87,10 +87,11 @@ public class AudioManager { /** * @hide Broadcast intent when the volume for a particular stream type changes. * Includes the stream and the new volume * Includes the stream, the new volume and previous volumes * * @see #EXTRA_VOLUME_STREAM_TYPE * @see #EXTRA_VOLUME_STREAM_VALUE * @see #EXTRA_PREV_VOLUME_STREAM_VALUE */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) public static final String VOLUME_CHANGED_ACTION = "android.media.VOLUME_CHANGED_ACTION"; Loading Loading @@ -126,6 +127,12 @@ public class AudioManager { public static final String EXTRA_VOLUME_STREAM_VALUE = "android.media.EXTRA_VOLUME_STREAM_VALUE"; /** * @hide The previous volume associated with the stream for the volume changed intent. */ public static final String EXTRA_PREV_VOLUME_STREAM_VALUE = "android.media.EXTRA_PREV_VOLUME_STREAM_VALUE"; /** The audio stream for phone calls */ public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL; /** The audio stream for system sounds */ Loading
media/java/android/media/AudioService.java +12 −8 Original line number Diff line number Diff line Loading @@ -403,31 +403,35 @@ public class AudioService extends IAudioService.Stub { // UI mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent sendVolumeUpdate(streamType); sendVolumeUpdate(streamType, oldIndex, streamState.mIndex); } /** @see AudioManager#setStreamVolume(int, int, int) */ public void setStreamVolume(int streamType, int index, int flags) { ensureValidStreamType(streamType); final int oldIndex = mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex; index = rescaleIndex(index * 10, streamType, STREAM_VOLUME_ALIAS[streamType]); setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType], index, false, true); // UI, etc. mVolumePanel.postVolumeChanged(streamType, flags); // Broadcast Intent sendVolumeUpdate(streamType); sendVolumeUpdate(streamType, oldIndex, index); } private void sendVolumeUpdate(int streamType) { private void sendVolumeUpdate(int streamType, int oldIndex, int index) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, getStreamVolume(streamType)); intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index); intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); // Currently, sending the intent only when the stream is BLUETOOTH_SCO if (streamType == AudioSystem.STREAM_BLUETOOTH_SCO) { mContext.sendBroadcast(intent); } } /** * Sets the stream state's index, and posts a message to set system volume. Loading