summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jean-Michel Trivi <jmtrivi@google.com> 2019-03-05 14:55:37 -0800
committer Jean-Michel Trivi <jmtrivi@google.com> 2019-03-07 08:35:44 -0800
commit3fbbf6eb3cdfb045abdce63c0f3562d4a0368fd9 (patch)
tree56df077a149f64edec0dfc2bd73c9c4cea38dd25
parent639033929014c1154b443306728f30437060293b (diff)
Audio service: restrict conditions to send ACTION_AUDIO_BECOMING_NOISY
Do not send ACTION_AUDIO_BECOMING_NOISY if: - DEVICE_OUT_REMOTE_SUBMIX is in the selected devices for media streams - there is no media playback at the time Bug: 112203196 Test: see repro steps in bug Change-Id: I9cc8347837de2eb3c9949f81c11bdfb352512804
-rw-r--r--services/core/java/com/android/server/audio/AudioDeviceInventory.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 37f0496c0db3..b77a36107b9c 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -854,11 +854,20 @@ public final class AudioDeviceInventory {
if (musicDevice == AudioSystem.DEVICE_NONE) {
musicDevice = mDeviceBroker.getDeviceForStream(AudioSystem.STREAM_MUSIC);
}
- // ignore condition on device being actually used for music when in communication
+
+ // always ignore condition on device being actually used for music when in communication
// because music routing is altered in this case.
- // also checks whether media routing if affected by a dynamic policy
+ // also checks whether media routing if affected by a dynamic policy or mirroring
if (((device == musicDevice) || mDeviceBroker.isInCommunication())
- && (device == devices) && !mDeviceBroker.hasMediaDynamicPolicy()) {
+ && (device == devices) && !mDeviceBroker.hasMediaDynamicPolicy()
+ && ((musicDevice & AudioSystem.DEVICE_OUT_REMOTE_SUBMIX) == 0)) {
+ if (!AudioSystem.isStreamActive(AudioSystem.STREAM_MUSIC, 0 /*not looking in past*/)) {
+ // no media playback, not a "becoming noisy" situation, otherwise it could cause
+ // the pausing of some apps that are playing remotely
+ AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
+ "dropping ACTION_AUDIO_BECOMING_NOISY, no media playback")).printLog(TAG));
+ return 0;
+ }
mDeviceBroker.postBroadcastBecomingNoisy();
delay = 1000;
}