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