1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci 16d95e75fdSopenharmony_ci#include "config_request.h" 17d95e75fdSopenharmony_ci 18d95e75fdSopenharmony_ci#include "call_manager_errors.h" 19d95e75fdSopenharmony_ci#include "cellular_call_service.h" 20d95e75fdSopenharmony_ci#include "ims_call_client.h" 21d95e75fdSopenharmony_ci#include "radio_event.h" 22d95e75fdSopenharmony_ci 23d95e75fdSopenharmony_cinamespace OHOS { 24d95e75fdSopenharmony_cinamespace Telephony { 25d95e75fdSopenharmony_ciint32_t ConfigRequest::SetDomainPreferenceModeRequest(int32_t slotId, int32_t mode) 26d95e75fdSopenharmony_ci{ 27d95e75fdSopenharmony_ci if (moduleUtils_.NeedCallImsService()) { 28d95e75fdSopenharmony_ci TELEPHONY_LOGI("SetDomainPreferenceModeRequest, call ims service"); 29d95e75fdSopenharmony_ci if (DelayedSingleton<ImsCallClient>::GetInstance() == nullptr) { 30d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr."); 31d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 32d95e75fdSopenharmony_ci } 33d95e75fdSopenharmony_ci return DelayedSingleton<ImsCallClient>::GetInstance()->SetDomainPreferenceMode(slotId, mode); 34d95e75fdSopenharmony_ci } 35d95e75fdSopenharmony_ci 36d95e75fdSopenharmony_ci TELEPHONY_LOGD("SetDomainPreferenceModeRequest, ims vendor service does not exist."); 37d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 38d95e75fdSopenharmony_ci if (handle == nullptr) { 39d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetDomainPreferenceModeRequest return, error type: handle is nullptr."); 40d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 41d95e75fdSopenharmony_ci } 42d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().SetCallPreferenceMode( 43d95e75fdSopenharmony_ci slotId, RadioEvent::RADIO_SET_CALL_PREFERENCE_MODE, mode, handle); 44d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 45d95e75fdSopenharmony_ci} 46d95e75fdSopenharmony_ci 47d95e75fdSopenharmony_ciint32_t ConfigRequest::GetDomainPreferenceModeRequest(int32_t slotId) 48d95e75fdSopenharmony_ci{ 49d95e75fdSopenharmony_ci if (moduleUtils_.NeedCallImsService()) { 50d95e75fdSopenharmony_ci TELEPHONY_LOGI("GetDomainPreferenceModeRequest, call ims service"); 51d95e75fdSopenharmony_ci if (DelayedSingleton<ImsCallClient>::GetInstance() == nullptr) { 52d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr."); 53d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 54d95e75fdSopenharmony_ci } 55d95e75fdSopenharmony_ci return DelayedSingleton<ImsCallClient>::GetInstance()->GetDomainPreferenceMode(slotId); 56d95e75fdSopenharmony_ci } 57d95e75fdSopenharmony_ci 58d95e75fdSopenharmony_ci TELEPHONY_LOGD("GetDomainPreferenceModeRequest, ims vendor service does not exist."); 59d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 60d95e75fdSopenharmony_ci if (handle == nullptr) { 61d95e75fdSopenharmony_ci TELEPHONY_LOGE("GetDomainPreferenceModeRequest return, error type: handle is nullptr."); 62d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 63d95e75fdSopenharmony_ci } 64d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().GetCallPreferenceMode(slotId, RadioEvent::RADIO_GET_CALL_PREFERENCE_MODE, handle); 65d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 66d95e75fdSopenharmony_ci} 67d95e75fdSopenharmony_ci 68d95e75fdSopenharmony_ciint32_t ConfigRequest::SetImsSwitchStatusRequest(int32_t slotId, bool active) 69d95e75fdSopenharmony_ci{ 70d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 71d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 72d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 73d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 74d95e75fdSopenharmony_ci } 75d95e75fdSopenharmony_ci return imsCallClient->SetImsSwitchStatus(slotId, active); 76d95e75fdSopenharmony_ci} 77d95e75fdSopenharmony_ci 78d95e75fdSopenharmony_ciint32_t ConfigRequest::SetVoNRSwitchStatusRequest(int32_t slotId, int32_t state) 79d95e75fdSopenharmony_ci{ 80d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 81d95e75fdSopenharmony_ci if (handle == nullptr) { 82d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetVoNRSwitchStatusRequest return, error type: handle is nullptr."); 83d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 84d95e75fdSopenharmony_ci } 85d95e75fdSopenharmony_ci TELEPHONY_LOGD("slotId: %{public}d, switchState: %{public}d", slotId, state); 86d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().SetVoNRSwitch(slotId, state, RadioEvent::RADIO_SET_VONR_SWITCH_STATUS, handle); 87d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 88d95e75fdSopenharmony_ci} 89d95e75fdSopenharmony_ci 90d95e75fdSopenharmony_ciint32_t ConfigRequest::GetImsSwitchStatusRequest(int32_t slotId) 91d95e75fdSopenharmony_ci{ 92d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 93d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 94d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 95d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 96d95e75fdSopenharmony_ci } 97d95e75fdSopenharmony_ci return imsCallClient->GetImsSwitchStatus(slotId); 98d95e75fdSopenharmony_ci} 99d95e75fdSopenharmony_ci 100d95e75fdSopenharmony_ciint32_t ConfigRequest::SetImsConfigRequest(ImsConfigItem item, const std::string &value) 101d95e75fdSopenharmony_ci{ 102d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 103d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 104d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 105d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 106d95e75fdSopenharmony_ci } 107d95e75fdSopenharmony_ci return imsCallClient->SetImsConfig(item, value); 108d95e75fdSopenharmony_ci} 109d95e75fdSopenharmony_ci 110d95e75fdSopenharmony_ciint32_t ConfigRequest::SetImsConfigRequest(ImsConfigItem item, int32_t value) 111d95e75fdSopenharmony_ci{ 112d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 113d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 114d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 115d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 116d95e75fdSopenharmony_ci } 117d95e75fdSopenharmony_ci return imsCallClient->SetImsConfig(item, value); 118d95e75fdSopenharmony_ci} 119d95e75fdSopenharmony_ci 120d95e75fdSopenharmony_ciint32_t ConfigRequest::GetImsConfigRequest(ImsConfigItem item) 121d95e75fdSopenharmony_ci{ 122d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 123d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 124d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 125d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 126d95e75fdSopenharmony_ci } 127d95e75fdSopenharmony_ci return imsCallClient->GetImsConfig(item); 128d95e75fdSopenharmony_ci} 129d95e75fdSopenharmony_ci 130d95e75fdSopenharmony_ciint32_t ConfigRequest::SetImsFeatureValueRequest(FeatureType type, int32_t value) 131d95e75fdSopenharmony_ci{ 132d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 133d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 134d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 135d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 136d95e75fdSopenharmony_ci } 137d95e75fdSopenharmony_ci return imsCallClient->SetImsFeatureValue(type, value); 138d95e75fdSopenharmony_ci} 139d95e75fdSopenharmony_ci 140d95e75fdSopenharmony_ciint32_t ConfigRequest::GetImsFeatureValueRequest(FeatureType type, int32_t &value) 141d95e75fdSopenharmony_ci{ 142d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 143d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 144d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 145d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 146d95e75fdSopenharmony_ci } 147d95e75fdSopenharmony_ci return imsCallClient->GetImsFeatureValue(type, value); 148d95e75fdSopenharmony_ci} 149d95e75fdSopenharmony_ci 150d95e75fdSopenharmony_ciint32_t ConfigRequest::SetMuteRequest(int32_t slotId, int32_t mute) 151d95e75fdSopenharmony_ci{ 152d95e75fdSopenharmony_ci if (moduleUtils_.NeedCallImsService()) { 153d95e75fdSopenharmony_ci TELEPHONY_LOGI("SetMuteRequest, call ims service"); 154d95e75fdSopenharmony_ci if (DelayedSingleton<ImsCallClient>::GetInstance() == nullptr) { 155d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr."); 156d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 157d95e75fdSopenharmony_ci } 158d95e75fdSopenharmony_ci return DelayedSingleton<ImsCallClient>::GetInstance()->SetMute(slotId, mute); 159d95e75fdSopenharmony_ci } 160d95e75fdSopenharmony_ci 161d95e75fdSopenharmony_ci TELEPHONY_LOGD("SetMuteRequest, ims vendor service does not exist."); 162d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 163d95e75fdSopenharmony_ci if (handle == nullptr) { 164d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetMuteRequest return, error type: handle is nullptr."); 165d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 166d95e75fdSopenharmony_ci } 167d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().SetMute(slotId, RadioEvent::RADIO_SET_CMUT, mute, handle); 168d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 169d95e75fdSopenharmony_ci} 170d95e75fdSopenharmony_ci 171d95e75fdSopenharmony_ciint32_t ConfigRequest::GetMuteRequest(int32_t slotId) 172d95e75fdSopenharmony_ci{ 173d95e75fdSopenharmony_ci if (moduleUtils_.NeedCallImsService()) { 174d95e75fdSopenharmony_ci TELEPHONY_LOGI("GetMuteRequest, call ims service"); 175d95e75fdSopenharmony_ci if (DelayedSingleton<ImsCallClient>::GetInstance() == nullptr) { 176d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr."); 177d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 178d95e75fdSopenharmony_ci } 179d95e75fdSopenharmony_ci return DelayedSingleton<ImsCallClient>::GetInstance()->GetMute(slotId); 180d95e75fdSopenharmony_ci } 181d95e75fdSopenharmony_ci 182d95e75fdSopenharmony_ci TELEPHONY_LOGD("GetMuteRequest, ims vendor service does not exist."); 183d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 184d95e75fdSopenharmony_ci if (handle == nullptr) { 185d95e75fdSopenharmony_ci TELEPHONY_LOGE("GetMuteRequest return, error type: handle is nullptr."); 186d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 187d95e75fdSopenharmony_ci } 188d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().GetMute(slotId, RadioEvent::RADIO_GET_CMUT, handle); 189d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 190d95e75fdSopenharmony_ci} 191d95e75fdSopenharmony_ci 192d95e75fdSopenharmony_ciint32_t ConfigRequest::GetEmergencyCallListRequest(int32_t slotId) 193d95e75fdSopenharmony_ci{ 194d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 195d95e75fdSopenharmony_ci if (handle == nullptr) { 196d95e75fdSopenharmony_ci TELEPHONY_LOGE("GetEmergencyCallListRequest return, error type: handle is nullptr."); 197d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 198d95e75fdSopenharmony_ci } 199d95e75fdSopenharmony_ci CoreManagerInner::GetInstance().GetEmergencyCallList(slotId, RadioEvent::RADIO_GET_EMERGENCY_CALL_LIST, handle); 200d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 201d95e75fdSopenharmony_ci} 202d95e75fdSopenharmony_ci 203d95e75fdSopenharmony_ciint32_t ConfigRequest::SetEmergencyCallListRequest(int32_t slotId, std::vector<EmergencyCall> &eccVec) 204d95e75fdSopenharmony_ci{ 205d95e75fdSopenharmony_ci TELEPHONY_LOGD("SetEmergencyCallListRequest start "); 206d95e75fdSopenharmony_ci auto handle = DelayedSingleton<CellularCallService>::GetInstance()->GetHandler(slotId); 207d95e75fdSopenharmony_ci if (handle == nullptr) { 208d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetEmergencyCallListRequest return, error type: handle is nullptr."); 209d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 210d95e75fdSopenharmony_ci } 211d95e75fdSopenharmony_ci int32_t errorCode = TELEPHONY_ERR_FAIL; 212d95e75fdSopenharmony_ci errorCode = CoreManagerInner::GetInstance().SetEmergencyCallList( 213d95e75fdSopenharmony_ci slotId, RadioEvent::RADIO_SET_EMERGENCY_CALL_LIST, eccVec, handle); 214d95e75fdSopenharmony_ci if (errorCode != TELEPHONY_ERR_SUCCESS) { 215d95e75fdSopenharmony_ci TELEPHONY_LOGE("SetEmergencyCallListRequest end fail, errorCode: %{public}d", errorCode); 216d95e75fdSopenharmony_ci } 217d95e75fdSopenharmony_ci return errorCode; 218d95e75fdSopenharmony_ci} 219d95e75fdSopenharmony_ci 220d95e75fdSopenharmony_ciint32_t ConfigRequest::UpdateImsCapabilities(int32_t slotId, const ImsCapabilityList &imsCapabilityList) 221d95e75fdSopenharmony_ci{ 222d95e75fdSopenharmony_ci auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance(); 223d95e75fdSopenharmony_ci if (imsCallClient == nullptr || imsCallClient->GetImsCallProxy() == nullptr) { 224d95e75fdSopenharmony_ci TELEPHONY_LOGE("ImsCallClient is nullptr or ims service SA not exists."); 225d95e75fdSopenharmony_ci return CALL_ERR_RESOURCE_UNAVAILABLE; 226d95e75fdSopenharmony_ci } 227d95e75fdSopenharmony_ci for (auto it : imsCapabilityList.imsCapabilities) { 228d95e75fdSopenharmony_ci TELEPHONY_LOGI("ImsCapabilityType:%{public}d imsRadioTech:%{public}d enable:%{public}d", it.imsCapabilityType, 229d95e75fdSopenharmony_ci it.imsRadioTech, it.enable); 230d95e75fdSopenharmony_ci } 231d95e75fdSopenharmony_ci return imsCallClient->UpdateImsCapabilities(slotId, imsCapabilityList); 232d95e75fdSopenharmony_ci} 233d95e75fdSopenharmony_ci} // namespace Telephony 234d95e75fdSopenharmony_ci} // namespace OHOS 235