Fix volume controls show media instead of call volume during a call.
- On some apps like Signal, When the app is in the foreground and there
is a active phone call, volume controls show media volume control
instead of call volume control.
- Investigation showed that with apps having the right behaviour
"MediaSession.dispatchVolumeKeyEvent" is called, while with apps having
the wrong behaviour
"MediaSessionService.dispatchVolumeKeyEventToSessionAsSystemService" is
called.
- Following this guided to the cause of the steps to reproduce it in
other apps by calling "Activty.setMediaController".
- Issue was reproducible on the Sample MediaRouter App.
- Fixed it through checking not being in a call before forwarding the
volume event to the session.
Bug: 240705522
Test: Manual using Signal App / Youtube and Sample MediaRouter App.
Change-Id: Iabac3c80631fd429daba23454488fceedbcc584d
(cherry picked from commit ed9f9d1b0a)
Merged-In: Iabac3c80631fd429daba23454488fceedbcc584d
This commit is contained in:
@@ -1950,9 +1950,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||||
case KeyEvent.KEYCODE_VOLUME_MUTE: {
|
case KeyEvent.KEYCODE_VOLUME_MUTE: {
|
||||||
// If we have a session send it the volume command, otherwise
|
// If we have a session and no active phone call send it the volume command,
|
||||||
// use the suggested stream.
|
// otherwise use the suggested stream.
|
||||||
if (mMediaController != null) {
|
if (mMediaController != null && !isActivePhoneCallKnown()) {
|
||||||
getMediaSessionManager().dispatchVolumeKeyEventToSessionAsSystemService(event,
|
getMediaSessionManager().dispatchVolumeKeyEventToSessionAsSystemService(event,
|
||||||
mMediaController.getSessionToken());
|
mMediaController.getSessionToken());
|
||||||
} else {
|
} else {
|
||||||
@@ -2003,6 +2003,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
|||||||
return false;
|
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() {
|
private KeyguardManager getKeyguardManager() {
|
||||||
if (mKeyguardManager == null) {
|
if (mKeyguardManager == null) {
|
||||||
mKeyguardManager = (KeyguardManager) getContext().getSystemService(
|
mKeyguardManager = (KeyguardManager) getContext().getSystemService(
|
||||||
|
|||||||
Reference in New Issue
Block a user