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

Commit 09870a93 authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Dan Pasanen
Browse files

policy_hal: fix improper voice-playback concurrency handling

- setPhoneState checks call-state in audio hal to filter out
  unworthy usage of this API.
- With M upgrade, change to update call-state with audio hal is
  removed, instead permission checks are introduced to prevent
  random usage of such APIs. But setPhoneState is still checking
  for this call-state causing improper concurrency handling.
- Fix the issue by removing state check from setPhoneState.
- Remove set and get for parameter "in_call" from voice_extn.

Change-Id: I92fe10c617d6158976a0e07eed3275acb0aadd15
parent 2c2f7efd
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -131,8 +131,6 @@ int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
    }

    session->state.current = CALL_INACTIVE;
    if (adev->mode == AUDIO_MODE_NORMAL)
        adev->voice.is_in_call = false;

    /* Disable sidetone only when no calls are active */
    if (!voice_is_call_state_active(adev))
+0 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@ struct voice {
    int tty_mode;
    bool mic_mute;
    float volume;
    bool is_in_call;
    bool in_call;
};

+0 −19
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@
#define AUDIO_PARAMETER_KEY_ALL_CALL_STATES     "all_call_states"
#define AUDIO_PARAMETER_KEY_DEVICE_MUTE         "device_mute"
#define AUDIO_PARAMETER_KEY_DIRECTION           "direction"
#define AUDIO_PARAMETER_KEY_IN_CALL             "in_call"

#define VOICE_EXTN_PARAMETER_VALUE_MAX_LEN 256

@@ -480,15 +479,6 @@ int voice_extn_set_parameters(struct audio_device *adev,
        }
    }

    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_IN_CALL, str_value,
                            sizeof(str_value));
    if (err >= 0) {
          str_parms_del(parms, AUDIO_PARAMETER_KEY_IN_CALL);
           if (!strncmp("true", str_value, sizeof("true"))) {
           adev->voice.is_in_call = true;
        }
    }

done:
    ALOGV("%s: exit with code(%d)", __func__, ret);
    free(kv_pairs);
@@ -520,19 +510,10 @@ void voice_extn_get_parameters(const struct audio_device *adev,
    int ret;
    char value[VOICE_EXTN_PARAMETER_VALUE_MAX_LEN] = {0};
    char *str = str_parms_to_str(query);
    int val = 0;

    ALOGV_IF(str != NULL, "%s: enter %s", __func__, str);
    free(str);

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_IN_CALL, value,
                            sizeof(value));
    if (ret >=0) {
        if (adev->voice.is_in_call)
            val = 1;
        str_parms_add_int(reply, AUDIO_PARAMETER_KEY_IN_CALL, val);
    }

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_AUDIO_MODE, value,
                            sizeof(value));
    if (ret >= 0) {
+2 −12
Original line number Diff line number Diff line
@@ -694,7 +694,6 @@ void AudioPolicyManagerCustom::setPhoneState(audio_mode_t state)

    sp<SwAudioOutputDescriptor> hwOutputDesc = mPrimaryOutput;
#ifdef VOICE_CONCURRENCY
    int voice_call_state = 0;
    char propValue[PROPERTY_VALUE_MAX];
    bool prop_playback_enabled = false, prop_rec_enabled=false, prop_voip_enabled = false;

@@ -710,19 +709,10 @@ void AudioPolicyManagerCustom::setPhoneState(audio_mode_t state)
        prop_voip_enabled = atoi(propValue) || !strncmp("true", propValue, 4);
    }

    bool mode_in_call = (AUDIO_MODE_IN_CALL != oldState) && (AUDIO_MODE_IN_CALL == state);
    //query if it is a actual voice call initiated by telephony
    if (mode_in_call) {
        String8 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0, String8("in_call"));
        AudioParameter result = AudioParameter(valueStr);
        if (result.getInt(String8("in_call"), voice_call_state) == NO_ERROR)
            ALOGD("voice_conc:SetPhoneState: Voice call state = %d", voice_call_state);
    }

    if (mode_in_call && voice_call_state && !mvoice_call_state) {
    if ((AUDIO_MODE_IN_CALL != oldState) && (AUDIO_MODE_IN_CALL == state)) {
        ALOGD("voice_conc:Entering to call mode oldState :: %d state::%d ",
            oldState, state);
        mvoice_call_state = voice_call_state;
        mvoice_call_state = state;
        if (prop_rec_enabled) {
            //Close all active inputs
            audio_io_handle_t activeInput = mInputs.getActiveInput();