From bf5bb3d44fd07a4896f09042ede8bb8aad2486fe Mon Sep 17 00:00:00 2001 From: Vlad Popa Date: Mon, 28 Oct 2024 16:16:44 -0700 Subject: Initialize absolute volume state onReinitVolume APM could trigger a reinit volume command if the curves are not initialized properly. In this case it can happen since the AUDIO_STREAM_BLUETOOTH_SCO curves min/max are not initialized due to the missing STREAM_BT_SCO on the service side. Test: manual Flag: EXEMPT bugfix Bug: 362594705 Change-Id: I3e3936412842211d34ef72f2f2f0041fc8b9c213 --- .../com/android/server/audio/AudioService.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 353cfbe773dc..3dbe48a2e540 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -2070,22 +2070,6 @@ public class AudioService extends IAudioService.Stub onIndicateSystemReady(); - synchronized (mCachedAbsVolDrivingStreamsLock) { - mCachedAbsVolDrivingStreams.forEach((dev, stream) -> { - boolean enabled = true; - if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { - enabled = mAvrcpAbsVolSupported; - } - final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", - enabled, stream); - if (result != AudioSystem.AUDIO_STATUS_OK) { - sVolumeLogger.enqueueAndSlog( - new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, - result, dev, enabled, stream).eventToString(), ALOGE, TAG); - } - }); - } - // indicate the end of reconfiguration phase to audio HAL AudioSystem.setParameters("restarting=false"); @@ -2200,6 +2184,22 @@ public class AudioService extends IAudioService.Stub return; } + synchronized (mCachedAbsVolDrivingStreamsLock) { + mCachedAbsVolDrivingStreams.forEach((dev, stream) -> { + boolean enabled = true; + if (dev == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) { + enabled = mAvrcpAbsVolSupported; + } + final int result = mAudioSystem.setDeviceAbsoluteVolumeEnabled(dev, /*address=*/"", + enabled, stream); + if (result != AudioSystem.AUDIO_STATUS_OK) { + sVolumeLogger.enqueueAndSlog( + new VolumeEvent(VolumeEvent.VOL_ABS_DEVICE_ENABLED_ERROR, + result, dev, enabled, stream).eventToString(), ALOGE, TAG); + } + }); + } + // did it work? check based on min/max values of some basic streams if (!checkVolumeRangeInitialization(caller)) { return; -- cgit v1.2.3-59-g8ed1b