• 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_H
17 #define OHOS_SIM_FILE_H
18 
19 #include "icc_file.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 class SimFile : public IccFile {
24 public:
25     explicit SimFile(std::shared_ptr<SimStateManager> simStateManager);
26     void StartLoad();
27     std::string ObtainMsisdnNumber();
28     std::string ObtainSimOperator();
29     std::string ObtainIsoCountryCode();
30     int ObtainSpnCondition(bool roaming, const std::string &operatorNum);
31     int ObtainCallForwardStatus();
32     std::shared_ptr<UsimFunctionHandle> ObtainUsimFunctionHandle();
33     bool UpdateMsisdnNumber(
34         const std::string &alphaTag, const std::string &number);
35     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
36     ~SimFile() = default;
37     bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event);
38     bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber);
39     bool SetVoiceMailCount(int32_t voiceMailCount);
40     bool SetVoiceCallForwarding(bool enable, const std::string &number);
41     void ProcessIccRefresh(int msgId);
42     std::string GetVoiceMailNumber();
43     void SetVoiceMailNumber(const std::string mailNumber);
44 
45 protected:
46     enum SpnStatus {
47         OBTAIN_SPN_NONE,
48         OBTAIN_SPN_START,
49         OBTAIN_SPN_GENERAL,
50         OBTAIN_OPERATOR_NAMESTRING,
51         OBTAIN_OPERATOR_NAME_SHORTFORM
52     };
53     void ProcessFileLoaded(bool response);
54     void OnAllFilesFetched();
55     void LoadSimFiles();
56     bool ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event);
57     void ObtainCallForwardFiles();
58     void UpdateSimLanguage();
59     int callForwardStatus_ = 0;
60     std::string cphsInfo_ = IccFileController::NULLSTR;
61     bool cspPlmnOn_ = false;
62     unsigned char *efMWIS_ = nullptr;
63     unsigned char *efCphsMwi_ = nullptr;
64     unsigned char *efCff_ = nullptr;
65     unsigned char *efCfis_ = nullptr;
66     std::string efMWISStr_;
67     std::string efCphsMwisStr_;
68     std::string efCffStr_;
69     std::string efCfisStr_;
70     std::string efLi_ = IccFileController::NULLSTR;
71     std::string efPl_ = IccFileController::NULLSTR;
72     SpnStatus spnStatus_ = OBTAIN_SPN_NONE;
73     int displayConditionOfSpn_ = 0;
74     std::vector<std::string> spdiNetworks_;
75     std::shared_ptr<UsimFunctionHandle> UsimFunctionHandle_ = nullptr;
76 
77 private:
78     using FileProcessFunc = bool (SimFile::*)(const AppExecFwk::InnerEvent::Pointer &event);
79     std::map<int, FileProcessFunc> memberFuncMap_;
80     void InitMemberFunc();
81     void ObtainSpnPhase(bool start, const AppExecFwk::InnerEvent::Pointer &event);
82     std::string AnalysisBcdPlmn(std::string data, std::string description);
83     void ProcessElementaryFileCsp(std::string data);
84     void AnalysisElementaryFileSpdi(std::string data);
85     void ProcessSmses(std::string messages);
86     void ProcessSms(std::string data);
87 
88     void ProcessSpnGeneral(const AppExecFwk::InnerEvent::Pointer &event);
89     void ProcessSpnCphs(const AppExecFwk::InnerEvent::Pointer &event);
90     void ProcessSpnShortCphs(const AppExecFwk::InnerEvent::Pointer &event);
91     bool ProcessGetAdDone(const AppExecFwk::InnerEvent::Pointer &event);
92     bool ProcessVoiceMailCphs(const AppExecFwk::InnerEvent::Pointer &event);
93     bool ProcessGetMwisDone(const AppExecFwk::InnerEvent::Pointer &event);
94     bool ProcessGetMbdnDone(const AppExecFwk::InnerEvent::Pointer &event);
95     bool ProcessGetCphsMailBoxDone(const AppExecFwk::InnerEvent::Pointer &event);
96     bool ProcessGetMbiDone(const AppExecFwk::InnerEvent::Pointer &event);
97     bool ProcessGetCfisDone(const AppExecFwk::InnerEvent::Pointer &event);
98     bool ProcessGetCffDone(const AppExecFwk::InnerEvent::Pointer &event);
99     bool ProcessObtainIMSIDone(const AppExecFwk::InnerEvent::Pointer &event);
100     bool ProcessGetIccIdDone(const AppExecFwk::InnerEvent::Pointer &event);
101     bool ProcessGetPlmnActDone(const AppExecFwk::InnerEvent::Pointer &event);
102     bool ProcessGetOplmnActDone(const AppExecFwk::InnerEvent::Pointer &event);
103     bool ProcessGetSpdiDone(const AppExecFwk::InnerEvent::Pointer &event);
104     bool ProcessGetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event);
105     bool ProcessSetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event);
106     bool ProcessObtainGid1Done(const AppExecFwk::InnerEvent::Pointer &event);
107     bool ProcessObtainGid2Done(const AppExecFwk::InnerEvent::Pointer &event);
108     bool ProcessSmsOnSim(const AppExecFwk::InnerEvent::Pointer &event);
109     bool ProcessGetCspCphs(const AppExecFwk::InnerEvent::Pointer &event);
110     bool ProcessGetInfoCphs(const AppExecFwk::InnerEvent::Pointer &event);
111     bool ProcessGetSstDone(const AppExecFwk::InnerEvent::Pointer &event);
112     bool ProcessGetSmsDone(const AppExecFwk::InnerEvent::Pointer &event);
113     bool ProcessGetAllSmsDone(const AppExecFwk::InnerEvent::Pointer &event);
114     bool ProcessGetHplmActDone(const AppExecFwk::InnerEvent::Pointer &event);
115     bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
116     bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event);
117     bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event);
118     bool ProcessGetOpl5gDone(const AppExecFwk::InnerEvent::Pointer &event);
119     bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event);
120     bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event);
121     bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
122     bool ProcessSetMbdn(const AppExecFwk::InnerEvent::Pointer &event);
123     bool ProcessMarkSms(const AppExecFwk::InnerEvent::Pointer &event);
124     bool ProcessObtainSpnPhase(const AppExecFwk::InnerEvent::Pointer &event);
125     bool ProcessObtainLiLanguage(const AppExecFwk::InnerEvent::Pointer &event);
126     bool ProcessObtainPlLanguage(const AppExecFwk::InnerEvent::Pointer &event);
127     void StartObtainSpn();
128 
129     void CheckMncLength();
130     bool IsContinueGetSpn(bool start, SpnStatus curStatus, SpnStatus &newStatus);
131     const int MNC_INDEX = 7;
132     const int MCC_LEN = 3;
133     const int MNC_LEN = 2;
134     const int MCCMNC_LEN = 6;
135     const int LOAD_STEP = 1;
136     const int INVALID_BYTES_NUM = 1;
137     const int SPN_CHAR_POS = 0;
138     const int MAIL_DELAY_TIME = 50 * 1000;
139     static const uint8_t CPHS_VOICE_MAIL_MASK = 0x30;
140     static const uint8_t CPHS_VOICE_MAIL_EXSIT = 0x30;
141     static const int CFIS_BCD_NUMBER_LENGTH_OFFSET = 2;
142     static const int CFIS_TON_NPI_OFFSET = 3;
143     static const int CFIS_ADN_CAPABILITY_ID_OFFSET = 14;
144     static const int CFIS_ADN_EXTENSION_ID_OFFSET = 15;
145     int ObtainExtensionElementaryFile(int ef);
146     bool CphsVoiceMailAvailable();
147     bool EfCfisAvailable(int32_t size);
148     void GetCphsMailBox();
149     std::string ParseSpn(const std::string &rawData, int curState);
150     void ParsePnn(const std::vector<std::string> &records);
151     void ParseOpl(const std::vector<std::string> &records);
152     void ParseOpl5g(const std::vector<std::string> &records);
153     bool FillNumber(std::shared_ptr<unsigned char> efCfisData, int32_t efCfisSize, const std::string &number);
154     bool VoiceMailNotEditToSim();
155 };
156 } // namespace Telephony
157 } // namespace OHOS
158 
159 #endif // OHOS_SIM_FILE_H
160