• 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     SimFile(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 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     void UpdateMsisdnNumber(
34         const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete);
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 
40 protected:
41     enum SpnStatus {
42         OBTAIN_SPN_NONE,
43         OBTAIN_SPN_START,
44         OBTAIN_SPN_GENERAL,
45         OBTAIN_OPERATOR_NAMESTRING,
46         OBTAIN_OPERATOR_NAME_SHORTFORM
47     };
48     void ProcessIccRefresh(int msgId);
49     void ProcessFileLoaded(bool response);
50     void OnAllFilesFetched();
51     void LoadSimFiles();
52     bool ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event);
53     void ObtainCallForwardFiles();
54     void UpdateSimLanguage();
55     int callForwardStatus_ = 0;
56     std::string cphsInfo_ = IccFileController::NULLSTR;
57     bool cspPlmnOn_ = false;
58     unsigned char *efMWIS_ = nullptr;
59     unsigned char *efCphsMwi_ = nullptr;
60     unsigned char *efCff_ = nullptr;
61     unsigned char *efCfis_ = nullptr;
62     std::string efLi_ = IccFileController::NULLSTR;
63     std::string efPl_ = IccFileController::NULLSTR;
64     SpnStatus spnStatus_ = OBTAIN_SPN_NONE;
65     int displayConditionOfSpn_ = 0;
66     std::vector<std::string> spdiNetworks_;
67     std::shared_ptr<UsimFunctionHandle> UsimFunctionHandle_ = nullptr;
68 
69 private:
70     using FileProcessFunc = bool (SimFile::*)(const AppExecFwk::InnerEvent::Pointer &event);
71     std::map<int, FileProcessFunc> memberFuncMap_;
72     void InitMemberFunc();
73     void ObtainSpnPhase(bool start, const AppExecFwk::InnerEvent::Pointer &event);
74     std::string AnalysisBcdPlmn(std::string data, std::string description);
75     void ProcessElementaryFileCsp(std::string data);
76     void AnalysisElementaryFileSpdi(std::string data);
77     void ProcessSmses(std::string messages);
78     void ProcessSms(std::string data);
79 
80     void ProcessSpnGeneral(const AppExecFwk::InnerEvent::Pointer &event);
81     void ProcessSpnCphs(const AppExecFwk::InnerEvent::Pointer &event);
82     void ProcessSpnShortCphs(const AppExecFwk::InnerEvent::Pointer &event);
83     bool ProcessGetAdDone(const AppExecFwk::InnerEvent::Pointer &event);
84     bool ProcessVoiceMailCphs(const AppExecFwk::InnerEvent::Pointer &event);
85     bool ProcessGetMwisDone(const AppExecFwk::InnerEvent::Pointer &event);
86     bool ProcessGetMbdnDone(const AppExecFwk::InnerEvent::Pointer &event);
87     bool ProcessGetCphsMailBoxDone(const AppExecFwk::InnerEvent::Pointer &event);
88     bool ProcessGetMbiDone(const AppExecFwk::InnerEvent::Pointer &event);
89     bool ProcessGetCfisDone(const AppExecFwk::InnerEvent::Pointer &event);
90     bool ProcessGetCffDone(const AppExecFwk::InnerEvent::Pointer &event);
91     bool ProcessObtainIMSIDone(const AppExecFwk::InnerEvent::Pointer &event);
92     bool ProcessGetIccIdDone(const AppExecFwk::InnerEvent::Pointer &event);
93     bool ProcessGetPlmnActDone(const AppExecFwk::InnerEvent::Pointer &event);
94     bool ProcessGetOplmnActDone(const AppExecFwk::InnerEvent::Pointer &event);
95     bool ProcessGetSpdiDone(const AppExecFwk::InnerEvent::Pointer &event);
96     bool ProcessGetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event);
97     bool ProcessSetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event);
98     bool ProcessObtainGid1Done(const AppExecFwk::InnerEvent::Pointer &event);
99     bool ProcessObtainGid2Done(const AppExecFwk::InnerEvent::Pointer &event);
100     bool ProcessSmsOnSim(const AppExecFwk::InnerEvent::Pointer &event);
101     bool ProcessGetCspCphs(const AppExecFwk::InnerEvent::Pointer &event);
102     bool ProcessGetInfoCphs(const AppExecFwk::InnerEvent::Pointer &event);
103     bool ProcessGetSstDone(const AppExecFwk::InnerEvent::Pointer &event);
104     bool ProcessGetSmsDone(const AppExecFwk::InnerEvent::Pointer &event);
105     bool ProcessGetAllSmsDone(const AppExecFwk::InnerEvent::Pointer &event);
106     bool ProcessGetHplmActDone(const AppExecFwk::InnerEvent::Pointer &event);
107     bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
108     bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event);
109     bool ProcessGetOplDone(const AppExecFwk::InnerEvent::Pointer &event);
110     bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event);
111     bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event);
112     bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event);
113     bool ProcessSetMbdn(const AppExecFwk::InnerEvent::Pointer &event);
114     bool ProcessMarkSms(const AppExecFwk::InnerEvent::Pointer &event);
115     bool ProcessObtainSpnPhase(const AppExecFwk::InnerEvent::Pointer &event);
116     bool ProcessObtainLiLanguage(const AppExecFwk::InnerEvent::Pointer &event);
117     bool ProcessObtainPlLanguage(const AppExecFwk::InnerEvent::Pointer &event);
118     void StartObtainSpn();
119 
120     void CheckMncLength();
121     bool IsContinueGetSpn(bool start, SpnStatus curStatus, SpnStatus &newStatus);
122     const int MCC_LEN = 3;
123     const int MNC_LEN = 2;
124     const int MCCMNC_LEN = 6;
125     const int LOAD_STEP = 1;
126     const int INVALID_BYTES_NUM = 1;
127     const int SPN_CHAR_POS = 0;
128     const int MAIL_DELAY_TIME = 50 * 1000;
129     static const uint8_t CPHS_VOICE_MAIL_MASK = 0x30;
130     static const uint8_t CPHS_VOICE_MAIL_EXSIT = 0x30;
131     int ObtainExtensionElementaryFile(int ef);
132     bool CphsVoiceMailAvailable();
133     void GetCphsMailBox();
134     std::string ParseSpn(const std::string &rawData, int curState);
135     void ParsePnn(const std::vector<std::string> &records);
136     void ParseOpl(const std::vector<std::string> &records);
137 };
138 } // namespace Telephony
139 } // namespace OHOS
140 
141 #endif // OHOS_SIM_FILE_H