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 class OperatorConfigCache : public TelEventHandler { 26 public: 27 explicit OperatorConfigCache(std::weak_ptr<SimFileManager> simFileManager, int32_t slotId); 28 virtual ~OperatorConfigCache() = default; 29 void ClearAllCache(int32_t slotId); 30 void ClearMemoryCache(int32_t slotId); 31 void ClearOperatorValue(int32_t slotId); 32 int32_t LoadOperatorConfig(int32_t slotId, OperatorConfig &poc, int32_t state = 0); 33 int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc); 34 int32_t UpdateOperatorConfigs(int32_t slotId); 35 std::string EncryptIccId(const std::string iccid); 36 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 37 bool RegisterForIccChange(); 38 bool UnRegisterForIccChange(); 39 bool IsNeedOperatorLoad(int32_t slotId); 40 41 private: 42 OperatorFileParser parser_; 43 std::weak_ptr<SimFileManager> simFileManager_; 44 std::string GetOpKey(int32_t slotId); 45 void CopyOperatorConfig(const OperatorConfig &from, OperatorConfig &to); 46 void UpdateCurrentOpc(int32_t slotId, OperatorConfig &poc, int32_t state, bool needUpdateLoading); 47 void SendSimMatchedOperatorInfo(int32_t slotId); 48 bool AnnounceOperatorConfigChanged(int32_t slotId, int32_t state); 49 void notifyInitApnConfigs(int32_t slotId); 50 inline static const std::string KEY_SLOTID = "slotId"; 51 inline static const std::string CHANGE_STATE = "state"; 52 inline static const int32_t STATE_PARA_UPDATE = 3; 53 inline static const std::string OPERATOR_CONFIG_CHANGED = "operatorConfigChanged"; 54 OperatorConfig opc_; 55 int32_t slotId_; 56 bool isLoadingConfig = false; 57 std::mutex mutex_; 58 }; 59 } // namespace Telephony 60 } // namespace OHOS 61 #endif // OHOS_OPERATOR_FILE_PARSER_H 62