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