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( 26 const std::shared_ptr<AppExecFwk::EventRunner> &runner, std::shared_ptr<SimStateManager> simStateManager); 27 void Init(); 28 void StartLoad(); 29 std::string ObtainMsisdnNumber(); 30 std::string ObtainSimOperator(); 31 std::string ObtainIsoCountryCode(); 32 int ObtainSpnCondition(bool roaming, const std::string &operatorNum); 33 int ObtainCallForwardStatus(); 34 std::shared_ptr<UsimFunctionHandle> ObtainUsimFunctionHandle(); 35 void UpdateMsisdnNumber( 36 const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete); 37 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 38 ~SimFile(); 39 bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event); 40 bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber); 41 void UnInit(); 42 43 protected: 44 enum SpnStatus { 45 OBTAIN_SPN_NONE, 46 OBTAIN_SPN_START, 47 OBTAIN_SPN_GENERAL, 48 OBTAIN_OPERATOR_NAMESTRING, 49 OBTAIN_OPERATOR_NAME_SHORTFORM 50 }; 51 void ProcessIccRefresh(int msgId); 52 void ProcessFileLoaded(bool response); 53 void OnAllFilesFetched(); 54 void LoadSimFiles(); 55 bool ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event); 56 void ObtainCallForwardFiles(); 57 void UpdateSimLanguage(); 58 int callForwardStatus_ = 0; 59 std::string cphsInfo_ = IccFileController::NULLSTR; 60 bool cspPlmnOn_ = false; 61 unsigned char *efMWIS_ = nullptr; 62 unsigned char *efCphsMwi_ = nullptr; 63 unsigned char *efCff_ = nullptr; 64 unsigned char *efCfis_ = nullptr; 65 std::string efLi_ = IccFileController::NULLSTR; 66 std::string efPl_ = IccFileController::NULLSTR; 67 SpnStatus spnStatus_ = OBTAIN_SPN_NONE; 68 int displayConditionOfSpn_ = 0; 69 std::vector<std::string> spdiNetworks_; 70 std::shared_ptr<UsimFunctionHandle> UsimFunctionHandle_ = nullptr; 71 72 private: 73 using FileProcessFunc = bool (SimFile::*)(const AppExecFwk::InnerEvent::Pointer &event); 74 std::map<int, FileProcessFunc> memberFuncMap_; 75 void InitMemberFunc(); 76 void ObtainSpnPhase(bool start, const AppExecFwk::InnerEvent::Pointer &event); 77 std::string AnalysisBcdPlmn(std::string data, std::string description); 78 void ProcessElementaryFileCsp(std::string data); 79 void AnalysisElementaryFileSpdi(std::string data); 80 void ProcessSmses(std::string messages); 81 void ProcessSms(std::string data); 82 83 void ProcessSpnGeneral(const AppExecFwk::InnerEvent::Pointer &event); 84 void ProcessSpnCphs(const AppExecFwk::InnerEvent::Pointer &event); 85 void ProcessSpnShortCphs(const AppExecFwk::InnerEvent::Pointer &event); 86 bool ProcessGetAdDone(const AppExecFwk::InnerEvent::Pointer &event); 87 bool ProcessVoiceMailCphs(const AppExecFwk::InnerEvent::Pointer &event); 88 bool ProcessGetMwisDone(const AppExecFwk::InnerEvent::Pointer &event); 89 bool ProcessGetMbdnDone(const AppExecFwk::InnerEvent::Pointer &event); 90 bool ProcessGetCphsMailBoxDone(const AppExecFwk::InnerEvent::Pointer &event); 91 bool ProcessGetMbiDone(const AppExecFwk::InnerEvent::Pointer &event); 92 bool ProcessGetCfisDone(const AppExecFwk::InnerEvent::Pointer &event); 93 bool ProcessGetCffDone(const AppExecFwk::InnerEvent::Pointer &event); 94 bool ProcessObtainIMSIDone(const AppExecFwk::InnerEvent::Pointer &event); 95 bool ProcessGetIccIdDone(const AppExecFwk::InnerEvent::Pointer &event); 96 bool ProcessGetPlmnActDone(const AppExecFwk::InnerEvent::Pointer &event); 97 bool ProcessGetOplmnActDone(const AppExecFwk::InnerEvent::Pointer &event); 98 bool ProcessGetSpdiDone(const AppExecFwk::InnerEvent::Pointer &event); 99 bool ProcessGetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event); 100 bool ProcessSetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event); 101 bool ProcessObtainGid1Done(const AppExecFwk::InnerEvent::Pointer &event); 102 bool ProcessObtainGid2Done(const AppExecFwk::InnerEvent::Pointer &event); 103 bool ProcessSmsOnSim(const AppExecFwk::InnerEvent::Pointer &event); 104 bool ProcessGetCspCphs(const AppExecFwk::InnerEvent::Pointer &event); 105 bool ProcessGetInfoCphs(const AppExecFwk::InnerEvent::Pointer &event); 106 bool ProcessGetSstDone(const AppExecFwk::InnerEvent::Pointer &event); 107 bool ProcessGetSmsDone(const AppExecFwk::InnerEvent::Pointer &event); 108 bool ProcessGetAllSmsDone(const AppExecFwk::InnerEvent::Pointer &event); 109 bool ProcessGetHplmActDone(const AppExecFwk::InnerEvent::Pointer &event); 110 bool ProcessGetEhplmnDone(const AppExecFwk::InnerEvent::Pointer &event); 111 bool ProcessGetPnnDone(const AppExecFwk::InnerEvent::Pointer &event); 112 bool ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event); 113 bool ProcessSetCphsMailbox(const AppExecFwk::InnerEvent::Pointer &event); 114 bool ProcessGetFplmnDone(const AppExecFwk::InnerEvent::Pointer &event); 115 bool ProcessSetMbdn(const AppExecFwk::InnerEvent::Pointer &event); 116 bool ProcessMarkSms(const AppExecFwk::InnerEvent::Pointer &event); 117 bool ProcessObtainSpnPhase(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 enum SpnType { SPN_INVALID = -1, SPN_COND_PLMN = 1, SPN_COND = 2 }; 130 static const uint8_t CPHS_VOICE_MAIL_MASK = 0x30; 131 static const uint8_t CPHS_VOICE_MAIL_EXSIT = 0x30; 132 int ObtainExtensionElementaryFile(int ef); 133 bool CphsVoiceMailAvailable(); 134 void GetCphsMailBox(); 135 std::string ParseSpn(const std::string &rawData, int curState); 136 }; 137 } // namespace Telephony 138 } // namespace OHOS 139 140 #endif // OHOS_SIM_FILE_H