Merge "Support volume-changed sounds on master-volume-only configs" into ics-aah
This commit is contained in:
committed by
Android (Google) Code Review
commit
115284bc12
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user