mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-26 17:50:36 +00:00
commit
867e93072c
@ -61,14 +61,18 @@ public:
|
||||
int32_t GetSimIO(int32_t slotId, SimIoRequestInfo requestInfo, SimAuthenticationResponse &response);
|
||||
void SyncCmdResponse();
|
||||
void SyncSimMatchResponse();
|
||||
void SyncUnlockPinResponse();
|
||||
|
||||
public:
|
||||
bool responseReady_ = false;
|
||||
bool responseSimMatchReady_ = false;
|
||||
bool responseUnlockPinReady_ = false;
|
||||
std::mutex ctx_;
|
||||
std::mutex stx_;
|
||||
std::mutex unlockPinCtx_;
|
||||
std::condition_variable cv_;
|
||||
std::condition_variable sv_;
|
||||
std::condition_variable unlockPinCv_;
|
||||
|
||||
private:
|
||||
void RequestUnlock(UnlockCmd type);
|
||||
|
@ -707,6 +707,8 @@ void SimStateHandle::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
}
|
||||
if (eventId == MSG_SIM_SEND_NCFG_OPER_INFO_DONE) {
|
||||
simStateManager->SyncSimMatchResponse();
|
||||
} else if (eventId == MSG_SIM_UNLOCK_PIN_DONE) {
|
||||
simStateManager->SyncUnlockPinResponse();
|
||||
} else {
|
||||
simStateManager->SyncCmdResponse();
|
||||
}
|
||||
|
@ -168,28 +168,37 @@ void SimStateManager::SyncSimMatchResponse()
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(stx_);
|
||||
responseSimMatchReady_ = true;
|
||||
TELEPHONY_LOGI(
|
||||
"SimStateManager::SyncSimMatchResponse(), responseSimMatchReady = %{public}d", responseSimMatchReady_);
|
||||
TELEPHONY_LOGI("SimStateManager::SyncSimMatchResponse(), responseSimMatchReady = %{public}d",
|
||||
responseSimMatchReady_);
|
||||
sv_.notify_one();
|
||||
}
|
||||
|
||||
void SimStateManager::SyncUnlockPinResponse()
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(unlockPinCtx_);
|
||||
responseUnlockPinReady_ = true;
|
||||
TELEPHONY_LOGI("SimStateManager::SyncUnlockPinResponse(), responseUnlockPinReady = %{public}d",
|
||||
responseUnlockPinReady_);
|
||||
unlockPinCv_.notify_one();
|
||||
}
|
||||
|
||||
int32_t SimStateManager::UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response)
|
||||
{
|
||||
if (simStateHandle_ == nullptr) {
|
||||
TELEPHONY_LOGE("simStateHandle_ is nullptr");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
std::unique_lock<std::mutex> lck(ctx_);
|
||||
std::unique_lock<std::mutex> lck(unlockPinCtx_);
|
||||
TELEPHONY_LOGD("SimStateManager::UnlockPin slotId = %{public}d", slotId);
|
||||
responseReady_ = false;
|
||||
responseUnlockPinReady_ = false;
|
||||
simStateHandle_->UnlockPin(slotId, pin);
|
||||
while (!responseReady_) {
|
||||
while (!responseUnlockPinReady_) {
|
||||
TELEPHONY_LOGI("UnlockPin::wait(), response = false");
|
||||
if (cv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_LONG_SECOND)) == std::cv_status::timeout) {
|
||||
if (unlockPinCv_.wait_for(lck, std::chrono::seconds(WAIT_TIME_LONG_SECOND)) == std::cv_status::timeout) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!responseReady_) {
|
||||
if (!responseUnlockPinReady_) {
|
||||
TELEPHONY_LOGE("unlock pin sim update failed");
|
||||
return CORE_ERR_SIM_CARD_UPDATE_FAILED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user