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_CONF_H 17 #define OHOS_OPERATOR_CONF_H 18 19 #include <libxml/parser.h> 20 #include <libxml/xmlmemory.h> 21 #include <vector> 22 23 #include "common_event.h" 24 #include "common_event_manager.h" 25 #include "config_policy_utils.h" 26 #include "datashare_helper.h" 27 #include "datashare_predicates.h" 28 #include "datashare_result_set.h" 29 #include "datashare_values_bucket.h" 30 #include "event_handler.h" 31 #include "inner_event.h" 32 #include "iremote_broker.h" 33 #include "iservice_registry.h" 34 #include "operator_config_cache.h" 35 #include "sim_constant.h" 36 #include "sim_file_manager.h" 37 #include "system_ability_definition.h" 38 #include "telephony_log_wrapper.h" 39 #include "want.h" 40 41 namespace OHOS { 42 namespace Telephony { 43 static const std::string OPKEY_URI = "datashare:///com.ohos.opkeyability"; 44 const std::string OPKEY_INFO_URI = "datashare:///com.ohos.opkeyability/opkey/opkey_info"; 45 const std::string SIM_INFO_URI = "datashare:///com.ohos.simability/sim/sim_info"; 46 47 class OperatorConfigLoader { 48 public: 49 explicit OperatorConfigLoader( 50 std::weak_ptr<SimFileManager> simFileManager, std::shared_ptr<OperatorConfigCache> operatorConfigCache); 51 virtual ~OperatorConfigLoader(); 52 OperatorConfig LoadOperatorConfig(int32_t slotId); 53 int InitOpKeyData(); 54 55 private: 56 std::string LoadOpKeyOnMccMnc(int32_t slotId); 57 std::shared_ptr<DataShare::DataShareHelper> CreateOpKeyHelper() const; 58 std::shared_ptr<DataShare::DataShareHelper> CreateSimHelper() const; 59 std::string GetOpKey(std::shared_ptr<DataShare::DataShareResultSet> resultSet, int32_t slotId); 60 bool MatchOperatorRule(std::shared_ptr<DataShare::DataShareResultSet> &resultSet, int row); 61 void SetMatchResultToSimFileManager(std::string opKeyVal, std::string opNameVal, std::string opKeyExtVal, 62 int32_t slotId, std::shared_ptr<SimFileManager> simFileManager); 63 int InsertOpkeyToSimDb(std::string opKeyVal); 64 65 private: 66 std::weak_ptr<SimFileManager> simFileManager_; 67 std::shared_ptr<OperatorConfigCache> operatorConfigCache_ = nullptr; 68 std::string iccidFromSim_; 69 std::string imsiFromSim_; 70 std::string spnFromSim_; 71 std::string gid1FromSim_; 72 std::string gid2FromSim_; 73 std::string mccmncFromSim_; 74 }; 75 } // namespace Telephony 76 } // namespace OHOS 77 #endif // OHOS_OPERATOR_CONF_H 78