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); 33 int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc); 34 std::string EncryptIccId(const std::string iccid); 35 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 36 bool RegisterForIccChange(); 37 bool UnRegisterForIccChange(); 38 39 private: 40 OperatorFileParser parser_; 41 std::weak_ptr<SimFileManager> simFileManager_; 42 std::string GetOpKey(int32_t slotId); 43 void CopyOperatorConfig(const OperatorConfig &from, OperatorConfig &to); 44 void SendSimMatchedOperatorInfo(int32_t slotId); 45 bool AnnounceOperatorConfigChanged(int32_t slotId); 46 inline static const std::string KEY_SLOTID = "slotId"; 47 inline static const std::string OPERATOR_CONFIG_CHANGED = "operatorConfigChanged"; 48 OperatorConfig opc_; 49 int32_t slotId_; 50 std::mutex mutex_; 51 }; 52 } // namespace Telephony 53 } // namespace OHOS 54 #endif // OHOS_OPERATOR_FILE_PARSER_H 55