am 8abc9e9b: Merge "Don\'t play a sound if a volume key press is canceled." into gingerbread

Merge commit '8abc9e9b9917760a63cc38a030e64f207aeef86d' into gingerbread-plus-aosp

* commit '8abc9e9b9917760a63cc38a030e64f207aeef86d':
  Don't play a sound if a volume key press is canceled.
This commit is contained in:
Jeff Brown
2010-09-12 18:13:47 -07:00
committed by Android Git Automerger

View File

@@ -1317,18 +1317,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN: {
AudioManager audioManager = (AudioManager) getContext().getSystemService(
Context.AUDIO_SERVICE);
if (audioManager != null) {
/*
* Play a sound. This is done on key up since we don't want the
* sound to play when a user holds down volume down to mute.
*/
audioManager.adjustSuggestedStreamVolume(
AudioManager.ADJUST_SAME,
mVolumeControlStreamType,
AudioManager.FLAG_PLAY_SOUND);
mVolumeKeyUpTime = SystemClock.uptimeMillis();
if (!event.isCanceled()) {
AudioManager audioManager = (AudioManager) getContext().getSystemService(
Context.AUDIO_SERVICE);
if (audioManager != null) {
/*
* Play a sound. This is done on key up since we don't want the
* sound to play when a user holds down volume down to mute.
*/
audioManager.adjustSuggestedStreamVolume(
AudioManager.ADJUST_SAME,
mVolumeControlStreamType,
AudioManager.FLAG_PLAY_SOUND);
mVolumeKeyUpTime = SystemClock.uptimeMillis();
}
}
return true;
}