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

Commit a9a52581 authored by Eric Laurent's avatar Eric Laurent
Browse files

PhoneWindowManager: allow volume keys in VoIP calls and screen off

Apply the same rule for volume keys during VoIP calls as during
PSTN calls allowing to change call volume when when the screen
is off.

Bug: 37571875
Test: Check volume keys work in Hangouts. Check regressions for music
and PSTN call volume

Change-Id: I2d5c654af47ade99ff4cb326e54e734087f5e8ae
parent ed285e0c
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -5960,15 +5960,23 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            result &= ~ACTION_PASS_TO_USER;
                            break;
                        }
                        if (telecomManager.isInCall()
                                && (result & ACTION_PASS_TO_USER) == 0) {
                    }
                    int audioMode = AudioManager.MODE_NORMAL;
                    try {
                        audioMode = getAudioService().getMode();
                    } catch (Exception e) {
                        Log.e(TAG, "Error getting AudioService in interceptKeyBeforeQueueing.", e);
                    }
                    boolean isInCall = (telecomManager != null && telecomManager.isInCall()) ||
                            audioMode == AudioManager.MODE_IN_COMMUNICATION;
                    if (isInCall && (result & ACTION_PASS_TO_USER) == 0) {
                        // If we are in call but we decided not to pass the key to
                        // the application, just pass it to the session service.
                        MediaSessionLegacyHelper.getHelper(mContext).sendVolumeKeyEvent(
                                event, AudioManager.USE_DEFAULT_STREAM_TYPE, false);
                        break;
                    }
                    }

                }
                if (mUseTvRouting || mHandleVolumeKeysInWM) {
                    // Defer special key handlings to
@@ -6313,7 +6321,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                try {
                    getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE,
                            AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG);
                } catch (RemoteException e) {
                } catch (Exception e) {
                    Log.e(TAG, "Error dispatching volume up in dispatchTvAudioEvent.", e);
                }
                break;
@@ -6321,7 +6329,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                try {
                    getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER,
                            AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG);
                } catch (RemoteException e) {
                } catch (Exception e) {
                    Log.e(TAG, "Error dispatching volume down in dispatchTvAudioEvent.", e);
                }
                break;
@@ -6332,7 +6340,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                AudioManager.ADJUST_TOGGLE_MUTE,
                                AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG);
                    }
                } catch (RemoteException e) {
                } catch (Exception e) {
                    Log.e(TAG, "Error dispatching mute in dispatchTvAudioEvent.", e);
                }
                break;