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

Commit 504de531 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio: fix stream type for accessibility usage" into lmp-dev

parents 5f5d0544 bb6c9a05
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -320,6 +320,8 @@ public:
                                           audio_devices_t *device);
    static status_t releaseSoundTriggerSession(audio_session_t session);

    static audio_mode_t getPhoneState();

    // ----------------------------------------------------------------------------

    class AudioPortCallback : public RefBase
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,8 @@ public:
                                           audio_devices_t *device) = 0;

    virtual status_t releaseSoundTriggerSession(audio_session_t session) = 0;

    virtual audio_mode_t getPhoneState() = 0;
};


+9 −0
Original line number Diff line number Diff line
@@ -939,6 +939,15 @@ status_t AudioSystem::releaseSoundTriggerSession(audio_session_t session)
    if (aps == 0) return PERMISSION_DENIED;
    return aps->releaseSoundTriggerSession(session);
}

audio_mode_t AudioSystem::getPhoneState()
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return AUDIO_MODE_INVALID;
    return aps->getPhoneState();
}


// ---------------------------------------------------------------------------

void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __unused)
+8 −1
Original line number Diff line number Diff line
@@ -2124,9 +2124,16 @@ void AudioTrack::setStreamTypeFromAttributes(audio_attributes_t& aa) {

    // usage to stream type mapping
    switch (aa.usage) {
    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) {
            mStreamType = AUDIO_STREAM_RING;
            break;
        }
        /// FALL THROUGH
    case AUDIO_USAGE_MEDIA:
    case AUDIO_USAGE_GAME:
    case AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY:
    case AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE:
        mStreamType = AUDIO_STREAM_MUSIC;
        return;
+19 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ enum {
    REGISTER_CLIENT,
    GET_OUTPUT_FOR_ATTR,
    ACQUIRE_SOUNDTRIGGER_SESSION,
    RELEASE_SOUNDTRIGGER_SESSION
    RELEASE_SOUNDTRIGGER_SESSION,
    GET_PHONE_STATE
};

class BpAudioPolicyService : public BpInterface<IAudioPolicyService>
@@ -607,6 +608,17 @@ public:
        }
        return (status_t)reply.readInt32();
    }

    virtual audio_mode_t getPhoneState()
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        status_t status = remote()->transact(GET_PHONE_STATE, data, &reply);
        if (status != NO_ERROR) {
            return AUDIO_MODE_INVALID;
        }
        return (audio_mode_t)reply.readInt32();
    }
};

IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
@@ -1057,6 +1069,12 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        } break;

        case GET_PHONE_STATE: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            reply->writeInt32((int32_t)getPhoneState());
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
Loading