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_RUIM_FILE_H 17 #define OHOS_RUIM_FILE_H 18 19 #include "icc_file.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 class RuimFile : public IccFile { 24 public: 25 RuimFile( 26 const std::shared_ptr<AppExecFwk::EventRunner> &runner, std::shared_ptr<SimStateManager> simStateManager); 27 void Init(); 28 void StartLoad(); 29 std::string ObtainSimOperator(); 30 std::string ObtainIsoCountryCode(); 31 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 32 ~RuimFile(); 33 bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event); 34 std::string ObtainMdnNumber(); 35 std::string ObtainCdmaMin(); 36 std::string ObtainPrlVersion(); 37 std::string ObtainNAI(); 38 std::string ObtainMdn(); 39 std::string ObtainMin(); 40 std::string ObtainSid(); 41 std::string ObtainNid(); 42 bool ObtainCsimSpnDisplayCondition(); 43 int ObtainSpnCondition(bool roaming, const std::string &operatorNum); 44 bool UpdateVoiceMail(const std::string &mailName, const std::string &mailNumber); 45 void UnInit(); 46 47 protected: 48 void ProcessIccRefresh(int msgId); 49 void ProcessFileLoaded(bool response); 50 void OnAllFilesFetched(); 51 void LoadRuimFiles(); 52 bool ProcessIccLocked(const AppExecFwk::InnerEvent::Pointer &event); 53 54 private: 55 using RecordProcessFunc = bool (RuimFile::*)(const AppExecFwk::InnerEvent::Pointer &event); 56 std::map<int, RecordProcessFunc> memberFuncMap_; 57 void InitMemberFunc(); 58 void ProcessLockedAllFilesFetched(); 59 bool ProcessGetImsiDone(const AppExecFwk::InnerEvent::Pointer &event); 60 bool ProcessGetIccidDone(const AppExecFwk::InnerEvent::Pointer &event); 61 bool ProcessGetSubscriptionDone(const AppExecFwk::InnerEvent::Pointer &event); 62 bool ProcessGetSpnDone(const AppExecFwk::InnerEvent::Pointer &event); 63 void ParseSpnName(int encodeType, const unsigned char* spnData, int dataLen); 64 const int MCC_LEN = 3; 65 const int LOAD_STEP = 1; 66 const int SPN_FLAG = 0x01; 67 const int ENCODING_POS = 1; 68 const int LANG_POS = 2; 69 static const int BUFFER_SIZE = 50; 70 const int FLAG_NUM = 3; 71 const int MAX_DATA_BYTE = 32; 72 const uint8_t BYTE_NUM = 0xFF; 73 std::string phoneNumber_ = ""; 74 // C.S0005 section 2.3.1 75 std::string min2And1_ = ""; 76 // C.S0065 section 5.2.2 77 std::string prlVersion_ = ""; 78 bool displayConditionOfCsimSpn_ = false; 79 std::string mdn_ = ""; 80 std::string min_ = ""; 81 std::string systemId_ = ""; 82 std::string networkId_ = ""; 83 std::string nai_ = ""; 84 }; 85 } // namespace Telephony 86 } // namespace OHOS 87 #endif // OHOS_RUIM_FILE_H