1 /* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef CELLULAR_CALL_CONFIG_H 17 #define CELLULAR_CALL_CONFIG_H 18 19 #include <map> 20 #include <mutex> 21 22 #include "config_request.h" 23 #include "global_params_data.h" 24 #include "operator_config_types.h" 25 #include "sim_state_type.h" 26 #include "telephony_log_wrapper.h" 27 28 namespace OHOS { 29 namespace Telephony { 30 class CellularCallConfig { 31 public: 32 /** 33 * CellularCallConfig constructor 34 * 35 */ 36 CellularCallConfig(); 37 38 /** 39 * Set Domain Preference Mode 40 * 41 * 3GPP TS 27.007 V17.3.0 (2021-09) 10.1.35 UE's voice domain preference E-UTRAN +CEVDP 42 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.27 /<X>/Voice_Domain_Preference_E_UTRAN 43 * 44 * @param mode 45 * @param slotId 46 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 47 */ 48 int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode); 49 50 /** 51 * Get Domain Preference Mode 52 * 53 * 3GPP TS 27.007 V17.3.0 (2021-09) 10.1.35 UE's voice domain preference E-UTRAN +CEVDP 54 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.27 /<X>/Voice_Domain_Preference_E_UTRAN 55 * 56 * @param slotId 57 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 58 */ 59 int32_t GetDomainPreferenceMode(int32_t slotId); 60 61 /** 62 * Set Lte Ims Switch Status 63 * 64 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.31 /<X>/Mobility_Management_IMS_Voice_Termination 65 * 66 * @param slotId 67 * @param active 68 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 69 */ 70 int32_t SetImsSwitchStatus(int32_t slotId, bool active); 71 72 /** 73 * Get Lte Ims Switch Status 74 * 75 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.31 /<X>/Mobility_Management_IMS_Voice_Termination 76 * 77 * @param slotId 78 * @param enabled 79 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 80 */ 81 int32_t GetImsSwitchStatus(int32_t slotId, bool &enabled); 82 83 /** 84 * Set VoNR Switch Status 85 * 86 * @param slotId 87 * @param state 88 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 89 */ 90 int32_t SetVoNRSwitchStatus(int32_t slotId, int32_t state); 91 92 /** 93 * Get VoNR Switch Status 94 * 95 * @param slotId 96 * @param state 97 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 98 */ 99 int32_t GetVoNRSwitchStatus(int32_t slotId, int32_t &state); 100 101 /** 102 * Get Domain Preference Mode Response 103 * 104 * @param slotId 105 * @param mode 106 */ 107 void GetDomainPreferenceModeResponse(int32_t slotId, int32_t mode); 108 109 /** 110 * Get Lte Ims Switch Status Response 111 * 112 * @param slotId 113 * @param active 114 */ 115 void GetImsSwitchStatusResponse(int32_t slotId, int32_t active); 116 117 /** 118 * Get Preference Mode 119 * 120 * @param slotId 121 * @return mode 122 */ 123 int32_t GetPreferenceMode(int32_t slotId) const; 124 125 /** 126 * Set Ims Config 127 * 128 * @param ImsConfigItem 129 * @param value 130 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 131 */ 132 int32_t SetImsConfig(ImsConfigItem item, const std::string &value); 133 134 /** 135 * Set Ims Config 136 * 137 * @param ImsConfigItem 138 * @param value 139 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 140 */ 141 int32_t SetImsConfig(ImsConfigItem item, int32_t value); 142 143 /** 144 * Get Ims Config 145 * 146 * @param ImsConfigItem 147 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 148 */ 149 int32_t GetImsConfig(ImsConfigItem item); 150 151 /** 152 * Set Ims Feature Value 153 * 154 * @param FeatureType 155 * @param value 156 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 157 */ 158 int32_t SetImsFeatureValue(FeatureType type, int32_t value); 159 160 /** 161 * Get Ims Feature Value 162 * 163 * @param FeatureType 164 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 165 */ 166 int32_t GetImsFeatureValue(FeatureType type); 167 168 /** 169 * SetMute 170 * 171 * @param slotId 172 * @param mute 173 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 174 */ 175 int32_t SetMute(int32_t slotId, int32_t mute); 176 177 /** 178 * GetMute 179 * 180 * @param slotId 181 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 182 */ 183 int32_t GetMute(int32_t slotId); 184 185 /** 186 * GetEmergencyCallList 187 * 188 * @param slotId 189 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 190 */ 191 int32_t GetEmergencyCallList(int32_t slotId); 192 193 /** 194 * SetEmergencyCallList 195 * 196 * @param slotId 197 * @param eccVec 198 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 199 */ 200 int32_t SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall> &eccVec); 201 202 /** 203 * SetTempMode 204 * 205 * @param slotId 206 */ 207 void SetTempMode(int32_t slotId); 208 209 /** 210 * Init mode and active 211 */ 212 void InitModeActive(); 213 214 /** 215 * Get Emergency Call List Response 216 * 217 * @param slotId 218 * @param EmergencyInfoList 219 */ 220 void UpdateEmergencyCallFromRadio(int32_t slotId, const EmergencyInfoList &eccList); 221 222 /** 223 * HandleSimStateChanged 224 * 225 * @param slotId 226 */ 227 void HandleSimStateChanged(int32_t slotId); 228 229 /** 230 * HandleFactoryReset 231 * 232 * @param slotId 233 */ 234 void HandleFactoryReset(int32_t slotId); 235 236 /** 237 * HandleSetLteImsSwitchResult 238 * 239 * @param slotId 240 * @param result 241 */ 242 void HandleSetLteImsSwitchResult(int32_t slotId, HRilErrType result); 243 244 /** 245 * HandleSetVoNRSwitchResult 246 * 247 * @param slotId 248 * @param result 249 */ 250 void HandleSetVoNRSwitchResult(int32_t slotId, HRilErrType result); 251 252 /** 253 * HandleSimRecordsLoaded 254 * 255 * @param slotId 256 */ 257 void HandleSimRecordsLoaded(int32_t slotId); 258 259 void HandleResidentNetworkChange(int32_t slotId, std::string plmn); 260 261 void HandleNetworkStateChange(int32_t slotId); 262 263 /** 264 * HandleSimAccountLoaded 265 * 266 * @param slotId 267 */ 268 void HandleSimAccountLoaded(int32_t slotId); 269 270 /** 271 * Handle when operator config change. 272 * 273 * @param slotId 274 */ 275 void HandleOperatorConfigChanged(int32_t slotId); 276 277 /** 278 * Get Ecc Call List 279 * 280 * @param slotId 281 * @return std::vector<EmergencyCall> 282 */ 283 std::vector<EmergencyCall> GetEccCallList(int32_t slotId); 284 285 std::string GetMcc(int32_t slotId_); 286 287 /** 288 * Change bool value to Ims switch value. 289 * 290 * @param value 291 * @return std::int32_t 292 */ 293 std::int32_t BooleanToImsSwitchValue(bool value); 294 295 /** 296 * The IF used to get the value of operator config 297 * {@link OperatorConfig#KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL} 298 * 299 * @param slotId 300 * @return bool 301 */ 302 bool GetImsSwitchOnByDefaultConfig(int32_t slotId); 303 304 /** 305 * The IF used to get the value of operator config 306 * {@link OperatorConfig#KEY_HIDE_IMS_SWITCH_BOOL} 307 * 308 * @param slotId 309 * @return bool 310 */ 311 bool GethideImsSwitchConfig(int32_t slotId); 312 313 /** 314 * The IF used to get the value of operator config 315 * {@link OperatorConfig#KEY_VOLTE_SUPPORTED_BOOL} 316 * 317 * @param slotId 318 * @return bool 319 */ 320 bool GetvolteSupportedConfig(int32_t slotId); 321 322 /** 323 * The IF used to get the value of operator config 324 * {@link OperatorConfig#KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY} 325 * 326 * @param slotId 327 * @return std::vector<int32_t> 328 */ 329 std::vector<int32_t> GetNrModeSupportedListConfig(int32_t slotId); 330 331 /** 332 * The IF used to get the value of operator config 333 * {@link OperatorConfig#KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL} 334 * 335 * @param slotId 336 * @return bool 337 */ 338 bool GetVolteProvisioningSupportedConfig(int32_t slotId); 339 340 /** 341 * The IF used to get the value of operator config 342 * {@link OperatorConfig#KEY_SS_OVER_UT_SUPPORTED_BOOL} 343 * 344 * @param slotId 345 * @return bool 346 */ 347 bool GetSsOverUtSupportedConfig(int32_t slotId); 348 349 /** 350 * The IF used to get the value of operator config 351 * {@link OperatorConfig#KEY_IMS_GBA_REQUIRED_BOOL} 352 * 353 * @param slotId 354 * @return bool 355 */ 356 bool GetImsGbaRequiredConfig(int32_t slotId); 357 358 /** 359 * The IF used to get the value of operator config 360 * {@link OperatorConfig#KEY_UT_PROVISIONING_SUPPORTED_BOOL} 361 * 362 * @param slotId 363 * @return bool 364 */ 365 bool GetUtProvisioningSupportedConfig(int32_t slotId); 366 367 /** 368 * The IF used to get the value of operator config 369 * {@link OperatorConfig#KEY_IMS_PREFER_FOR_EMERGENCY_BOOL} 370 * 371 * @param slotId 372 * @return bool 373 */ 374 bool GetImsPreferForEmergencyConfig(int32_t slotId); 375 376 /** 377 * The IF used to get the value of operator config 378 * {@link OperatorConfig#KEY_CALL_WAITING_SERVICE_CLASS_INT} 379 * 380 * @param slotId 381 * @return std::int32_t 382 */ 383 std::int32_t GetCallWaitingServiceClassConfig(int32_t slotId); 384 385 /** 386 * The IF used to get the value of operator config 387 * {@link OperatorConfig#KEY_IMS_CALL_DISCONNECT_REASONINFO_MAPPING_STRING_ARRAY} 388 * 389 * @param slotId 390 * @return std::vector<std::string> 391 */ 392 std::vector<std::string> GetImsCallDisconnectResoninfoMappingConfig(int32_t slotId); 393 394 /** 395 * The IF used to get the value of operator config 396 * {@link OperatorConfig#KEY_FORCE_VOLTE_SWITCH_ON_BOOL} 397 * 398 * @param slotId 399 * @return bool 400 */ 401 bool GetForceVolteSwitchOnConfig(int32_t slotId); 402 403 /** 404 * Is Valid Slot Id 405 * 406 * @param slotId 407 * @return bool 408 */ 409 bool IsValidSlotId(int32_t slotId); 410 411 void SetReadyToCall(int32_t slotId, bool isReadyToCall); 412 413 bool IsReadyToCall(int32_t slotId); 414 415 private: 416 static void InitDefaultOperatorConfig(); 417 EmergencyCall BuildDefaultEmergencyCall(const std::string &number, SimpresentType simType); 418 EmergencyCall BuildEmergencyCall(int32_t slotId, const EmergencyInfo &from); 419 void UniqueEccCallList(int32_t slotId, std::vector<EmergencyCall> &eccList); 420 void MergeEccCallList(int32_t slotId); 421 bool CheckAndUpdateSimState(int32_t slotId); 422 int32_t ParseAndCacheOperatorConfigs(int32_t slotId, OperatorConfig &poc); 423 void ParseBoolOperatorConfigs( 424 int32_t slotId, std::map<int32_t, bool> &config, OperatorConfig &poc, std::string configName); 425 void ResetImsSwitch(int32_t slotId); 426 void UpdateImsCapabilities(int32_t slotId, bool needUpdateUtCapability); 427 void UpdateImsUtCapabilities(int32_t slotId, bool isGbaValid, ImsCapabilityList &imsCapabilityList); 428 void UpdateImsVoiceCapabilities(int32_t slotId, bool isGbaValid, ImsCapabilityList &imsCapabilityList); 429 bool IsGbaValid(int32_t slotId); 430 bool IsVolteProvisioned(int32_t slotId); 431 bool IsVonrSupported(int32_t slotId, bool isGbaValid); 432 bool IsUtProvisioned(int32_t slotId); 433 bool IsNeedTurnOnIms(const ImsCapabilityList &imsCapabilityList); 434 bool IsSimChanged(int32_t slotId, std::string iccid); 435 bool ChangeImsSwitchWithOperatorConfig(int32_t slotId, bool active); 436 int32_t SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue); 437 int32_t GetSwitchStatus(int32_t slotId); 438 void saveImsSwitchStatusToLocalForPowerOn(int32_t slotId); 439 void saveImsSwitchStatusToLocal(int32_t slotId, int32_t imsSwitchStatus); 440 void SaveVoNRState(int32_t slotId, int32_t state); 441 int32_t ObtainVoNRState(int32_t slotId); 442 void UpdateEccNumberList(int32_t slotId); 443 void GetEccListFromResult(const std::vector<EccNum> &eccVec, 444 std::vector<std::string> &callListWithCard, std::vector<std::string> &callListNoCard); 445 446 private: 447 static std::map<int32_t, int32_t> modeTempMap_; 448 static std::map<int32_t, int32_t> modeMap_; 449 static std::map<int32_t, std::vector<EmergencyCall>> eccListRadioMap_; 450 static std::vector<EmergencyCall> eccList3gppHasSim_; 451 static std::vector<EmergencyCall> eccList3gppNoSim_; 452 static std::map<int32_t, std::vector<EmergencyCall>> allEccList_; 453 static std::map<int32_t, int32_t> simState_; 454 static std::map<int32_t, std::string> curPlmn_; 455 static std::map<int32_t, RegServiceState> serviceState_; 456 std::mutex mutex_; 457 static std::mutex operatorMutex_; 458 ConfigRequest configRequest_; 459 static std::map<int32_t, bool> imsSwitchOnByDefault_; 460 static std::map<int32_t, bool> hideImsSwitch_; 461 static std::map<int32_t, bool> volteSupported_; 462 static std::map<int32_t, std::vector<int32_t>> nrModeSupportedList_; 463 static std::map<int32_t, bool> volteProvisioningSupported_; 464 static std::map<int32_t, bool> ssOverUtSupported_; 465 static std::map<int32_t, bool> imsGbaRequired_; 466 static std::map<int32_t, bool> utProvisioningSupported_; 467 static std::map<int32_t, bool> imsPreferForEmergency_; 468 static std::map<int32_t, int32_t> callWaitingServiceClass_; 469 static std::map<int32_t, std::vector<std::string>> imsCallDisconnectResoninfoMapping_; 470 static std::map<int32_t, bool> forceVolteSwitchOn_; 471 static std::map<int32_t, bool> readyToCall_; 472 static std::map<int32_t, int32_t> vonrSwithStatus_; 473 static bool isOperatorConfigInit_; 474 }; 475 } // namespace Telephony 476 } // namespace OHOS 477 #endif // CELLULAR_CALL_CONFIG_H 478