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