Merge "Support volume-changed sounds on master-volume-only configs" into ics-aah

This commit is contained in:
Christopher Tate
2012-05-25 11:55:04 -07:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 6 deletions

View File

@@ -103,6 +103,9 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
private boolean mShowCombinedVolumes;
private boolean mVoiceCapable;
// True if we want to play tones on the system stream when the master stream is specified.
private final boolean mPlayMasterStreamTones;
/** Dialog containing all the sliders */
private final Dialog mDialog;
/** Dialog's content view */
@@ -275,6 +278,13 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
mMoreButton.setOnClickListener(this);
}
boolean masterVolumeOnly = context.getResources().getBoolean(
com.android.internal.R.bool.config_useMasterVolume);
boolean masterVolumeKeySounds = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_useVolumeKeySounds);
mPlayMasterStreamTones = masterVolumeOnly && masterVolumeKeySounds;
listenToRingerMode();
}
@@ -657,7 +667,16 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
* Lock on this VolumePanel instance as long as you use the returned ToneGenerator.
*/
private ToneGenerator getOrCreateToneGenerator(int streamType) {
if (streamType == STREAM_MASTER) return null;
if (streamType == STREAM_MASTER) {
// For devices that use the master volume setting only but still want to
// play a volume-changed tone, direct the master volume pseudostream to
// the system stream's tone generator.
if (mPlayMasterStreamTones) {
streamType = AudioManager.STREAM_SYSTEM;
} else {
return null;
}
}
synchronized (this) {
if (mToneGenerators[streamType] == null) {
try {

View File

@@ -460,8 +460,6 @@ public class AudioManager {
* responsive to the user.
*/
int flags = FLAG_SHOW_UI | FLAG_VIBRATE;
// if there is no volume key-up sound, apply the new volume immediately
if (!mUseVolumeKeySounds) flags |= FLAG_PLAY_SOUND;
if (mUseMasterVolume) {
adjustMasterVolume(
@@ -508,9 +506,7 @@ public class AudioManager {
*/
if (mUseVolumeKeySounds) {
if (mUseMasterVolume) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
adjustMasterVolume(ADJUST_SAME, FLAG_PLAY_SOUND);
}
adjustMasterVolume(ADJUST_SAME, FLAG_PLAY_SOUND);
} else {
int flags = FLAG_PLAY_SOUND;
if (mVolumeControlStream != -1) {