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

Commit d806bf89 authored by Bishoy Gendy's avatar Bishoy Gendy Committed by Automerger Merge Worker
Browse files

Fix volume controls show media instead of call volume during a call. am: 188ab327

parents afa1ef56 188ab327
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -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(