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

Commit 03fcdcd0 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio: fix talkback why alarm is playing

Convert attributes usage "assistance accessibility" to
a stream type guarantying that the prompt is audible
and not muted by policy manager.

Bug: 17994328.
Change-Id: I89f53f2ce84b499b859336c0a1a3a0332ee670f5
parent b1322c78
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2127,14 +2127,21 @@ void AudioTrack::setStreamTypeFromAttributes(audio_attributes_t& aa) {

    // usage to stream type mapping
    switch (aa.usage) {
    case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
    case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY: {
        // TODO once AudioPolicyManager fully supports audio_attributes_t,
        //   remove stream change based on phone state
        if (AudioSystem::getPhoneState() == AUDIO_MODE_RINGTONE) {
        //   remove stream change based on stream activity
        bool active;
        status_t status = AudioSystem::isStreamActive(AUDIO_STREAM_RING, &active, 0);
        if (status == NO_ERROR && active == true) {
            mStreamType = AUDIO_STREAM_RING;
            break;
        }
        /// FALL THROUGH
        status = AudioSystem::isStreamActive(AUDIO_STREAM_ALARM, &active, 0);
        if (status == NO_ERROR && active == true) {
            mStreamType = AUDIO_STREAM_ALARM;
            break;
        }
    }    /// FALL THROUGH
    case AUDIO_USAGE_MEDIA:
    case AUDIO_USAGE_GAME:
    case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE: