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