1 /* 2 * Copyright (C) 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 OHOS_OPERATOR_CONFIG_CACHE_H 17 #define OHOS_OPERATOR_CONFIG_CACHE_H 18 #include "core_service_errors.h" 19 #include "operator_file_parser.h" 20 #include "sim_file_manager.h" 21 #include "telephony_log_wrapper.h" 22 23 namespace OHOS { 24 namespace Telephony { 25 const std::string KEY_CONST_TELEPHONY_IS_USE_CLOUD_IMS_NV = "const.telephony.is_use_cloud_ims_nv"; 26 const std::string KEY_PERSIST_TELEPHONY_VOLTE_CAP_IN_CHIP = "persist.telephony.volte_cap_in_chip_slot"; 27 class OperatorConfigCache : public TelEventHandler { 28 public: 29 explicit OperatorConfigCache(std::weak_ptr<SimFileManager> simFileManager, int32_t slotId); 30 virtual ~OperatorConfigCache() = default; 31 void ClearAllCache(int32_t slotId); 32 void ClearMemoryCache(int32_t slotId); 33 void ClearOperatorValue(int32_t slotId); 34 void ClearMemoryAndOpkey(int32_t slotId); 35 int32_t LoadOperatorConfig(int32_t slotId, OperatorConfig &poc, int32_t state = 0); 36 int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc); 37 int32_t UpdateOperatorConfigs(int32_t slotId); 38 std::string EncryptIccId(const std::string iccid); 39 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 40 bool RegisterForIccChange(); 41 bool UnRegisterForIccChange(); 42 bool IsNeedOperatorLoad(int32_t slotId); 43 inline static const int32_t STATE_PARA_LOADED = 1; 44 inline static const int32_t STATE_PARA_CLEAR = 2; 45 inline static const int32_t STATE_PARA_UPDATE = 3; 46 inline static const int32_t STATE_COTA_UPDATE = 4; 47 void UpdateImsCapFromChip(int32_t slotId, const ImsCapFromChip &imsCapFromChip); 48 void UpdatevolteCap(int32_t slotId, OperatorConfig &opc); 49 void UpdateOpcBoolValue(OperatorConfig &opc, const std::string &key, const bool value); 50 51 private: 52 OperatorFileParser parser_; 53 std::weak_ptr<SimFileManager> simFileManager_; 54 std::string GetOpKey(int32_t slotId); 55 void CopyOperatorConfig(const OperatorConfig &from, OperatorConfig &to); 56 void UpdateCurrentOpc(int32_t slotId, OperatorConfig &poc); 57 void SendSimMatchedOperatorInfo(int32_t slotId, int32_t state); 58 bool AnnounceOperatorConfigChanged(int32_t slotId, int32_t state); 59 void notifyInitApnConfigs(int32_t slotId); 60 int32_t LoadOperatorConfigFile(int32_t slotId, OperatorConfig &poc); 61 inline static const std::string KEY_SLOTID = "slotId"; 62 inline static const std::string CHANGE_STATE = "state"; 63 inline static const int32_t IMS_SWITCH_OFF = 0; 64 inline static const int32_t IMS_SWITCH_ON = 1; 65 inline static const int32_t IMS_SWITCH_DEFAULT = 2; 66 inline static const std::string OPERATOR_CONFIG_CHANGED = "operatorConfigChanged"; 67 OperatorConfig opc_; 68 int32_t slotId_; 69 std::string modemSimMatchedOpNameCache_ = ""; 70 bool isLoadingConfig_ = false; 71 std::mutex mutex_; 72 bool isUpdateImsCapFromChipDone_ = false; 73 }; 74 } // namespace Telephony 75 } // namespace OHOS 76 #endif // OHOS_OPERATOR_FILE_PARSER_H 77