• 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 #include "icc_file.h"
17 
18 #include "core_manager_inner.h"
19 #include "if_system_ability_manager.h"
20 #include "inner_event.h"
21 #include "iservice_registry.h"
22 #include "radio_event.h"
23 #include "system_ability_definition.h"
24 #include "telephony_state_registry_client.h"
25 
26 using namespace std;
27 using namespace OHOS::AppExecFwk;
28 using namespace OHOS::EventFwk;
29 
30 namespace OHOS {
31 namespace Telephony {
32 std::unique_ptr<ObserverHandler> IccFile::filesFetchedObser_ = nullptr;
IccFile(const std::shared_ptr<AppExecFwk::EventRunner> & runner,std::shared_ptr<SimStateManager> simStateManager)33 IccFile::IccFile(
34     const std::shared_ptr<AppExecFwk::EventRunner> &runner, std::shared_ptr<SimStateManager> simStateManager)
35     : AppExecFwk::EventHandler(runner), stateManager_(simStateManager)
36 {
37     if (stateManager_ == nullptr) {
38         TELEPHONY_LOGE("IccFile::IccFile set NULL SIMStateManager!!");
39     }
40     if (filesFetchedObser_ == nullptr) {
41         filesFetchedObser_ = std::make_unique<ObserverHandler>();
42     }
43     if (filesFetchedObser_ == nullptr) {
44         TELEPHONY_LOGE("IccFile::IccFile filesFetchedObser_ create nullptr.");
45         return;
46     }
47 
48     lockedFilesFetchedObser_ = std::make_unique<ObserverHandler>();
49     if (lockedFilesFetchedObser_ == nullptr) {
50         TELEPHONY_LOGE("IccFile::IccFile lockedFilesFetchedObser_ create nullptr.");
51         return;
52     }
53     networkLockedFilesFetchedObser_ = std::make_unique<ObserverHandler>();
54     if (networkLockedFilesFetchedObser_ == nullptr) {
55         TELEPHONY_LOGE("IccFile::IccFile networkLockedFilesFetchedObser_ create nullptr.");
56         return;
57     }
58     imsiReadyObser_ = std::make_unique<ObserverHandler>();
59     if (imsiReadyObser_ == nullptr) {
60         TELEPHONY_LOGE("IccFile::IccFile imsiReadyObser_ create nullptr.");
61         return;
62     }
63     recordsEventsObser_ = std::make_unique<ObserverHandler>();
64     if (recordsEventsObser_ == nullptr) {
65         TELEPHONY_LOGE("IccFile::IccFile recordsEventsObser_ create nullptr.");
66         return;
67     }
68     networkSelectionModeAutomaticObser_ = std::make_unique<ObserverHandler>();
69     if (networkSelectionModeAutomaticObser_ == nullptr) {
70         TELEPHONY_LOGE("IccFile::IccFile networkSelectionModeAutomaticObser_ create nullptr.");
71         return;
72     }
73     spnUpdatedObser_ = std::make_unique<ObserverHandler>();
74     if (spnUpdatedObser_ == nullptr) {
75         TELEPHONY_LOGE("IccFile::IccFile spnUpdatedObser_ create nullptr.");
76         return;
77     }
78     recordsOverrideObser_ = std::make_unique<ObserverHandler>();
79     if (recordsOverrideObser_ == nullptr) {
80         TELEPHONY_LOGE("IccFile::IccFile recordsOverrideObser_ create nullptr.");
81         return;
82     }
83     TELEPHONY_LOGI("simmgr IccFile::IccFile finish");
84 }
85 
Init()86 void IccFile::Init()
87 {
88     if (stateManager_ != nullptr) {
89         stateManager_->RegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_READY);
90         stateManager_->RegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_LOCKED);
91         stateManager_->RegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_SIMLOCK);
92     }
93 }
94 
StartLoad()95 void IccFile::StartLoad()
96 {
97     TELEPHONY_LOGI("IccFile::StarLoad start");
98 }
99 
ObtainIMSI()100 std::string IccFile::ObtainIMSI()
101 {
102     if (imsi_.empty()) {
103         TELEPHONY_LOGI("IccFile::ObtainIMSI is null:");
104     }
105     return imsi_;
106 }
107 
UpdateImsi(std::string imsi)108 void IccFile::UpdateImsi(std::string imsi)
109 {
110     imsi_ = imsi;
111 }
112 
ObtainIccId()113 std::string IccFile::ObtainIccId()
114 {
115     return iccId_;
116 }
117 
ObtainGid1()118 std::string IccFile::ObtainGid1()
119 {
120     return gid1_;
121 }
122 
ObtainGid2()123 std::string IccFile::ObtainGid2()
124 {
125     return gid2_;
126 }
127 
ObtainMsisdnNumber()128 std::string IccFile::ObtainMsisdnNumber()
129 {
130     return msisdn_;
131 }
132 
LoadedOrNot()133 bool IccFile::LoadedOrNot()
134 {
135     return loaded_;
136 }
137 
UpdateLoaded(bool loaded)138 void IccFile::UpdateLoaded(bool loaded)
139 {
140     loaded_ = loaded;
141 }
142 
ObtainSimOperator()143 std::string IccFile::ObtainSimOperator()
144 {
145     return operatorNumeric_;
146 }
147 
ObtainIsoCountryCode()148 std::string IccFile::ObtainIsoCountryCode()
149 {
150     return "";
151 }
152 
ObtainCallForwardStatus()153 int IccFile::ObtainCallForwardStatus()
154 {
155     return ICC_CALL_FORWARD_TYPE_UNKNOWN;
156 }
157 
UpdateMsisdnNumber(const std::string & alphaTag,const std::string & number,const AppExecFwk::InnerEvent::Pointer & onComplete)158 void IccFile::UpdateMsisdnNumber(
159     const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete)
160 {}
161 
ObtainFilesFetched()162 bool IccFile::ObtainFilesFetched()
163 {
164     return (fileToGet_ == 0) && fileQueried_;
165 }
166 
LockQueriedOrNot()167 bool IccFile::LockQueriedOrNot()
168 {
169     return (fileToGet_ == 0) && lockQueried_;
170 }
171 
ObtainDiallingNumberInfo()172 std::string IccFile::ObtainDiallingNumberInfo()
173 {
174     return "";
175 }
176 
ObtainNAI()177 std::string IccFile::ObtainNAI()
178 {
179     return "";
180 }
181 
ObtainHomeNameOfPnn()182 std::string IccFile::ObtainHomeNameOfPnn()
183 {
184     return pnnHomeName_;
185 }
186 
ObtainMsisdnAlphaStatus()187 std::string IccFile::ObtainMsisdnAlphaStatus()
188 {
189     return msisdnTag_;
190 }
191 
ObtainVoiceMailNumber()192 std::string IccFile::ObtainVoiceMailNumber()
193 {
194     return voiceMailNum_;
195 }
196 
ObtainVoiceMailCount()197 int32_t IccFile::ObtainVoiceMailCount()
198 {
199     return voiceMailCount_;
200 }
201 
ObtainSPN()202 std::string IccFile::ObtainSPN()
203 {
204     return spn_;
205 }
206 
ObtainEons(const std::string & plmn,int32_t lac,bool longNameRequired)207 std::string IccFile::ObtainEons(const std::string &plmn, int32_t lac, bool longNameRequired)
208 {
209     std::vector<std::shared_ptr<OperatorPlmnInfo>> oplFiles = oplFiles_;
210     sptr<NetworkState> networkState = nullptr;
211     CoreManagerInner::GetInstance().GetNetworkStatus(slotId_, networkState);
212     if (networkState != nullptr && !(opl5gFiles_.empty())) {
213         NrState nrState = networkState->GetNrState();
214         if (nrState == NrState::NR_NSA_STATE_SA_ATTACHED) {
215             oplFiles = opl5gFiles_;
216         }
217     }
218     bool roaming = (plmn.compare(operatorNumeric_) == 0 ? false : true);
219     TELEPHONY_LOGI("ObtainEons roaming:%{public}d", roaming);
220     if (plmn.empty() || pnnFiles_.empty() || (oplFiles.empty() && roaming)) {
221         TELEPHONY_LOGE("ObtainEons is empty");
222         return "";
223     }
224     int pnnIndex = 1;
225     for (std::shared_ptr<OperatorPlmnInfo> opl : oplFiles) {
226         if (opl == nullptr) {
227             continue;
228         }
229         pnnIndex = -1;
230         TELEPHONY_LOGD("ObtainEons plmn:%{public}s, opl->plmnNumeric:%{public}s, lac:%{public}d, "
231                        "opl->lacStart:%{public}d, opl->lacEnd:%{public}d, opl->pnnRecordId:%{public}d",
232             plmn.c_str(), opl->plmnNumeric.c_str(), lac, opl->lacStart, opl->lacEnd, opl->pnnRecordId);
233         if (plmn.compare(opl->plmnNumeric) == 0 &&
234             ((opl->lacStart == 0 && opl->lacEnd == 0xfffe) || (opl->lacStart <= lac && opl->lacEnd >= lac))) {
235             pnnIndex = opl->pnnRecordId;
236             break;
237         }
238     }
239     std::string eons = "";
240     if (pnnIndex >= 1 && pnnIndex <= static_cast<int>(pnnFiles_.size())) {
241         TELEPHONY_LOGI("ObtainEons longNameRequired:%{public}d, longName:%{public}s, shortName:%{public}s,",
242             longNameRequired, pnnFiles_.at(pnnIndex - 1)->longName.c_str(),
243             pnnFiles_.at(pnnIndex - 1)->shortName.c_str());
244         if (longNameRequired) {
245             eons = pnnFiles_.at(pnnIndex - 1)->longName;
246         } else {
247             eons = pnnFiles_.at(pnnIndex - 1)->shortName;
248         }
249     }
250     return eons;
251 }
252 
ObtainVoiceMailInfo()253 std::string IccFile::ObtainVoiceMailInfo()
254 {
255     return voiceMailTag_;
256 }
257 
ObtainIccLanguage()258 std::string IccFile::ObtainIccLanguage()
259 {
260     return iccLanguage_;
261 }
262 
ObtainUsimFunctionHandle()263 std::shared_ptr<UsimFunctionHandle> IccFile::ObtainUsimFunctionHandle()
264 {
265     return std::make_shared<UsimFunctionHandle>(nullptr, 0);
266 }
267 
ObtainSpNameFromEfSpn()268 std::string IccFile::ObtainSpNameFromEfSpn()
269 {
270     return "";
271 }
272 
ObtainLengthOfMnc()273 int IccFile::ObtainLengthOfMnc()
274 {
275     return lengthOfMnc_;
276 }
277 
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)278 void IccFile::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
279 {
280     if (event == nullptr) {
281         TELEPHONY_LOGE("event is nullptr!");
282         return;
283     }
284     auto id = event->GetInnerEventId();
285     bool result = false;
286     TELEPHONY_LOGD("IccFile::ProcessEvent id %{public}d", id);
287     switch (id) {
288         case MSG_SIM_OBTAIN_ICC_FILE_DONE:
289             result = ProcessIccFileObtained(event);
290             ProcessFileLoaded(result);
291             break;
292         case MSG_ICC_REFRESH:
293             ProcessIccRefresh(MSG_ID_DEFAULT);
294             break;
295         default:
296             break;
297     }
298 }
299 
RegisterImsiLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler)300 void IccFile::RegisterImsiLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler)
301 {
302     int eventCode = RadioEvent::RADIO_IMSI_LOADED_READY;
303     if (imsiReadyObser_ != nullptr) {
304         imsiReadyObser_->RegObserver(eventCode, eventHandler);
305     }
306     if (!ObtainIMSI().empty()) {
307         if (eventHandler != nullptr) {
308             eventHandler->SendEvent(RadioEvent::RADIO_IMSI_LOADED_READY);
309         }
310     }
311 }
312 
UnregisterImsiLoaded(const std::shared_ptr<AppExecFwk::EventHandler> & handler)313 void IccFile::UnregisterImsiLoaded(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
314 {
315     if (imsiReadyObser_ != nullptr) {
316         imsiReadyObser_->Remove(RadioEvent::RADIO_IMSI_LOADED_READY, handler);
317     }
318 }
319 
RegisterAllFilesLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler)320 void IccFile::RegisterAllFilesLoaded(std::shared_ptr<AppExecFwk::EventHandler> eventHandler)
321 {
322     int eventCode = RadioEvent::RADIO_SIM_RECORDS_LOADED;
323     if (filesFetchedObser_ != nullptr) {
324         filesFetchedObser_->RegObserver(eventCode, eventHandler);
325     }
326     TELEPHONY_LOGD("IccFile::RegisterAllFilesLoaded: registerd");
327     if (ObtainFilesFetched()) {
328         TELEPHONY_LOGI("IccFile::RegisterAllFilesLoaded: notify");
329         if (eventHandler != nullptr) {
330             eventHandler->SendEvent(RadioEvent::RADIO_SIM_RECORDS_LOADED, slotId_, 0);
331         }
332         PublishSimFileEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SIM_STATE_CHANGED,
333             static_cast<int32_t>(SimState::SIM_STATE_LOADED), "");
334     }
335 }
336 
UnregisterAllFilesLoaded(const std::shared_ptr<AppExecFwk::EventHandler> & handler)337 void IccFile::UnregisterAllFilesLoaded(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
338 {
339     if (filesFetchedObser_ != nullptr) {
340         filesFetchedObser_->Remove(RadioEvent::RADIO_SIM_RECORDS_LOADED, handler);
341     }
342 }
343 
RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> & handler,int what)344 void IccFile::RegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what)
345 {
346     switch (what) {
347         case RadioEvent::RADIO_SIM_RECORDS_LOADED:
348             RegisterAllFilesLoaded(handler);
349             break;
350         case RadioEvent::RADIO_IMSI_LOADED_READY:
351             RegisterImsiLoaded(handler);
352             break;
353         default:
354             TELEPHONY_LOGI("RegisterCoreNotify default");
355     }
356 }
357 
UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> & handler,int what)358 void IccFile::UnRegisterCoreNotify(const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what)
359 {
360     switch (what) {
361         case RadioEvent::RADIO_SIM_RECORDS_LOADED:
362             UnregisterAllFilesLoaded(handler);
363             break;
364         case RadioEvent::RADIO_IMSI_LOADED_READY:
365             UnregisterImsiLoaded(handler);
366             break;
367         default:
368             TELEPHONY_LOGI("RegisterCoreNotify default");
369     }
370 }
371 
UpdateSPN(const std::string spn)372 void IccFile::UpdateSPN(const std::string spn)
373 {
374     if (spn_ != spn) {
375         spnUpdatedObser_->NotifyObserver(MSG_SIM_SPN_UPDATED);
376         spn_ = spn;
377     }
378 }
379 
BuildCallerInfo(int eventId)380 AppExecFwk::InnerEvent::Pointer IccFile::BuildCallerInfo(int eventId)
381 {
382     std::unique_ptr<FileToControllerMsg> object = std::make_unique<FileToControllerMsg>();
383     int eventParam = 0;
384     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(eventId, object, eventParam);
385     if (event == nullptr) {
386         TELEPHONY_LOGE("event is nullptr!");
387         return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
388     }
389     event->SetOwner(shared_from_this());
390     return event;
391 }
392 
BuildCallerInfo(int eventId,int arg1,int arg2)393 AppExecFwk::InnerEvent::Pointer IccFile::BuildCallerInfo(int eventId, int arg1, int arg2)
394 {
395     std::unique_ptr<FileToControllerMsg> object = std::make_unique<FileToControllerMsg>();
396     object->arg1 = arg1;
397     object->arg2 = arg2;
398     int eventParam = 0;
399     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(eventId, object, eventParam);
400     if (event == nullptr) {
401         TELEPHONY_LOGE("event is nullptr!");
402         return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
403     }
404     event->SetOwner(shared_from_this());
405     return event;
406 }
407 
BuildCallerInfo(int eventId,std::shared_ptr<void> loader)408 AppExecFwk::InnerEvent::Pointer IccFile::BuildCallerInfo(int eventId, std::shared_ptr<void> loader)
409 {
410     std::unique_ptr<FileToControllerMsg> object = std::make_unique<FileToControllerMsg>();
411     object->iccLoader = loader;
412     int eventParam = 0;
413     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(eventId, object, eventParam);
414     if (event == nullptr) {
415         TELEPHONY_LOGE("event is nullptr!");
416         return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
417     }
418     event->SetOwner(shared_from_this());
419     return event;
420 }
421 
PublishSimFileEvent(const std::string & event,int eventCode,const std::string & eventData)422 bool IccFile::PublishSimFileEvent(const std::string &event, int eventCode, const std::string &eventData)
423 {
424     Want want;
425     want.SetAction(event);
426     CommonEventData data;
427     data.SetWant(want);
428     data.SetCode(eventCode);
429     data.SetData(eventData);
430     CommonEventPublishInfo publishInfo;
431     publishInfo.SetOrdered(true);
432     bool publishResult = CommonEventManager::PublishCommonEvent(data, publishInfo, nullptr);
433     TELEPHONY_LOGI("IccFile::PublishSimEvent result : %{public}d", publishResult);
434     return publishResult;
435 }
436 
ProcessIccFileObtained(const AppExecFwk::InnerEvent::Pointer & event)437 bool IccFile::ProcessIccFileObtained(const AppExecFwk::InnerEvent::Pointer &event)
438 {
439     bool isFileProcessResponse = true;
440     std::shared_ptr<ControllerToFileMsg> fd = event->GetSharedObject<ControllerToFileMsg>();
441     std::shared_ptr<void> baseLoad = fd->iccLoader;
442     if (baseLoad != nullptr) {
443         std::shared_ptr<IccFileLoaded> destLoad = std::static_pointer_cast<IccFileLoaded>(baseLoad);
444         destLoad->ProcessParseFile(event);
445         TELEPHONY_LOGI("ProcessIccFileObtained item %{public}s", destLoad->ObtainElementaryFileName().c_str());
446     } else {
447         isFileProcessResponse = false;
448         TELEPHONY_LOGE("IccFile::ProcessIccFileObtained null base ponter");
449     }
450     return isFileProcessResponse;
451 }
452 
UpdateIccLanguage(const std::string & langLi,const std::string & langPl)453 void IccFile::UpdateIccLanguage(const std::string &langLi, const std::string &langPl)
454 {
455     iccLanguage_ = ObtainValidLanguage(langLi);
456     if (iccLanguage_.empty()) {
457         iccLanguage_ = ObtainValidLanguage(langPl);
458     }
459     TELEPHONY_LOGI("IccFile::UpdateIccLanguage end is %{public}s", iccLanguage_.c_str());
460 }
461 
ObtainValidLanguage(const std::string & langData)462 std::string IccFile::ObtainValidLanguage(const std::string &langData)
463 {
464     if (langData.empty()) {
465         TELEPHONY_LOGE("langData null data!!");
466         return "";
467     }
468     int langDataLen = 0;
469     std::shared_ptr<unsigned char> ucc = SIMUtils::HexStringConvertToBytes(langData, langDataLen);
470     unsigned char *data = ucc.get();
471 
472     std::string spnName((char *)data);
473     TELEPHONY_LOGI("ObtainValidLanguage all is %{public}s---%{public}d", spnName.c_str(), langDataLen);
474     std::string result = "";
475     for (int i = 0; (i + 1) < langDataLen; i += DATA_STEP) {
476         std::string langName((char *)data, i, DATA_STEP);
477         TELEPHONY_LOGI("ObtainValidLanguage item is %{public}d--%{public}s", i, langName.c_str());
478         if (!langName.empty()) {
479             result = langName;
480         }
481     }
482 
483     return result;
484 }
485 
~IccFile()486 IccFile::~IccFile() {}
487 
SetRilAndFileController(const std::shared_ptr<Telephony::ITelRilManager> & ril,const std::shared_ptr<IccFileController> & file,const std::shared_ptr<IccDiallingNumbersHandler> & handler)488 void IccFile::SetRilAndFileController(const std::shared_ptr<Telephony::ITelRilManager> &ril,
489     const std::shared_ptr<IccFileController> &file, const std::shared_ptr<IccDiallingNumbersHandler> &handler)
490 {
491     telRilManager_ = ril;
492     if (telRilManager_ == nullptr) {
493         TELEPHONY_LOGE("IccFile set NULL TelRilManager!!");
494     }
495 
496     fileController_ = file;
497     if (fileController_ == nullptr) {
498         TELEPHONY_LOGE("IccFile set NULL File Controller!!");
499     }
500     diallingNumberHandler_ = handler;
501     if (fileController_ == nullptr) {
502         TELEPHONY_LOGE("IccFile set NULL File Controller!!");
503     }
504 }
505 
CreateDiallingNumberPointer(int eventid,int efId,int index,std::shared_ptr<void> pobj)506 AppExecFwk::InnerEvent::Pointer IccFile::CreateDiallingNumberPointer(
507     int eventid, int efId, int index, std::shared_ptr<void> pobj)
508 {
509     std::unique_ptr<DiallingNumbersHandleHolder> holder = std::make_unique<DiallingNumbersHandleHolder>();
510     holder->fileID = efId;
511     holder->index = index;
512     holder->diallingNumber = pobj;
513     int eventParam = 0;
514     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(eventid, holder, eventParam);
515     if (event == nullptr) {
516         TELEPHONY_LOGE("event is nullptr!");
517         return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
518     }
519     event->SetOwner(shared_from_this());
520     return event;
521 }
522 
523 
NotifyRegistrySimState(CardType type,SimState state,LockReason reason)524 void IccFile::NotifyRegistrySimState(CardType type, SimState state, LockReason reason)
525 {
526     int32_t result =
527         DelayedRefSingleton<TelephonyStateRegistryClient>::GetInstance().UpdateSimState(slotId_, type, state, reason);
528     TELEPHONY_LOGI("NotifyRegistrySimState msgId is %{public}d ret %{public}d", state, result);
529 }
530 
HasSimCard()531 bool IccFile::HasSimCard()
532 {
533     return (stateManager_ != nullptr) ? stateManager_->HasSimCard() : false;
534 }
535 
ClearData()536 void IccFile::ClearData()
537 {
538     imsi_ = "";
539     iccId_ = "";
540     UpdateSPN("");
541     UpdateLoaded(false);
542     operatorNumeric_ = "";
543     voiceMailNum_ = "";
544     voiceMailTag_ = "";
545     indexOfMailbox_ = 1;
546     msisdn_ = "";
547     gid1_ = "";
548     gid2_ = "";
549     msisdnTag_ = "";
550     fileQueried_ = false;
551 }
UnInit()552 void IccFile::UnInit()
553 {
554     if (stateManager_ != nullptr) {
555         stateManager_->UnRegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_READY);
556         stateManager_->UnRegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_LOCKED);
557         stateManager_->UnRegisterCoreNotify(shared_from_this(), RadioEvent::RADIO_SIM_STATE_SIMLOCK);
558     }
559     ClearData();
560 }
561 
SaveCountryCode()562 void IccFile::SaveCountryCode()
563 {
564     std::string countryCode = ObtainIsoCountryCode();
565     std::string key = COUNTRY_CODE_KEY + std::to_string(slotId_);
566     SetParameter(key.c_str(), countryCode.c_str());
567 }
568 } // namespace Telephony
569 } // namespace OHOS
570