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