• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 TELEPHONY_SIMSTATETRACKER_H
17 #define TELEPHONY_SIMSTATETRACKER_H
18 
19 #include <string>
20 
21 #include "operator_config_cache.h"
22 #include "operator_config_loader.h"
23 #include "system_ability_status_change_stub.h"
24 #include "telephony_log_wrapper.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class SimStateTracker : public AppExecFwk::EventHandler {
29 public:
30     SimStateTracker(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
31         std::shared_ptr<SimFileManager> simFileManager, std::shared_ptr<OperatorConfigCache> operatorConfigCache,
32         int32_t slotId);
33     virtual ~SimStateTracker() = default;
34     void InitListener();
35     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
36     bool RegisterForIccLoaded();
37     bool UnRegisterForIccLoaded();
38 
39     std::shared_ptr<OperatorConfigLoader> operatorConfigLoader_ = nullptr;
40 
41 private:
42     inline static const std::string OPERATOR_CONFIG_CHANGED = "operatorConfigChanged";
43     std::shared_ptr<SimFileManager> simFileManager_ = nullptr;
44     sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr;
45     std::shared_ptr<OperatorConfigCache> operatorConfigCache_ = nullptr;
46     int32_t slotId_;
47     OperatorConfig config_;
48 
49 private:
50     class SystemAbilityStatusChangeListener : public OHOS::SystemAbilityStatusChangeStub {
51     public:
52         explicit SystemAbilityStatusChangeListener(int32_t slotId, std::shared_ptr<OperatorConfigLoader> configLoader);
53         ~SystemAbilityStatusChangeListener() = default;
54         virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
55         virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
56 
57     private:
58         const int32_t slotId_;
59         std::shared_ptr<OperatorConfigLoader> configLoader_ = nullptr;
60     };
61 };
62 } // namespace Telephony
63 } // namespace OHOS
64 #endif // TELEPHONY_SIMSTATETRACKER_H