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

Commit 3d8b4a45 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Address the concurrency of accessibility and ringtone

Use ringtone level -4dB for accessibility when an accessibility
  prompt is played while the ringtone is playing, and the
  accessibility level is lower than the ringtone level.

Bug 30754235

Change-Id: I5f044c3bddabca45528292846a378be13d73ff6c
parent 41f2c47c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -4939,6 +4939,18 @@ float AudioPolicyManager::computeVolume(audio_stream_type_t stream,
                                        audio_devices_t device)
{
    float volumeDB = mVolumeCurves->volIndexToDb(stream, Volume::getDeviceCategory(device), index);

    // handle the case of accessibility active while a ringtone is playing: if the ringtone is much
    // louder than the accessibility prompt, the prompt cannot be heard, thus masking the touch
    // exploration of the dialer UI. In this situation, bring the accessibility volume closer to
    // the ringtone volume
    if ((stream == AUDIO_STREAM_ACCESSIBILITY)
            && (AUDIO_MODE_RINGTONE == mEngine->getPhoneState())
            && isStreamActive(AUDIO_STREAM_RING, 0)) {
        const float ringVolumeDB = computeVolume(AUDIO_STREAM_RING, index, device);
        return ringVolumeDB - 4 > volumeDB ? ringVolumeDB - 4 : volumeDB;
    }

    // if a headset is connected, apply the following rules to ring tones and notifications
    // to avoid sound level bursts in user's ears:
    // - always attenuate notifications volume by 6dB