summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vlad Popa <pvlad@google.com> 2024-12-05 19:44:28 -0800
committer Vlad Popa <pvlad@google.com> 2024-12-06 10:16:42 -0800
commit3b87c1bba27a86313bfde91707fe1e4249918ac2 (patch)
treefba00f8c3208cf66e5c34398196b97be9042246e
parent48d2f0d373aca1643b06d9ba76489a3ef177e905 (diff)
Only allow STREAM_MUSIC as driving stream for AVRCP
The BT AVRCP service is storing the last volume of STREAM_MUSIC when something changes. This is inconsistent with the audio framework which now allows to have STREAM_VOICE_CALL drive the absolute volume too. As a quick fix, enforcing on the audio fwk side to be consistent with the AVRCP service and report only STREAM_MUSIC as the driving stream for AVRCP. Test: bug repro with active STREAM_VC when AVRCP active Bug: 379917442 Bug: 382366084 Flag: EXEMPT bugfix Change-Id: I4e87edfc938d34c341b0012736e1af2affaa2746
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 5928f8105cdf..09b8e212bfad 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -4684,6 +4684,12 @@ public class AudioService extends IAudioService.Stub
switch (mode) {
case AudioSystem.MODE_IN_COMMUNICATION:
case AudioSystem.MODE_IN_CALL:
+ // TODO(b/382704431): remove to allow STREAM_VOICE_CALL to drive abs volume
+ // over A2DP
+ if (getDeviceForStream(AudioSystem.STREAM_VOICE_CALL)
+ == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
+ return AudioSystem.STREAM_MUSIC;
+ }
return AudioSystem.STREAM_VOICE_CALL;
case AudioSystem.MODE_CALL_SCREENING:
case AudioSystem.MODE_COMMUNICATION_REDIRECT:
@@ -4695,15 +4701,20 @@ public class AudioService extends IAudioService.Stub
// other conditions will influence the stream type choice, read on...
break;
}
- if (voiceActivityCanOverride
- && mVoicePlaybackActive.get()) {
+
+ if (voiceActivityCanOverride && mVoicePlaybackActive.get()) {
+ // TODO(b/382704431): remove to allow STREAM_VOICE_CALL to drive abs volume over A2DP
+ if (getDeviceForStream(AudioSystem.STREAM_VOICE_CALL)
+ == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
+ return AudioSystem.STREAM_MUSIC;
+ }
return AudioSystem.STREAM_VOICE_CALL;
}
return AudioSystem.STREAM_MUSIC;
}
- private AtomicBoolean mVoicePlaybackActive = new AtomicBoolean(false);
- private AtomicBoolean mMediaPlaybackActive = new AtomicBoolean(false);
+ private final AtomicBoolean mVoicePlaybackActive = new AtomicBoolean(false);
+ private final AtomicBoolean mMediaPlaybackActive = new AtomicBoolean(false);
private final IPlaybackConfigDispatcher mPlaybackActivityMonitor =
new IPlaybackConfigDispatcher.Stub() {
@@ -4923,7 +4934,7 @@ public class AudioService extends IAudioService.Stub
private void onUpdateContextualVolumes() {
final int streamType = getBluetoothContextualVolumeStream();
- Log.i(TAG,
+ Slog.i(TAG,
"onUpdateContextualVolumes: absolute volume driving streams " + streamType
+ " avrcp supported: " + mAvrcpAbsVolSupported);
synchronized (mCachedAbsVolDrivingStreamsLock) {
@@ -4932,7 +4943,7 @@ public class AudioService extends IAudioService.Stub
if (absDev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
enabled = mAvrcpAbsVolSupported;
if (!enabled) {
- Log.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes");
+ Slog.w(TAG, "Updating avrcp not supported in onUpdateContextualVolumes");
}
}
if (stream != streamType) {
@@ -4960,7 +4971,7 @@ public class AudioService extends IAudioService.Stub
return;
}
if (absVolumeDevices.size() > 1) {
- Log.w(TAG, "onUpdateContextualVolumes too many active devices: "
+ Slog.w(TAG, "onUpdateContextualVolumes too many active devices: "
+ absVolumeDevices.stream().map(AudioSystem::getOutputDeviceName)
.collect(Collectors.joining(","))
+ ", for stream: " + streamType);
@@ -4971,7 +4982,7 @@ public class AudioService extends IAudioService.Stub
final int index = getStreamVolume(streamType, device);
if (DEBUG_VOL) {
- Log.i(TAG, "onUpdateContextualVolumes streamType: " + streamType
+ Slog.i(TAG, "onUpdateContextualVolumes streamType: " + streamType
+ ", device: " + AudioSystem.getOutputDeviceName(device)
+ ", index: " + index);
}