diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index bb69192f187fe..7d3a2a397ad52 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -1950,9 +1950,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_MUTE: { - // If we have a session send it the volume command, otherwise - // use the suggested stream. - if (mMediaController != null) { + // If we have a session and no active phone call send it the volume command, + // otherwise use the suggested stream. + if (mMediaController != null && !isActivePhoneCallKnown()) { getMediaSessionManager().dispatchVolumeKeyEventToSessionAsSystemService(event, mMediaController.getSessionToken()); } else { @@ -2003,6 +2003,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { return false; } + private boolean isActivePhoneCallKnown() { + boolean isActivePhoneCallKnown = false; + AudioManager audioManager = + (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); + int audioManagerMode = audioManager.getMode(); + if (audioManagerMode == AudioManager.MODE_IN_CALL + || audioManagerMode == AudioManager.MODE_IN_COMMUNICATION) { + isActivePhoneCallKnown = true; + } + return isActivePhoneCallKnown; + } + private KeyguardManager getKeyguardManager() { if (mKeyguardManager == null) { mKeyguardManager = (KeyguardManager) getContext().getSystemService(