• 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 OHOS_SIM_FILE_MANAGER_H
17 #define OHOS_SIM_FILE_MANAGER_H
18 
19 #include "event_handler.h"
20 #include "event_runner.h"
21 #include "hril_modem_parcel.h"
22 #include "sim_file_controller.h"
23 #include "usim_file_controller.h"
24 #include "i_tel_ril_manager.h"
25 #include "ruim_file.h"
26 #include "ruim_file_controller.h"
27 #include "sim_file.h"
28 #include "isim_file.h"
29 #include "isim_file_controller.h"
30 #include "csim_file_controller.h"
31 #include "telephony_log_wrapper.h"
32 
33 namespace OHOS {
34 namespace Telephony {
35 class SimFileManager : public AppExecFwk::EventHandler {
36 public:
37     using HANDLE = std::shared_ptr<AppExecFwk::EventHandler>;
38     SimFileManager(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
39         std::shared_ptr<Telephony::ITelRilManager> telRilManager,
40         std::shared_ptr<Telephony::SimStateManager> state);
41     virtual ~SimFileManager();
42     void Init(int slotId);
43     std::u16string GetSimOperatorNumeric();
44     std::u16string GetISOCountryCodeForSim();
45     std::u16string GetSimSpn();
46     std::u16string GetSimIccId();
47     std::u16string GetIMSI();
48     std::u16string GetLocaleFromDefaultSim();
49     std::u16string GetSimGid1();
50     std::u16string GetSimTelephoneNumber();
51     std::u16string GetSimTeleNumberIdentifier();
52     std::u16string GetVoiceMailIdentifier();
53     std::u16string GetVoiceMailNumber();
54     int ObtainSpnCondition(bool roaming, std::string operatorNum);
55     void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what);
56     void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what);
57     void SetImsi(std::string imsi);
58     std::shared_ptr<IccFile> GetIccFile();
59     std::shared_ptr<IccFileController> GetIccFileController();
60     std::shared_ptr<IccDiallingNumbersHandler> ObtainDiallingNumberHandler();
61     bool SetVoiceMailInfo(const std::u16string &mailName, const std::u16string &mailNumber);
62     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
63     static std::shared_ptr<SimFileManager> CreateInstance(
64         const std::shared_ptr<Telephony::ITelRilManager> &ril,
65         const std::shared_ptr<SimStateManager> &simState);
66     enum class HandleRunningState { STATE_NOT_START, STATE_RUNNING };
67     enum class IccType { ICC_TYPE_CDMA, ICC_TYPE_GSM, ICC_TYPE_IMS, ICC_TYPE_USIM };
68 
69 protected:
70     std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr;
71     std::shared_ptr<IccFileController> fileController_ = nullptr;
72     std::shared_ptr<IccFile> simFile_ = nullptr;
73     std::shared_ptr<IccDiallingNumbersHandler> diallingNumberHandler_ = nullptr;
74     std::shared_ptr<AppExecFwk::EventRunner> eventLoopRecord_ = nullptr;
75     std::shared_ptr<AppExecFwk::EventRunner> eventLoopFileController_ = nullptr;
76     HandleRunningState stateRecord_ = HandleRunningState::STATE_NOT_START;
77     HandleRunningState stateHandler_ = HandleRunningState::STATE_NOT_START;
78     std::shared_ptr<Telephony::SimStateManager> simStateManager_ = nullptr;
79     int slotId_ = 0;
80     IccType iccType_ = IccType::ICC_TYPE_USIM;
81     std::map<IccType, std::shared_ptr<IccFile>> iccFileCache_;
82     std::map<IccType, std::shared_ptr<IccFileController>> iccFileControllerCache_;
83 
84 private:
85     bool InitDiallingNumberHandler();
86     IccType GetIccTypeByCardType(CardType type);
87     IccType GetIccTypeByTech(const std::shared_ptr<VoiceRadioTechnology> &tech);
88     bool InitSimFile(IccType type);
89     bool InitIccFileController(IccType type);
90     void ChangeSimFileByCardType(IccType type);
91     bool IsValidType(IccType type);
92 };
93 } // namespace Telephony
94 } // namespace OHOS
95 #endif // OHOS_SIM_FILE_MANAGER_H
96