Loading media/java/android/media/AudioManager.java +24 −2 Original line number Diff line number Diff line Loading @@ -421,7 +421,7 @@ public class AudioManager { flags); break; case KeyEvent.KEYCODE_VOLUME_MUTE: // TODO: Actually handle MUTE. toggleMute(stream); break; } } Loading Loading @@ -450,11 +450,33 @@ public class AudioManager { mVolumeKeyUpTime = SystemClock.uptimeMillis(); break; case KeyEvent.KEYCODE_VOLUME_MUTE: // TODO: Actually handle MUTE. break; } } /** * Toggles global mute state via ringer mode. * @param stream The stream for which the volume panel will be shown. * @hide */ public void toggleMute(int stream) { boolean vibrate = getVibrateSetting( AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON; int currentMode = getRingerMode(); if ((vibrate && currentMode == AudioManager.RINGER_MODE_VIBRATE) || (currentMode == AudioManager.RINGER_MODE_SILENT)) { setRingerMode(AudioManager.RINGER_MODE_NORMAL); } else { setRingerMode(vibrate ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT); } adjustSuggestedStreamVolume(ADJUST_SAME, stream, FLAG_SHOW_UI | FLAG_VIBRATE); } /** * Adjusts the volume of a particular stream by one step in a direction. * <p> Loading policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +10 −7 Original line number Diff line number Diff line Loading @@ -216,7 +216,9 @@ public abstract class KeyguardViewBase extends FrameLayout { } // Volume buttons should only function for music. if (mAudioManager.isMusicActive()) { // TODO: Actually handle MUTE. if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { mAudioManager.toggleMute(AudioManager.STREAM_MUSIC); } else { mAudioManager.adjustStreamVolume( AudioManager.STREAM_MUSIC, keyCode == KeyEvent.KEYCODE_VOLUME_UP Loading @@ -224,6 +226,7 @@ public abstract class KeyguardViewBase extends FrameLayout { : AudioManager.ADJUST_LOWER, 0); } } // Don't execute default volume behavior return true; } else { Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +18 −10 Original line number Diff line number Diff line Loading @@ -2735,16 +2735,24 @@ public class PhoneWindowManager implements WindowManagerPolicy { return; } try { if (keycode == KeyEvent.KEYCODE_VOLUME_MUTE) { final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); if (am == null) { Log.w(TAG, "handleVolumeKey: couldn't get AudioManager reference"); } else { am.toggleMute(stream); } } else { // since audio is playing, we shouldn't have to hold a wake lock // during the call, but we do it as a precaution for the rare possibility // that the music stops right before we call this // TODO: Actually handle MUTE. mBroadcastWakeLock.acquire(); audioService.adjustStreamVolume(stream, keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, 0); } } catch (RemoteException e) { Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e); } finally { Loading Loading
media/java/android/media/AudioManager.java +24 −2 Original line number Diff line number Diff line Loading @@ -421,7 +421,7 @@ public class AudioManager { flags); break; case KeyEvent.KEYCODE_VOLUME_MUTE: // TODO: Actually handle MUTE. toggleMute(stream); break; } } Loading Loading @@ -450,11 +450,33 @@ public class AudioManager { mVolumeKeyUpTime = SystemClock.uptimeMillis(); break; case KeyEvent.KEYCODE_VOLUME_MUTE: // TODO: Actually handle MUTE. break; } } /** * Toggles global mute state via ringer mode. * @param stream The stream for which the volume panel will be shown. * @hide */ public void toggleMute(int stream) { boolean vibrate = getVibrateSetting( AudioManager.VIBRATE_TYPE_RINGER) == AudioManager.VIBRATE_SETTING_ON; int currentMode = getRingerMode(); if ((vibrate && currentMode == AudioManager.RINGER_MODE_VIBRATE) || (currentMode == AudioManager.RINGER_MODE_SILENT)) { setRingerMode(AudioManager.RINGER_MODE_NORMAL); } else { setRingerMode(vibrate ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT); } adjustSuggestedStreamVolume(ADJUST_SAME, stream, FLAG_SHOW_UI | FLAG_VIBRATE); } /** * Adjusts the volume of a particular stream by one step in a direction. * <p> Loading
policy/src/com/android/internal/policy/impl/KeyguardViewBase.java +10 −7 Original line number Diff line number Diff line Loading @@ -216,7 +216,9 @@ public abstract class KeyguardViewBase extends FrameLayout { } // Volume buttons should only function for music. if (mAudioManager.isMusicActive()) { // TODO: Actually handle MUTE. if (keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { mAudioManager.toggleMute(AudioManager.STREAM_MUSIC); } else { mAudioManager.adjustStreamVolume( AudioManager.STREAM_MUSIC, keyCode == KeyEvent.KEYCODE_VOLUME_UP Loading @@ -224,6 +226,7 @@ public abstract class KeyguardViewBase extends FrameLayout { : AudioManager.ADJUST_LOWER, 0); } } // Don't execute default volume behavior return true; } else { Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +18 −10 Original line number Diff line number Diff line Loading @@ -2735,16 +2735,24 @@ public class PhoneWindowManager implements WindowManagerPolicy { return; } try { if (keycode == KeyEvent.KEYCODE_VOLUME_MUTE) { final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); if (am == null) { Log.w(TAG, "handleVolumeKey: couldn't get AudioManager reference"); } else { am.toggleMute(stream); } } else { // since audio is playing, we shouldn't have to hold a wake lock // during the call, but we do it as a precaution for the rare possibility // that the music stops right before we call this // TODO: Actually handle MUTE. mBroadcastWakeLock.acquire(); audioService.adjustStreamVolume(stream, keycode == KeyEvent.KEYCODE_VOLUME_UP ? AudioManager.ADJUST_RAISE : AudioManager.ADJUST_LOWER, 0); } } catch (RemoteException e) { Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e); } finally { Loading