mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-23 16:09:48 +00:00
卡号码更新修改
Signed-off-by: Jierbumo866 <fangping5@huawei.com>
This commit is contained in:
parent
c0959a4fcc
commit
72bf5df091
@ -54,8 +54,8 @@ public:
|
||||
virtual int ObtainSpnCondition(bool roaming, const std::string &operatorNum) = 0;
|
||||
bool LoadedOrNot();
|
||||
void UpdateLoaded(bool loaded);
|
||||
virtual void UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete);
|
||||
virtual bool UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number);
|
||||
virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
virtual ~IccFile();
|
||||
virtual bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event) = 0;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
int32_t SetPrimarySlotId(int32_t slotId);
|
||||
int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber);
|
||||
int32_t SetShowNumber(int32_t slotId, std::u16string Number, bool force = false);
|
||||
int32_t SetShowNumberToDB(int32_t slotId, std::u16string Number);
|
||||
int32_t GetShowName(int32_t slotId, std::u16string &showName);
|
||||
int32_t SetShowName(int32_t slotId, std::u16string name, bool force = false);
|
||||
int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber);
|
||||
|
@ -30,8 +30,8 @@ public:
|
||||
int ObtainSpnCondition(bool roaming, const std::string &operatorNum);
|
||||
int ObtainCallForwardStatus();
|
||||
std::shared_ptr<UsimFunctionHandle> ObtainUsimFunctionHandle();
|
||||
void UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete);
|
||||
bool UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number);
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
~SimFile() = default;
|
||||
bool ProcessIccReady(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
std::shared_ptr<IccFileController> GetIccFileController();
|
||||
std::shared_ptr<IccDiallingNumbersHandler> ObtainDiallingNumberHandler();
|
||||
bool SetVoiceMailInfo(const std::u16string &mailName, const std::u16string &mailNumber);
|
||||
bool SetSimTelephoneNumber(const std::u16string &alphaTag, const std::u16string &phoneNumber);
|
||||
bool HasSimCard();
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
|
||||
|
@ -191,9 +191,10 @@ int IccFile::ObtainCallForwardStatus()
|
||||
return ICC_CALL_FORWARD_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
void IccFile::UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete)
|
||||
{}
|
||||
bool IccFile::UpdateMsisdnNumber(const std::string &alphaTag, const std::string &number)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IccFile::ObtainFilesFetched()
|
||||
{
|
||||
|
@ -300,22 +300,13 @@ bool MultiSimController::InitShowNumber(int slotId)
|
||||
TELEPHONY_LOGE("InValidData");
|
||||
return false;
|
||||
}
|
||||
if (static_cast<uint32_t>(slotId) >= localCacheInfo_.size()) {
|
||||
TELEPHONY_LOGE("failed by nullptr");
|
||||
return false;
|
||||
}
|
||||
showNumber = Str8ToStr16(localCacheInfo_[slotId].phoneNumber);
|
||||
if (!showNumber.empty()) {
|
||||
TELEPHONY_LOGD("no need to init showNumber");
|
||||
return true;
|
||||
}
|
||||
if (simFileManager_[slotId] == nullptr) {
|
||||
TELEPHONY_LOGE("can not get simFileManager");
|
||||
return false;
|
||||
}
|
||||
showNumber = simFileManager_[slotId]->GetSimTelephoneNumber();
|
||||
int32_t result = TELEPHONY_ERROR;
|
||||
result = SetShowNumber(slotId, showNumber, true);
|
||||
result = SetShowNumberToDB(slotId, showNumber);
|
||||
return result == TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
@ -883,6 +874,16 @@ int32_t MultiSimController::GetShowNumber(int32_t slotId, std::u16string &showNu
|
||||
TELEPHONY_LOGE("InValidData");
|
||||
return TELEPHONY_ERR_NO_SIM_CARD;
|
||||
}
|
||||
if (simFileManager_[slotId] == nullptr) {
|
||||
TELEPHONY_LOGE("can not get simFileManager");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
showNumber = simFileManager_[slotId]->GetSimTelephoneNumber();
|
||||
if (!showNumber.empty()) {
|
||||
std::string number = Str16ToStr8(showNumber);
|
||||
TELEPHONY_LOGI("showNumber: %{public}s", number.c_str());
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(mutex_);
|
||||
if (static_cast<uint32_t>(slotId) >= localCacheInfo_.size()) {
|
||||
TELEPHONY_LOGE("failed by nullptr");
|
||||
@ -890,6 +891,8 @@ int32_t MultiSimController::GetShowNumber(int32_t slotId, std::u16string &showNu
|
||||
}
|
||||
showNumber = Str8ToStr16(localCacheInfo_[slotId].phoneNumber);
|
||||
if (!showNumber.empty()) {
|
||||
std::string number = Str16ToStr8(showNumber);
|
||||
TELEPHONY_LOGI("showNumber: %{public}s", number.c_str());
|
||||
return TELEPHONY_ERR_SUCCESS;
|
||||
}
|
||||
return GetSimTelephoneNumber(slotId, showNumber);
|
||||
@ -902,6 +905,23 @@ int32_t MultiSimController::SetShowNumber(int32_t slotId, std::u16string number,
|
||||
TELEPHONY_LOGE("MultiSimController::SetShowNumber InValidData");
|
||||
return TELEPHONY_ERR_NO_SIM_CARD;
|
||||
}
|
||||
if (simFileManager_[slotId] == nullptr) {
|
||||
TELEPHONY_LOGE("can not get simFileManager");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
std::u16string alphaTag = simFileManager_[slotId]->GetSimTeleNumberIdentifier();
|
||||
if(!simFileManager_[slotId]->SetSimTelephoneNumber(alphaTag, number)){
|
||||
return TELEPHONY_ERR_FAIL;
|
||||
}
|
||||
return SetShowNumberToDB(slotId, number);
|
||||
}
|
||||
|
||||
int32_t MultiSimController::SetShowNumberToDB(int32_t slotId, std::u16string number)
|
||||
{
|
||||
if (static_cast<uint32_t>(slotId) >= localCacheInfo_.size()) {
|
||||
TELEPHONY_LOGE("failed by nullptr");
|
||||
return false;
|
||||
}
|
||||
int curSimId;
|
||||
if (GetTargetSimId(slotId, curSimId) != TELEPHONY_ERR_SUCCESS) {
|
||||
TELEPHONY_LOGE("MultiSimController::SetShowNumber failed by out of range");
|
||||
|
@ -88,9 +88,34 @@ int SimFile::ObtainCallForwardStatus()
|
||||
return callForwardStatus_;
|
||||
}
|
||||
|
||||
void SimFile::UpdateMsisdnNumber(
|
||||
const std::string &alphaTag, const std::string &number, const AppExecFwk::InnerEvent::Pointer &onComplete)
|
||||
{}
|
||||
bool SimFile::UpdateMsisdnNumber(const std::string &alphaTag, const std::string &number)
|
||||
{
|
||||
lastMsisdn_ = number;
|
||||
lastMsisdnTag_ = alphaTag;
|
||||
TELEPHONY_LOGI("SimFile::UpdateMsisdnNumber lastMsisdn_:%{public}s, lastMsisdnTag_:%{public}s", lastMsisdn_.c_str(),
|
||||
lastMsisdnTag_.c_str());
|
||||
waitResult_ = false;
|
||||
std::shared_ptr<DiallingNumbersInfo> diallingNumber = std::make_shared<DiallingNumbersInfo>();
|
||||
diallingNumber->name_ = Str8ToStr16(alphaTag);
|
||||
diallingNumber->number_ = Str8ToStr16(number);
|
||||
std::unique_lock<std::mutex> lock(IccFile::mtx_);
|
||||
AppExecFwk::InnerEvent::Pointer phoneNumberEvent =
|
||||
CreateDiallingNumberPointer(MSG_SIM_SET_MSISDN_DONE, 0, 0, nullptr);
|
||||
DiallingNumberUpdateInfor infor;
|
||||
infor.diallingNumber = diallingNumber;
|
||||
infor.fileId = ELEMENTARY_FILE_MSISDN;
|
||||
infor.extFile = ObtainExtensionElementaryFile(ELEMENTARY_FILE_MSISDN);
|
||||
infor.index = 1;
|
||||
diallingNumberHandler_->UpdateDiallingNumbers(infor, phoneNumberEvent);
|
||||
while (!waitResult_) {
|
||||
TELEPHONY_LOGI("update voicemail wait, response = false");
|
||||
if (processWait_.wait_for(lock, std::chrono::seconds(WAIT_TIME_SECOND)) == std::cv_status::timeout) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
TELEPHONY_LOGI("UpdateMsisdnNumber finished %{public}d", waitResult_);
|
||||
return waitResult_;
|
||||
}
|
||||
|
||||
void SimFile::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
@ -650,12 +675,13 @@ bool SimFile::ProcessGetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
}
|
||||
msisdn_ = Str16ToStr8(diallingNumber->GetNumber());
|
||||
msisdnTag_ = Str16ToStr8(diallingNumber->GetName());
|
||||
TELEPHONY_LOGI("ProcessGetMsisdnDone msisdn_:%{public}s, msisdnTag_:%{public}s", msisdn_.c_str(), msisdnTag_.c_str());
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
|
||||
bool SimFile::ProcessSetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
bool isFileProcessResponse = false;
|
||||
bool isFileProcessResponse = true;
|
||||
if (event == nullptr) {
|
||||
TELEPHONY_LOGE("update Msisdn event is nullptr!");
|
||||
return isFileProcessResponse;
|
||||
@ -669,7 +695,12 @@ bool SimFile::ProcessSetMsisdnDone(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
if (fd->exception == nullptr) {
|
||||
msisdn_ = lastMsisdn_;
|
||||
msisdnTag_ = lastMsisdnTag_;
|
||||
waitResult_ = true;
|
||||
processWait_.notify_all();
|
||||
TELEPHONY_LOGI("SimFile Success to update EF[MSISDN]");
|
||||
} else {
|
||||
processWait_.notify_all();
|
||||
TELEPHONY_LOGE("SimFile Fail to update EF[MSISDN]");
|
||||
}
|
||||
return isFileProcessResponse;
|
||||
}
|
||||
|
@ -310,6 +310,17 @@ std::u16string SimFileManager::GetSimTelephoneNumber()
|
||||
return Str8ToStr16(result);
|
||||
}
|
||||
|
||||
bool SimFileManager::SetSimTelephoneNumber(const std::u16string &alphaTag, const std::u16string &phoneNumber)
|
||||
{
|
||||
if (simFile_ == nullptr) {
|
||||
TELEPHONY_LOGE("SimFileManager::SetSimTelephoneNumber simFile nullptr");
|
||||
return false;
|
||||
}
|
||||
std::string tag = Str16ToStr8(alphaTag);
|
||||
std::string number = Str16ToStr8(phoneNumber);
|
||||
return simFile_->UpdateMsisdnNumber(tag, number);
|
||||
}
|
||||
|
||||
std::u16string SimFileManager::GetSimTeleNumberIdentifier()
|
||||
{
|
||||
if (simFile_ == nullptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user