@@ -103,6 +103,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
103103 private boolean mShowCombinedVolumes ;
104104 private boolean mVoiceCapable ;
105105
106+ // True if we want to play tones on the system stream when the master stream is specified.
107+ private final boolean mPlayMasterStreamTones ;
108+
106109 /** Dialog containing all the sliders */
107110 private final Dialog mDialog ;
108111 /** Dialog's content view */
@@ -275,6 +278,13 @@ public void onDismiss(DialogInterface dialog) {
275278 mMoreButton .setOnClickListener (this );
276279 }
277280
281+ boolean masterVolumeOnly = context .getResources ().getBoolean (
282+ com .android .internal .R .bool .config_useMasterVolume );
283+ boolean masterVolumeKeySounds = mContext .getResources ().getBoolean (
284+ com .android .internal .R .bool .config_useVolumeKeySounds );
285+
286+ mPlayMasterStreamTones = masterVolumeOnly && masterVolumeKeySounds ;
287+
278288 listenToRingerMode ();
279289 }
280290
@@ -657,7 +667,16 @@ protected void onVibrate() {
657667 * Lock on this VolumePanel instance as long as you use the returned ToneGenerator.
658668 */
659669 private ToneGenerator getOrCreateToneGenerator (int streamType ) {
660- if (streamType == STREAM_MASTER ) return null ;
670+ if (streamType == STREAM_MASTER ) {
671+ // For devices that use the master volume setting only but still want to
672+ // play a volume-changed tone, direct the master volume pseudostream to
673+ // the system stream's tone generator.
674+ if (mPlayMasterStreamTones ) {
675+ streamType = AudioManager .STREAM_SYSTEM ;
676+ } else {
677+ return null ;
678+ }
679+ }
661680 synchronized (this ) {
662681 if (mToneGenerators [streamType ] == null ) {
663682 try {
0 commit comments