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

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

Merge "audio policy: use call screen mode"

parents 0c3ab344 74b71519
Loading
Loading
Loading
Loading
+11 −3
Original line number Original line Diff line number Diff line
@@ -682,8 +682,8 @@ void AudioPolicyManager::setPhoneState(audio_mode_t state)
     * Switching to or from incall state or switching between telephony and VoIP lead to force
     * Switching to or from incall state or switching between telephony and VoIP lead to force
     * routing command.
     * routing command.
     */
     */
    bool force = ((is_state_in_call(oldState) != is_state_in_call(state))
    bool force = ((isStateInCall(oldState) != isStateInCall(state))
                  || (is_state_in_call(state) && (state != oldState)));
                  || (isStateInCall(state) && (state != oldState)));


    // check for device and output changes triggered by new phone state
    // check for device and output changes triggered by new phone state
    checkForDeviceAndOutputChanges();
    checkForDeviceAndOutputChanges();
@@ -1015,7 +1015,7 @@ status_t AudioPolicyManager::getOutputForAttrInt(
    if (outputDevices.onlyContainsDevicesWithType(AUDIO_DEVICE_OUT_TELEPHONY_TX) &&
    if (outputDevices.onlyContainsDevicesWithType(AUDIO_DEVICE_OUT_TELEPHONY_TX) &&
        (*stream == AUDIO_STREAM_MUSIC  || resultAttr->usage == AUDIO_USAGE_VOICE_COMMUNICATION) &&
        (*stream == AUDIO_STREAM_MUSIC  || resultAttr->usage == AUDIO_USAGE_VOICE_COMMUNICATION) &&
        audio_is_linear_pcm(config->format) &&
        audio_is_linear_pcm(config->format) &&
        isInCall()) {
        isCallAudioAccessible()) {
        if (requestedPortId != AUDIO_PORT_HANDLE_NONE) {
        if (requestedPortId != AUDIO_PORT_HANDLE_NONE) {
            *flags = (audio_output_flags_t)AUDIO_OUTPUT_FLAG_INCALL_MUSIC;
            *flags = (audio_output_flags_t)AUDIO_OUTPUT_FLAG_INCALL_MUSIC;
            *isRequestedDeviceForExclusiveUse = true;
            *isRequestedDeviceForExclusiveUse = true;
@@ -6068,6 +6068,14 @@ bool AudioPolicyManager::isStateInCall(int state)
    return is_state_in_call(state);
    return is_state_in_call(state);
}
}


bool AudioPolicyManager::isCallAudioAccessible()
{
    audio_mode_t mode = mEngine->getPhoneState();
    return (mode == AUDIO_MODE_IN_CALL)
            || (mode == AUDIO_MODE_IN_COMMUNICATION)
            || (mode == AUDIO_MODE_CALL_SCREEN);
}

void AudioPolicyManager::cleanUpForDevice(const sp<DeviceDescriptor>& deviceDesc)
void AudioPolicyManager::cleanUpForDevice(const sp<DeviceDescriptor>& deviceDesc)
{
{
    for (ssize_t i = (ssize_t)mAudioSources.size() - 1; i >= 0; i--)  {
    for (ssize_t i = (ssize_t)mAudioSources.size() - 1; i >= 0; i--)  {
+2 −0
Original line number Original line Diff line number Diff line
@@ -478,6 +478,8 @@ protected:
        virtual bool isInCall();
        virtual bool isInCall();
        // true if given state represents a device in a telephony or VoIP call
        // true if given state represents a device in a telephony or VoIP call
        virtual bool isStateInCall(int state);
        virtual bool isStateInCall(int state);
        // true if playback to call TX or capture from call RX is possible
        bool isCallAudioAccessible();


        // when a device is connected, checks if an open output can be routed
        // when a device is connected, checks if an open output can be routed
        // to this device. If none is open, tries to open one of the available outputs.
        // to this device. If none is open, tries to open one of the available outputs.