Loading core/java/android/view/VolumePanel.java +5 −2 Original line number Diff line number Diff line Loading @@ -699,9 +699,12 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie if (sc.seekbarView.getMax() != max) { sc.seekbarView.setMax(max); } sc.seekbarView.setProgress(index); if (streamType != mAudioManager.getMasterStreamType() && streamType != AudioService.STREAM_REMOTE_MUSIC && isMuted(streamType)) { if (((flags & AudioManager.FLAG_FIXED_VOLUME) != 0) || (streamType != mAudioManager.getMasterStreamType() && streamType != AudioService.STREAM_REMOTE_MUSIC && isMuted(streamType))) { sc.seekbarView.setEnabled(false); } else { sc.seekbarView.setEnabled(true); Loading media/java/android/media/AudioManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,13 @@ public class AudioManager { */ public static final int FLAG_VIBRATE = 1 << 4; /** * Indicates to VolumePanel that the volume slider should be disabled as user * cannot change the stream volume * @hide */ public static final int FLAG_FIXED_VOLUME = 1 << 5; /** * Ringer mode that will be silent and will not vibrate. (This overrides the * vibrate setting.) Loading media/java/android/media/AudioService.java +113 −83 Original line number Diff line number Diff line Loading @@ -424,6 +424,11 @@ public class AudioService extends IAudioService.Stub implements OnFinished { */ public final static int STREAM_REMOTE_MUSIC = -200; // Devices for which the volume is fixed and VolumePanel slider should be disabled final int mFixedVolumeDevices = AudioSystem.DEVICE_OUT_AUX_DIGITAL | AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET | AudioSystem.DEVICE_OUT_ALL_USB; /////////////////////////////////////////////////////////////////////////// // Construction /////////////////////////////////////////////////////////////////////////// Loading Loading @@ -762,6 +767,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished { return; } int index; int oldIndex; if ((streamTypeAlias == AudioSystem.STREAM_MUSIC) && ((device & mFixedVolumeDevices) != 0)) { flags |= AudioManager.FLAG_FIXED_VOLUME; index = mStreamStates[streamType].getMaxIndex(); oldIndex = index; } else { // If either the client forces allowing ringer modes for this adjustment, // or the stream type is one that is affected by ringer modes if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) || Loading @@ -781,8 +795,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } // If stream is muted, adjust last audible index only int index; final int oldIndex = mStreamStates[streamType].getIndex(device, oldIndex = mStreamStates[streamType].getIndex(device, (mStreamStates[streamType].muteCount() != 0) /* lastAudible */); if (streamState.muteCount() != 0) { Loading Loading @@ -813,7 +826,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } index = mStreamStates[streamType].getIndex(device, false /* lastAudible */); } } sendVolumeUpdate(streamType, oldIndex, index, flags); } Loading @@ -839,9 +852,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished { VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[streamType]]; final int device = getDeviceForStream(streamType); int oldIndex; if ((mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) && ((device & mFixedVolumeDevices) != 0)) { flags |= AudioManager.FLAG_FIXED_VOLUME; index = mStreamStates[streamType].getMaxIndex(); oldIndex = index; } else { // get last audible index if stream is muted, current index otherwise final int oldIndex = streamState.getIndex(device, oldIndex = streamState.getIndex(device, (streamState.muteCount() != 0) /* lastAudible */); index = rescaleIndex(index * 10, streamType, mStreamVolumeAlias[streamType]); Loading Loading @@ -872,7 +892,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // get last audible index if stream is muted, current index otherwise index = mStreamStates[streamType].getIndex(device, (mStreamStates[streamType].muteCount() != 0) /* lastAudible */); } sendVolumeUpdate(streamType, oldIndex, index, flags); } Loading Loading @@ -988,6 +1008,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { mVolumePanel.postVolumeChanged(streamType, flags); if ((flags & AudioManager.FLAG_FIXED_VOLUME) == 0) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION); Loading @@ -996,6 +1017,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); sendBroadcastToAll(intent); } } // UI update and Broadcast Intent private void sendMasterVolumeUpdate(int flags, int oldVolume, int newVolume) { Loading Loading @@ -1109,7 +1131,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished { public int getStreamVolume(int streamType) { ensureValidStreamType(streamType); int device = getDeviceForStream(streamType); return (mStreamStates[streamType].getIndex(device, false /* lastAudible */) + 5) / 10; int index; if ((mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) && (device & mFixedVolumeDevices) != 0) { index = mStreamStates[streamType].getMaxIndex(); } else { index = mStreamStates[streamType].getIndex(device, false /* lastAudible */); } return (index + 5) / 10; } public int getMasterVolume() { Loading Loading
core/java/android/view/VolumePanel.java +5 −2 Original line number Diff line number Diff line Loading @@ -699,9 +699,12 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie if (sc.seekbarView.getMax() != max) { sc.seekbarView.setMax(max); } sc.seekbarView.setProgress(index); if (streamType != mAudioManager.getMasterStreamType() && streamType != AudioService.STREAM_REMOTE_MUSIC && isMuted(streamType)) { if (((flags & AudioManager.FLAG_FIXED_VOLUME) != 0) || (streamType != mAudioManager.getMasterStreamType() && streamType != AudioService.STREAM_REMOTE_MUSIC && isMuted(streamType))) { sc.seekbarView.setEnabled(false); } else { sc.seekbarView.setEnabled(true); Loading
media/java/android/media/AudioManager.java +7 −0 Original line number Diff line number Diff line Loading @@ -313,6 +313,13 @@ public class AudioManager { */ public static final int FLAG_VIBRATE = 1 << 4; /** * Indicates to VolumePanel that the volume slider should be disabled as user * cannot change the stream volume * @hide */ public static final int FLAG_FIXED_VOLUME = 1 << 5; /** * Ringer mode that will be silent and will not vibrate. (This overrides the * vibrate setting.) Loading
media/java/android/media/AudioService.java +113 −83 Original line number Diff line number Diff line Loading @@ -424,6 +424,11 @@ public class AudioService extends IAudioService.Stub implements OnFinished { */ public final static int STREAM_REMOTE_MUSIC = -200; // Devices for which the volume is fixed and VolumePanel slider should be disabled final int mFixedVolumeDevices = AudioSystem.DEVICE_OUT_AUX_DIGITAL | AudioSystem.DEVICE_OUT_DGTL_DOCK_HEADSET | AudioSystem.DEVICE_OUT_ALL_USB; /////////////////////////////////////////////////////////////////////////// // Construction /////////////////////////////////////////////////////////////////////////// Loading Loading @@ -762,6 +767,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished { return; } int index; int oldIndex; if ((streamTypeAlias == AudioSystem.STREAM_MUSIC) && ((device & mFixedVolumeDevices) != 0)) { flags |= AudioManager.FLAG_FIXED_VOLUME; index = mStreamStates[streamType].getMaxIndex(); oldIndex = index; } else { // If either the client forces allowing ringer modes for this adjustment, // or the stream type is one that is affected by ringer modes if (((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0) || Loading @@ -781,8 +795,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } // If stream is muted, adjust last audible index only int index; final int oldIndex = mStreamStates[streamType].getIndex(device, oldIndex = mStreamStates[streamType].getIndex(device, (mStreamStates[streamType].muteCount() != 0) /* lastAudible */); if (streamState.muteCount() != 0) { Loading Loading @@ -813,7 +826,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { } index = mStreamStates[streamType].getIndex(device, false /* lastAudible */); } } sendVolumeUpdate(streamType, oldIndex, index, flags); } Loading @@ -839,9 +852,16 @@ public class AudioService extends IAudioService.Stub implements OnFinished { VolumeStreamState streamState = mStreamStates[mStreamVolumeAlias[streamType]]; final int device = getDeviceForStream(streamType); int oldIndex; if ((mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) && ((device & mFixedVolumeDevices) != 0)) { flags |= AudioManager.FLAG_FIXED_VOLUME; index = mStreamStates[streamType].getMaxIndex(); oldIndex = index; } else { // get last audible index if stream is muted, current index otherwise final int oldIndex = streamState.getIndex(device, oldIndex = streamState.getIndex(device, (streamState.muteCount() != 0) /* lastAudible */); index = rescaleIndex(index * 10, streamType, mStreamVolumeAlias[streamType]); Loading Loading @@ -872,7 +892,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // get last audible index if stream is muted, current index otherwise index = mStreamStates[streamType].getIndex(device, (mStreamStates[streamType].muteCount() != 0) /* lastAudible */); } sendVolumeUpdate(streamType, oldIndex, index, flags); } Loading Loading @@ -988,6 +1008,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { mVolumePanel.postVolumeChanged(streamType, flags); if ((flags & AudioManager.FLAG_FIXED_VOLUME) == 0) { oldIndex = (oldIndex + 5) / 10; index = (index + 5) / 10; Intent intent = new Intent(AudioManager.VOLUME_CHANGED_ACTION); Loading @@ -996,6 +1017,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE, oldIndex); sendBroadcastToAll(intent); } } // UI update and Broadcast Intent private void sendMasterVolumeUpdate(int flags, int oldVolume, int newVolume) { Loading Loading @@ -1109,7 +1131,15 @@ public class AudioService extends IAudioService.Stub implements OnFinished { public int getStreamVolume(int streamType) { ensureValidStreamType(streamType); int device = getDeviceForStream(streamType); return (mStreamStates[streamType].getIndex(device, false /* lastAudible */) + 5) / 10; int index; if ((mStreamVolumeAlias[streamType] == AudioSystem.STREAM_MUSIC) && (device & mFixedVolumeDevices) != 0) { index = mStreamStates[streamType].getMaxIndex(); } else { index = mStreamStates[streamType].getIndex(device, false /* lastAudible */); } return (index + 5) / 10; } public int getMasterVolume() { Loading