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

Commit bf5bb3d4 authored by Vlad Popa's avatar Vlad Popa
Browse files

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
parent 296c5c2e
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -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;