• 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 "telephony_log_wrapper.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 class OperatorConfigCache : public AppExecFwk::EventHandler {
26 public:
27     explicit OperatorConfigCache(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
28         std::shared_ptr<SimFileManager> simFileManager, int32_t slotId);
29     virtual ~OperatorConfigCache() = default;
30     void ClearAllCache(int32_t slotId);
31     void ClearMemoryCache(int32_t slotId);
32     void ClearOperatorValue(int32_t slotId);
33     int32_t LoadOperatorConfig(int32_t slotId, OperatorConfig &poc);
34     int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc);
35     std::string EncryptIccId(const std::string iccid);
36     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
37     bool RegisterForIccChange();
38     bool UnRegisterForIccChange();
39 
40 private:
41     OperatorFileParser parser_;
42     std::shared_ptr<SimFileManager> simFileManager_ = nullptr;
43     std::string GetOpKey(int32_t slotId);
44     void CopyOperatorConfig(const OperatorConfig &from, OperatorConfig &to);
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