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