• 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_ICC_FILE_H
17 #define OHOS_ICC_FILE_H
18 
19 #include "event_handler.h"
20 #include "event_runner.h"
21 #include "i_tel_ril_manager.h"
22 #include "mcc_pool.h"
23 #include "observer_handler.h"
24 #include "plmn_file.h"
25 #include "sim_constant.h"
26 #include "icc_file_controller.h"
27 #include "sim_state_manager.h"
28 #include "telephony_log_wrapper.h"
29 #include "usim_function_handle.h"
30 #include "common_event.h"
31 #include "common_event_manager.h"
32 #include "want.h"
33 #include "icc_dialling_numbers_handler.h"
34 
35 namespace OHOS {
36 namespace Telephony {
37 class IccFile : public AppExecFwk::EventHandler {
38 public:
39     IccFile(
40         const std::shared_ptr<AppExecFwk::EventRunner> &runner, std::shared_ptr<SimStateManager> simStateManager);
41     virtual void Init();
42     virtual void StartLoad();
43     std::string ObtainIMSI();
44     void UpdateImsi(std::string imsi);
45     std::string ObtainIccId();
46     std::string ObtainGid1();
47     std::string ObtainGid2();
48     std::string ObtainMsisdnNumber();
49     virtual std::string ObtainSimOperator();
50     virtual std::string ObtainIsoCountryCode();
51     virtual int ObtainCallForwardStatus();
52     virtual int ObtainSpnCondition(bool roaming, const std::string &operatorNum) = 0;
53     bool LoadedOrNot();
54     void UpdateLoaded(bool loaded);
55     virtual void UpdateMsisdnNumber(
56         const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete);
57     virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
58     virtual ~IccFile();
59     virtual bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event) = 0;
60     std::string ObtainDiallingNumberInfo();
61     std::string ObtainNAI();
62     std::string ObtainHomeNameOfPnn();
63     std::string ObtainMsisdnAlphaStatus();
64     std::string ObtainVoiceMailNumber();
65     std::string ObtainSPN();
66     std::string ObtainVoiceMailInfo();
67     bool ObtainFilesFetched();
68     std::string ObtainIccLanguage();
69     virtual std::shared_ptr<UsimFunctionHandle> ObtainUsimFunctionHandle();
70     std::string ObtainSpNameFromEfSpn();
71     int ObtainLengthOfMnc();
72     virtual void RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what);
73     virtual void UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what);
74     void SetRilAndFileController(const std::shared_ptr<Telephony::ITelRilManager> &ril,
75          const std::shared_ptr<IccFileController> &file, const std::shared_ptr<IccDiallingNumbersHandler> &handler);
76     struct IccFileLoaded {
77         virtual std::string ObtainElementaryFileName() = 0;
78         virtual void ProcessParseFile(const AppExecFwk::InnerEvent::Pointer &event) = 0;
79     };
80     virtual bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber) = 0;
81     bool HasSimCard();
82     virtual void UnInit();
SetId(int id)83     void SetId(int id)
84     {
85         slotId_ = id;
86     }
87 
88 protected:
89     virtual void ProcessIccRefresh(int msgId) = 0;
90     virtual void ProcessFileLoaded(bool response) = 0;
91     virtual void OnAllFilesFetched() = 0;
92     bool LockQueriedOrNot();
93     void UpdateSPN(const std::string spn);
94     std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr;
95     std::shared_ptr<IccFileController> fileController_ = nullptr;
96     std::shared_ptr<SimStateManager> stateManager_ = nullptr;
97     std::string imsi_ = "";
98     std::string iccId_ = ""; // decimals
99     std::string spn_ = "";
100     std::string gid1_ = "";
101     std::string gid2_ = "";
102     std::string msisdn_ = "";
103     std::string msisdnTag_ = "";
104     std::string lastMsisdn_ = "";
105     std::string lastMsisdnTag_ = "";
106     std::string voiceMailNum_ = "";
107     std::string voiceMailTag_ = "";
108     std::string lastVoiceMailNum_ = "";
109     std::string lastVoiceMailTag_ = "";
110     std::string operatorNumeric_ = "";
111     bool voiceMailFixedOrNot_ = false;
112     std::string pnnHomeName_ = "";
113     std::string iccLanguage_ = "";
114     PlmnFile *hplmnRAT_ = nullptr;
115     PlmnFile *oplmnRAT_ = nullptr;
116     PlmnFile *plmnRAT_ = nullptr;
117     std::string ehplmns_ = "";
118     std::string fplmns_ = "";
119     int lengthOfMnc_ = DEFAULT_MNC;
120     int indexOfMailbox_ = 1;
121     int fileToGet_ = 0;
122     bool loaded_ = false;
123     bool fileQueried_ = false;
124     bool lockQueried_ = false;
125     bool waitResult_ = false;
126     static std::mutex mtx_;
127     std::condition_variable processWait_;
128     const uint8_t BYTE_NUM = 0xff;
129     const int DATA_STEP = 2;
130     const std::string SIM_STATE_ACTION = "com.hos.action.SIM_STATE_CHANGED";
131     static std::unique_ptr<ObserverHandler> filesFetchedObser_;
132     std::unique_ptr<ObserverHandler> lockedFilesFetchedObser_ = nullptr;
133     std::unique_ptr<ObserverHandler> networkLockedFilesFetchedObser_ = nullptr;
134     std::unique_ptr<ObserverHandler> imsiReadyObser_ = nullptr;
135     std::unique_ptr<ObserverHandler> recordsEventsObser_ = nullptr;
136     std::unique_ptr<ObserverHandler> networkSelectionModeAutomaticObser_ = nullptr;
137     std::unique_ptr<ObserverHandler> spnUpdatedObser_ = nullptr;
138     std::unique_ptr<ObserverHandler> recordsOverrideObser_ = nullptr;
139     virtual AppExecFwk::InnerEvent::Pointer BuildCallerInfo(int eventId);
140     virtual AppExecFwk::InnerEvent::Pointer BuildCallerInfo(int eventId, int arg1, int arg2);
141     virtual AppExecFwk::InnerEvent::Pointer BuildCallerInfo(int eventId, std::shared_ptr<void> loader);
142     bool PublishSimFileEvent(const std::string &event, int eventCode, const std::string &eventData);
143     void UpdateIccLanguage(const std::string &langLi, const std::string &langPl);
144     std::string ObtainValidLanguage(const std::string &langData);
145     std::shared_ptr<IccDiallingNumbersHandler> diallingNumberHandler_ = nullptr;
146     AppExecFwk::InnerEvent::Pointer CreateDiallingNumberPointer(
147         int eventid, int efId, int index, std::shared_ptr<void> pobj);
148     void NotifyRegistrySimState(CardType type, SimState state, LockReason reason);
149     int slotId_ = 0;
150 
151 private:
152     bool ProcessIccFileObtained(const AppExecFwk::InnerEvent::Pointer &event);
153     void RegisterImsiLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler);
154     void UnregisterImsiLoaded(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
155     void RegisterAllFilesLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler);
156     void UnregisterAllFilesLoaded(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
157 };
158 } // namespace Telephony
159 } // namespace OHOS
160 
161 #endif // OHOS_ICC_FILE_H
162