status_t SpeechEnhancementController::SetDynamicMaskOnToAllModem(const sph_enh_dynamic_mask_t dynamic_mask_type, const bool new_flag_on)
{
    sph_enh_mask_struct_t mask = GetSpeechEnhancementMask();

    const bool current_flag_on = ((mask.dynamic_func & dynamic_mask_type) > 0);
    if (new_flag_on == current_flag_on) {
        ALOGW("%s(), dynamic_mask_type(%x), new_flag_on(%d) == current_flag_on(%d), return",
              __FUNCTION__, dynamic_mask_type, new_flag_on, current_flag_on);
        return NO_ERROR;
    }

    if (new_flag_on == false) {
        mask.dynamic_func &= (~dynamic_mask_type);
    }
    else {
        mask.dynamic_func |= dynamic_mask_type;
    }

    return SetSpeechEnhancementMaskToAllModem(mask);
}
sph_enh_mask_struct_t SpeechEnhancementController::GetNRECMask(const bool bNrecOn, bool* bNrecSwitchNeed) 
{ 
    sph_enh_mask_struct_t mask = GetSpeechEnhancementMask();

    SetBtHeadsetNrecOnMaskOn(&mask, SPH_ENH_DYNAMIC_MASK_DLNR, bNrecOn);
    SetBtHeadsetNrecOnMaskOn(&mask, SPH_ENH_DYNAMIC_MASK_ULNR, bNrecOn);
    SetBtHeadsetNrecOnMaskOn(&mask, SPH_ENH_DYNAMIC_MASK_AEC, bNrecOn);
    //update current mask 
    
    if(mSpeechEnhancementMask.dynamic_func != mask.dynamic_func)
    {
        mSpeechEnhancementMask = mask;
        *bNrecSwitchNeed = true;
        ALOGD("-%s(), bNrecOn(%d), bNrecSwitchNeed(%d) , update", __FUNCTION__, bNrecOn, *bNrecSwitchNeed);
    }
    else
    {
        *bNrecSwitchNeed = false;
        ALOGD("-%s(), bNrecOn(%d), bNrecSwitchNeed(%d) , skip", __FUNCTION__, bNrecOn, *bNrecSwitchNeed);
    }
    return mask; 
}