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 <shared_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 constexpr const char *KEY_CONST_TELEPHONY_READ_THIRD_PARTY_LIB = "const.telephony.read_third_party_lib"; 31 constexpr int32_t INVALID_OPERATOR_CONFIG_STATE = -1; 32 class CellularCallConfig { 33 public: 34 /** 35 * CellularCallConfig constructor 36 * 37 */ 38 CellularCallConfig(); 39 40 /** 41 * Set Domain Preference Mode 42 * 43 * 3GPP TS 27.007 V17.3.0 (2021-09) 10.1.35 UE's voice domain preference E-UTRAN +CEVDP 44 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.27 /<X>/Voice_Domain_Preference_E_UTRAN 45 * 46 * @param mode 47 * @param slotId 48 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 49 */ 50 int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode); 51 52 /** 53 * Get Domain Preference Mode 54 * 55 * 3GPP TS 27.007 V17.3.0 (2021-09) 10.1.35 UE's voice domain preference E-UTRAN +CEVDP 56 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.27 /<X>/Voice_Domain_Preference_E_UTRAN 57 * 58 * @param slotId 59 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 60 */ 61 int32_t GetDomainPreferenceMode(int32_t slotId); 62 63 /** 64 * Set Lte Ims Switch Status 65 * 66 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.31 /<X>/Mobility_Management_IMS_Voice_Termination 67 * 68 * @param slotId 69 * @param active 70 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 71 */ 72 int32_t SetImsSwitchStatus(int32_t slotId, bool active); 73 74 /** 75 * Get Lte Ims Switch Status 76 * 77 * 3GPP TS 24.167 V17.1.0 (2020-12) 5.31 /<X>/Mobility_Management_IMS_Voice_Termination 78 * 79 * @param slotId 80 * @param enabled 81 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 82 */ 83 int32_t GetImsSwitchStatus(int32_t slotId, bool &enabled); 84 85 /** 86 * Get Carrier Vt Config 87 * 88 * 89 * @param slotId 90 * @param enabled 91 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 92 */ 93 int32_t GetCarrierVtConfig(int32_t slotId, bool &enabled); 94 95 /** 96 * Get Carrier Vt Config bool value 97 * 98 * @param slotId 99 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 100 */ 101 bool GetCarrierVtAvailbleConfig(int32_t slotId); 102 103 /** 104 * Set VoNR Switch Status 105 * 106 * @param slotId 107 * @param state 108 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 109 */ 110 int32_t SetVoNRSwitchStatus(int32_t slotId, int32_t state); 111 112 /** 113 * Get VoNR Switch Status 114 * 115 * @param slotId 116 * @param state 117 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 118 */ 119 int32_t GetVoNRSwitchStatus(int32_t slotId, int32_t &state); 120 121 /** 122 * Get Domain Preference Mode Response 123 * 124 * @param slotId 125 * @param mode 126 */ 127 void GetDomainPreferenceModeResponse(int32_t slotId, int32_t mode); 128 129 /** 130 * Get Lte Ims Switch Status Response 131 * 132 * @param slotId 133 * @param active 134 */ 135 void GetImsSwitchStatusResponse(int32_t slotId, int32_t active); 136 137 /** 138 * Get Preference Mode 139 * 140 * @param slotId 141 * @return mode 142 */ 143 int32_t GetPreferenceMode(int32_t slotId) const; 144 145 /** 146 * Set Ims Config 147 * 148 * @param ImsConfigItem 149 * @param value 150 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 151 */ 152 int32_t SetImsConfig(ImsConfigItem item, const std::string &value); 153 154 /** 155 * Set Ims Config 156 * 157 * @param ImsConfigItem 158 * @param value 159 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 160 */ 161 int32_t SetImsConfig(ImsConfigItem item, int32_t value); 162 163 /** 164 * Get Ims Config 165 * 166 * @param ImsConfigItem 167 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 168 */ 169 int32_t GetImsConfig(ImsConfigItem item); 170 171 /** 172 * Set Ims Feature Value 173 * 174 * @param FeatureType 175 * @param value 176 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 177 */ 178 int32_t SetImsFeatureValue(FeatureType type, int32_t value); 179 180 /** 181 * Get Ims Feature Value 182 * 183 * @param FeatureType 184 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 185 */ 186 int32_t GetImsFeatureValue(FeatureType type); 187 188 /** 189 * SetMute 190 * 191 * @param slotId 192 * @param mute 193 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 194 */ 195 int32_t SetMute(int32_t slotId, int32_t mute); 196 197 /** 198 * GetMute 199 * 200 * @param slotId 201 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 202 */ 203 int32_t GetMute(int32_t slotId); 204 205 /** 206 * GetEmergencyCallList 207 * 208 * @param slotId 209 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 210 */ 211 int32_t GetEmergencyCallList(int32_t slotId); 212 213 /** 214 * SetEmergencyCallList 215 * 216 * @param slotId 217 * @param eccVec 218 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 219 */ 220 int32_t SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall> &eccVec); 221 222 /** 223 * SetTempMode 224 * 225 * @param slotId 226 */ 227 void SetTempMode(int32_t slotId); 228 229 /** 230 * Init mode and active 231 */ 232 void InitModeActive(); 233 234 /** 235 * Get Emergency Call List Response 236 * 237 * @param slotId 238 * @param EmergencyInfoList 239 */ 240 void UpdateEmergencyCallFromRadio(int32_t slotId, const EmergencyInfoList &eccList); 241 242 /** 243 * HandleSimStateChanged 244 * 245 * @param slotId 246 */ 247 void HandleSimStateChanged(int32_t slotId); 248 249 /** 250 * HandleFactoryReset 251 * 252 * @param slotId 253 */ 254 void HandleFactoryReset(int32_t slotId); 255 256 /** 257 * HandleSetLteImsSwitchResult 258 * 259 * @param slotId 260 * @param result 261 */ 262 void HandleSetLteImsSwitchResult(int32_t slotId, ErrType result); 263 264 /** 265 * HandleSetVoNRSwitchResult 266 * 267 * @param slotId 268 * @param result 269 */ 270 void HandleSetVoNRSwitchResult(int32_t slotId, ErrType result); 271 272 /** 273 * HandleSimRecordsLoaded 274 * 275 * @param slotId 276 */ 277 void HandleSimRecordsLoaded(int32_t slotId); 278 279 void HandleResidentNetworkChange(int32_t slotId, std::string plmn); 280 281 void HandleNetworkStateChange(int32_t slotId); 282 283 /** 284 * HandleSimAccountLoaded 285 * 286 * @param slotId 287 */ 288 void HandleSimAccountLoaded(int32_t slotId); 289 290 /** 291 * Handle when operator config change. 292 * 293 * @param slotId 294 */ 295 void HandleOperatorConfigChanged(int32_t slotId, int32_t state); 296 297 /** 298 * update ims configuration 299 * 300 * @param slotId 301 * @param configState 302 * @param isOpcChanged 303 */ 304 void UpdateImsConfiguration(int32_t slotId, int32_t configState, bool isOpcChanged); 305 306 /** 307 * Get Ecc Call List 308 * 309 * @param slotId 310 * @return std::vector<EmergencyCall> 311 */ 312 std::vector<EmergencyCall> GetEccCallList(int32_t slotId); 313 314 std::string GetMcc(int32_t slotId_); 315 316 /** 317 * Change bool value to Ims switch value. 318 * 319 * @param value 320 * @return std::int32_t 321 */ 322 std::int32_t BooleanToImsSwitchValue(bool value); 323 324 /** 325 * The IF used to get the value of operator config 326 * {@link OperatorConfig#KEY_IMS_SWITCH_ON_BY_DEFAULT_BOOL} 327 * 328 * @param slotId 329 * @return bool 330 */ 331 bool GetImsSwitchOnByDefaultConfig(int32_t slotId); 332 333 /** 334 * The IF used to get the value of operator config 335 * {@link OperatorConfig#KEY_HIDE_IMS_SWITCH_BOOL} 336 * 337 * @param slotId 338 * @return bool 339 */ 340 bool GethideImsSwitchConfig(int32_t slotId); 341 342 /** 343 * The IF used to get the value of operator config 344 * {@link OperatorConfig#KEY_VOLTE_SUPPORTED_BOOL} 345 * 346 * @param slotId 347 * @return bool 348 */ 349 bool GetvolteSupportedConfig(int32_t slotId); 350 351 /** 352 * The IF used to get the value of operator config 353 * {@link OperatorConfig#KEY_NR_MODE_SUPPORTED_LIST_INT_ARRAY} 354 * 355 * @param slotId 356 * @return std::vector<int32_t> 357 */ 358 std::vector<int32_t> GetNrModeSupportedListConfig(int32_t slotId); 359 360 /** 361 * The IF used to get the value of operator config 362 * {@link OperatorConfig#KEY_VOLTE_PROVISIONING_SUPPORTED_BOOL} 363 * 364 * @param slotId 365 * @return bool 366 */ 367 bool GetVolteProvisioningSupportedConfig(int32_t slotId); 368 369 /** 370 * The IF used to get the value of operator config 371 * {@link OperatorConfig#KEY_SS_OVER_UT_SUPPORTED_BOOL} 372 * 373 * @param slotId 374 * @return bool 375 */ 376 bool GetSsOverUtSupportedConfig(int32_t slotId); 377 378 /** 379 * The IF used to get the value of operator config 380 * {@link OperatorConfig#KEY_IMS_GBA_REQUIRED_BOOL} 381 * 382 * @param slotId 383 * @return bool 384 */ 385 bool GetImsGbaRequiredConfig(int32_t slotId); 386 387 /** 388 * The IF used to get the value of operator config 389 * {@link OperatorConfig#KEY_UT_PROVISIONING_SUPPORTED_BOOL} 390 * 391 * @param slotId 392 * @return bool 393 */ 394 bool GetUtProvisioningSupportedConfig(int32_t slotId); 395 396 /** 397 * The IF used to get the value of operator config 398 * {@link OperatorConfig#KEY_IMS_PREFER_FOR_EMERGENCY_BOOL} 399 * 400 * @param slotId 401 * @return bool 402 */ 403 bool GetImsPreferForEmergencyConfig(int32_t slotId); 404 405 /** 406 * The IF used to get the value of operator config 407 * {@link OperatorConfig#KEY_CALL_WAITING_SERVICE_CLASS_INT} 408 * 409 * @param slotId 410 * @return std::int32_t 411 */ 412 std::int32_t GetCallWaitingServiceClassConfig(int32_t slotId); 413 414 /** 415 * The IF used to get the value of operator config 416 * {@link OperatorConfig#KEY_IMS_CALL_DISCONNECT_REASONINFO_MAPPING_STRING_ARRAY} 417 * 418 * @param slotId 419 * @return std::vector<std::string> 420 */ 421 std::vector<std::string> GetImsCallDisconnectResoninfoMappingConfig(int32_t slotId); 422 423 /** 424 * The IF used to get the value of operator config 425 * {@link OperatorConfig#KEY_FORCE_VOLTE_SWITCH_ON_BOOL} 426 * 427 * @param slotId 428 * @return bool 429 */ 430 bool GetForceVolteSwitchOnConfig(int32_t slotId); 431 432 /** 433 * Is Valid Slot Id 434 * 435 * @param slotId 436 * @return bool 437 */ 438 bool IsValidSlotId(int32_t slotId); 439 440 void SetReadyToCall(int32_t slotId, bool isReadyToCall); 441 442 bool IsReadyToCall(int32_t slotId); 443 444 /** 445 * update ims capability to modem. 446 * 447 * @param slotId 448 * @param needUpdateUtCapability update ut capability or not 449 */ 450 void UpdateImsCapabilities(int32_t slotId, bool needUpdateUtCapability, bool isOperatorConfigChanged, 451 int32_t state); 452 453 bool NeedReadThirdParyLib(); 454 455 /** 456 * On Inquire video Call Waiting 457 * 458 * @param data send data 459 * @param reply Received data 460 * @return Returns TELEPHONY_SUCCESS on success, others on failure. 461 */ 462 int32_t GetVideoCallWaiting(int32_t slotId, bool &enabled); 463 464 /** 465 * get ims switch from modem. 466 * 467 * @param slotId 468 */ 469 void GetImsSwitchStatusRequest(int32_t slotId); 470 471 /** 472 * Is volte support from ap 473 * 474 * @param slotId 475 * @return bool 476 */ 477 bool IsVolteSupport(int32_t slotId); 478 479 private: 480 static void InitDefaultOperatorConfig(); 481 EmergencyCall BuildDefaultEmergencyCall(const std::string &number, SimpresentType simType); 482 EmergencyCall BuildEmergencyCall(int32_t slotId, const EmergencyInfo &from); 483 void UniqueEccCallList(int32_t slotId, std::vector<EmergencyCall> &eccList); 484 void MergeEccCallList(int32_t slotId); 485 bool CheckAndUpdateSimState(int32_t slotId); 486 int32_t ParseAndCacheOperatorConfigs(int32_t slotId, OperatorConfig &poc); 487 void ParseBoolOperatorConfigs( 488 int32_t slotId, std::map<int32_t, bool> &config, OperatorConfig &poc, std::string configName); 489 void ResetImsSwitch(int32_t slotId); 490 void UpdateImsUtCapabilities(int32_t slotId, ImsCapabilityList &imsCapabilityList); 491 void UpdateImsVoiceCapabilities(int32_t slotId, ImsCapabilityList &imsCapabilityList); 492 bool IsGbaValid(int32_t slotId); 493 bool IsVolteProvisioned(int32_t slotId); 494 bool IsVonrSupported(int32_t slotId, bool isGbaValid); 495 bool IsVonrSupportedForImsSwitch(int32_t slotId, bool isGbaValid); 496 bool IsUtProvisioned(int32_t slotId); 497 bool IsNeedTurnOnIms(const ImsCapabilityList &imsCapabilityList); 498 bool IsSimChanged(int32_t slotId, std::string iccid); 499 int32_t SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue); 500 int32_t GetSwitchStatus(int32_t slotId); 501 void saveImsSwitchStatusToLocalForPowerOn(int32_t slotId); 502 void saveImsSwitchStatusToLocal(int32_t slotId, int32_t imsSwitchStatus); 503 void SaveVoNRState(int32_t slotId, int32_t state); 504 int32_t ObtainVoNRState(int32_t slotId); 505 void UpdateEccNumberList(int32_t slotId); 506 void GetEccListFromResult(const std::vector<EccNum> &eccVec, 507 std::vector<std::string> &callListWithCard, std::vector<std::string> &callListNoCard); 508 int32_t CheckHomeAndPresentState(int32_t slotId, bool &isHoamAndPresent); 509 bool GetRoamingState(int32_t slotId); 510 511 private: 512 static std::map<int32_t, int32_t> modeTempMap_; 513 static std::map<int32_t, int32_t> modeMap_; 514 static std::map<int32_t, std::vector<EmergencyCall>> eccListRadioMap_; 515 static std::vector<EmergencyCall> eccList3gppHasSim_; 516 static std::vector<EmergencyCall> eccList3gppNoSim_; 517 static std::map<int32_t, std::vector<EmergencyCall>> allEccList_; 518 static std::map<int32_t, int32_t> simState_; 519 static std::map<int32_t, std::string> curPlmn_; 520 static std::shared_mutex simStateLock_; 521 static std::shared_mutex mutex_; 522 static std::mutex operatorMutex_; 523 ConfigRequest configRequest_; 524 static std::map<int32_t, bool> imsSwitchOnByDefault_; 525 static std::map<int32_t, bool> hideImsSwitch_; 526 static std::map<int32_t, bool> volteSupported_; 527 static std::map<int32_t, bool> carrierVtAvailable_; 528 static std::map<int32_t, std::vector<int32_t>> nrModeSupportedList_; 529 static std::map<int32_t, bool> volteProvisioningSupported_; 530 static std::map<int32_t, bool> ssOverUtSupported_; 531 static std::map<int32_t, bool> imsGbaRequired_; 532 static std::map<int32_t, bool> utProvisioningSupported_; 533 static std::map<int32_t, bool> imsPreferForEmergency_; 534 static std::map<int32_t, int32_t> callWaitingServiceClass_; 535 static std::map<int32_t, std::vector<std::string>> imsCallDisconnectResoninfoMapping_; 536 static std::map<int32_t, bool> forceVolteSwitchOn_; 537 static std::map<int32_t, bool> videoCallWaiting_; 538 static std::map<int32_t, bool> readyToCall_; 539 static std::map<int32_t, int32_t> vonrSwithStatus_; 540 static bool isOperatorConfigInit_; 541 struct cellularNetworkState { 542 bool isInService_ = false; 543 bool isRoaming_ = false; 544 }; 545 static std::map<int32_t, cellularNetworkState> networkServiceState_; 546 }; 547 } // namespace Telephony 548 } // namespace OHOS 549 #endif // CELLULAR_CALL_CONFIG_H 550