Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2e25764 authored by Bishoy Gendy's avatar Bishoy Gendy Committed by Android (Google) Code Review
Browse files

Merge "Fix volume controls show media instead of call volume during a call."

parents 00e664d2 ed9f9d1b
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -1942,9 +1942,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 {
@@ -1995,6 +1995,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(