1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci#include "supplement_request_cs.h" 16d95e75fdSopenharmony_ci 17d95e75fdSopenharmony_ci#include "cellular_call_service.h" 18d95e75fdSopenharmony_ci#include "radio_event.h" 19d95e75fdSopenharmony_ci#include "securec.h" 20d95e75fdSopenharmony_ci#include "telephony_log_wrapper.h" 21d95e75fdSopenharmony_ci#include "telephony_types.h" 22d95e75fdSopenharmony_ci 23d95e75fdSopenharmony_cinamespace OHOS { 24d95e75fdSopenharmony_cinamespace Telephony { 25d95e75fdSopenharmony_ciint32_t SupplementRequestCs::GetClipRequest(int32_t slotId, int32_t index) 26d95e75fdSopenharmony_ci{ 27d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 28d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIP, index); 29d95e75fdSopenharmony_ci if (response == nullptr) { 30d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 31d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 32d95e75fdSopenharmony_ci } 33d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 34d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().GetClip(slotId, response); 35d95e75fdSopenharmony_ci} 36d95e75fdSopenharmony_ci 37d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SetClirRequest(int32_t slotId, int32_t action, int32_t index) 38d95e75fdSopenharmony_ci{ 39d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 40d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_CALL_CLIR, index); 41d95e75fdSopenharmony_ci if (response == nullptr) { 42d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 43d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 44d95e75fdSopenharmony_ci } 45d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 46d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetClir(slotId, action, response); 47d95e75fdSopenharmony_ci} 48d95e75fdSopenharmony_ci 49d95e75fdSopenharmony_ciint32_t SupplementRequestCs::GetClirRequest(int32_t slotId, int32_t index) 50d95e75fdSopenharmony_ci{ 51d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 52d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_CLIR, index); 53d95e75fdSopenharmony_ci if (response == nullptr) { 54d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 55d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 56d95e75fdSopenharmony_ci } 57d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 58d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().GetClir(slotId, response); 59d95e75fdSopenharmony_ci} 60d95e75fdSopenharmony_ci 61d95e75fdSopenharmony_ciint32_t SupplementRequestCs::GetCallTransferRequest(int32_t slotId, int32_t reason, int32_t index) 62d95e75fdSopenharmony_ci{ 63d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 64d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_FORWARD, index); 65d95e75fdSopenharmony_ci if (response == nullptr) { 66d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 67d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 68d95e75fdSopenharmony_ci } 69d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 70d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().GetCallTransferInfo(slotId, reason, response); 71d95e75fdSopenharmony_ci} 72d95e75fdSopenharmony_ci 73d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SetCallTransferRequest( 74d95e75fdSopenharmony_ci int32_t slotId, const CallTransferParam &callTransferParam, int32_t index) 75d95e75fdSopenharmony_ci{ 76d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 77d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_CALL_FORWARD, index); 78d95e75fdSopenharmony_ci if (response == nullptr) { 79d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 80d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 81d95e75fdSopenharmony_ci } 82d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 83d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetCallTransferInfo(slotId, callTransferParam, response); 84d95e75fdSopenharmony_ci} 85d95e75fdSopenharmony_ci 86d95e75fdSopenharmony_ciint32_t SupplementRequestCs::GetCallRestrictionRequest(int32_t slotId, const std::string &fac, int32_t index) 87d95e75fdSopenharmony_ci{ 88d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 89d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = 90d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_RESTRICTION, index); 91d95e75fdSopenharmony_ci if (response == nullptr) { 92d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 93d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 94d95e75fdSopenharmony_ci } 95d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 96d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().GetCallRestriction(slotId, fac, response); 97d95e75fdSopenharmony_ci} 98d95e75fdSopenharmony_ci 99d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SetCallRestrictionRequest( 100d95e75fdSopenharmony_ci int32_t slotId, const std::string &fac, int32_t mode, const std::string &pw, int32_t index) 101d95e75fdSopenharmony_ci{ 102d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 103d95e75fdSopenharmony_ci CallRestrictionParam callRestrictionParam; 104d95e75fdSopenharmony_ci callRestrictionParam.mode = mode; 105d95e75fdSopenharmony_ci callRestrictionParam.fac = fac; 106d95e75fdSopenharmony_ci size_t cpyLen = strlen(pw.c_str()) + 1; 107d95e75fdSopenharmony_ci size_t maxCpyLen = sizeof(callRestrictionParam.password); 108d95e75fdSopenharmony_ci if (strcpy_s(callRestrictionParam.password, cpyLen > maxCpyLen ? maxCpyLen : cpyLen, pw.c_str()) != EOK) { 109d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] strcpy_s fail.", slotId); 110d95e75fdSopenharmony_ci return TELEPHONY_ERR_STRCPY_FAIL; 111d95e75fdSopenharmony_ci } 112d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = 113d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_CALL_RESTRICTION, index); 114d95e75fdSopenharmony_ci if (response == nullptr) { 115d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 116d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 117d95e75fdSopenharmony_ci } 118d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 119d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetCallRestriction(slotId, callRestrictionParam, response); 120d95e75fdSopenharmony_ci} 121d95e75fdSopenharmony_ci 122d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SetBarringPasswordRequest(int32_t slotId, const std::string &restrictionType, 123d95e75fdSopenharmony_ci int32_t index, const char *oldPassword, const char *newPassword) 124d95e75fdSopenharmony_ci{ 125d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 126d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = 127d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_CALL_RESTRICTION_PWD, index); 128d95e75fdSopenharmony_ci if (response == nullptr) { 129d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 130d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 131d95e75fdSopenharmony_ci } 132d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 133d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetBarringPassword( 134d95e75fdSopenharmony_ci slotId, oldPassword, newPassword, restrictionType, response); 135d95e75fdSopenharmony_ci} 136d95e75fdSopenharmony_ci 137d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SetCallWaitingRequest(int32_t slotId, bool activate, int32_t classType, int32_t index) 138d95e75fdSopenharmony_ci{ 139d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 140d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_SET_CALL_WAIT, index); 141d95e75fdSopenharmony_ci if (response == nullptr) { 142d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 143d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 144d95e75fdSopenharmony_ci } 145d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 146d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetCallWaiting(slotId, activate, response); 147d95e75fdSopenharmony_ci} 148d95e75fdSopenharmony_ci 149d95e75fdSopenharmony_ciint32_t SupplementRequestCs::GetCallWaitingRequest(int32_t slotId, int32_t index) 150d95e75fdSopenharmony_ci{ 151d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 152d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer response = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GET_CALL_WAIT, index); 153d95e75fdSopenharmony_ci if (response == nullptr) { 154d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] response is null!", slotId); 155d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 156d95e75fdSopenharmony_ci } 157d95e75fdSopenharmony_ci response->SetOwner(GetMMIHandler(slotId)); 158d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().GetCallWaiting(slotId, response); 159d95e75fdSopenharmony_ci} 160d95e75fdSopenharmony_ci 161d95e75fdSopenharmony_cistd::shared_ptr<CellularCallHandler> SupplementRequestCs::GetMMIHandler(int32_t slotId) const 162d95e75fdSopenharmony_ci{ 163d95e75fdSopenharmony_ci auto callService = DelayedSingleton<CellularCallService>::GetInstance(); 164d95e75fdSopenharmony_ci if (callService == nullptr) { 165d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] error type: callService is nullptr.", slotId); 166d95e75fdSopenharmony_ci return nullptr; 167d95e75fdSopenharmony_ci } 168d95e75fdSopenharmony_ci return callService->GetHandler(slotId); 169d95e75fdSopenharmony_ci} 170d95e75fdSopenharmony_ci 171d95e75fdSopenharmony_ciint32_t SupplementRequestCs::SendUssdRequest(int32_t slotId, const std::string &msg) 172d95e75fdSopenharmony_ci{ 173d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 174d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().SetUssd(slotId, RadioEvent::RADIO_SET_USSD, msg, GetMMIHandler(slotId)); 175d95e75fdSopenharmony_ci} 176d95e75fdSopenharmony_ci 177d95e75fdSopenharmony_ciint32_t SupplementRequestCs::AlterPinPassword(int32_t slotId, std::string newPin, std::string oldPin) 178d95e75fdSopenharmony_ci{ 179d95e75fdSopenharmony_ci TELEPHONY_LOGD("[slot%{public}d] entry", slotId); 180d95e75fdSopenharmony_ci LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR }; 181d95e75fdSopenharmony_ci int32_t result = CoreManagerInner::GetInstance().AlterPin(slotId, newPin, oldPin, response); 182d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] result: %{public}d, remain: %{public}d", slotId, response.result, response.remain); 183d95e75fdSopenharmony_ci if (result == TELEPHONY_SUCCESS) { 184d95e75fdSopenharmony_ci std::shared_ptr<CellularCallHandler> ccHandler = GetMMIHandler(slotId); 185d95e75fdSopenharmony_ci if (ccHandler == nullptr) { 186d95e75fdSopenharmony_ci TELEPHONY_LOGE("ccHandler is null"); 187d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 188d95e75fdSopenharmony_ci } 189d95e75fdSopenharmony_ci std::shared_ptr<PinPukResponse> pinResData = std::make_shared<PinPukResponse>(); 190d95e75fdSopenharmony_ci pinResData->result = response.result; 191d95e75fdSopenharmony_ci pinResData->remain = response.remain; 192d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer msgEvent = 193d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(MMIHandlerId::EVENT_SET_UNLOCK_PIN_PUK_ID, pinResData, 0); 194d95e75fdSopenharmony_ci if (msgEvent == nullptr) { 195d95e75fdSopenharmony_ci TELEPHONY_LOGE("msgEvent is null"); 196d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 197d95e75fdSopenharmony_ci } 198d95e75fdSopenharmony_ci bool ret = ccHandler->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); 199d95e75fdSopenharmony_ci if (!ret) { 200d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] SendEvent failed! status update failed", slotId); 201d95e75fdSopenharmony_ci return TELEPHONY_ERR_FAIL; 202d95e75fdSopenharmony_ci } 203d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 204d95e75fdSopenharmony_ci } 205d95e75fdSopenharmony_ci return TELEPHONY_ERROR; 206d95e75fdSopenharmony_ci} 207d95e75fdSopenharmony_ci 208d95e75fdSopenharmony_ciint32_t SupplementRequestCs::UnlockPuk(int32_t slotId, std::string newPin, std::string puk) 209d95e75fdSopenharmony_ci{ 210d95e75fdSopenharmony_ci TELEPHONY_LOGD("[slot%{public}d] entry", slotId); 211d95e75fdSopenharmony_ci LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR }; 212d95e75fdSopenharmony_ci int32_t result = CoreManagerInner::GetInstance().UnlockPuk(slotId, newPin, puk, response); 213d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] result: %{public}d, remain: %{public}d", slotId, response.result, response.remain); 214d95e75fdSopenharmony_ci if (result == TELEPHONY_SUCCESS) { 215d95e75fdSopenharmony_ci std::shared_ptr<CellularCallHandler> ccHandler = GetMMIHandler(slotId); 216d95e75fdSopenharmony_ci if (ccHandler == nullptr) { 217d95e75fdSopenharmony_ci TELEPHONY_LOGE("ccHandler is null"); 218d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 219d95e75fdSopenharmony_ci } 220d95e75fdSopenharmony_ci std::shared_ptr<PinPukResponse> pinResData = std::make_shared<PinPukResponse>(); 221d95e75fdSopenharmony_ci pinResData->result = response.result; 222d95e75fdSopenharmony_ci pinResData->remain = response.remain; 223d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer msgEvent = 224d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(MMIHandlerId::EVENT_SET_UNLOCK_PIN_PUK_ID, pinResData, 0); 225d95e75fdSopenharmony_ci if (msgEvent == nullptr) { 226d95e75fdSopenharmony_ci TELEPHONY_LOGE("msgEvent is null"); 227d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 228d95e75fdSopenharmony_ci } 229d95e75fdSopenharmony_ci bool ret = ccHandler->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); 230d95e75fdSopenharmony_ci if (!ret) { 231d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] SendEvent failed! status update failed", slotId); 232d95e75fdSopenharmony_ci return TELEPHONY_ERR_FAIL; 233d95e75fdSopenharmony_ci } 234d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 235d95e75fdSopenharmony_ci } 236d95e75fdSopenharmony_ci return TELEPHONY_ERROR; 237d95e75fdSopenharmony_ci} 238d95e75fdSopenharmony_ci 239d95e75fdSopenharmony_ciint32_t SupplementRequestCs::AlterPin2Password(int32_t slotId, std::string newPin2, std::string oldPin2) 240d95e75fdSopenharmony_ci{ 241d95e75fdSopenharmony_ci TELEPHONY_LOGD("[slot%{public}d] entry", slotId); 242d95e75fdSopenharmony_ci LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR }; 243d95e75fdSopenharmony_ci int32_t result = CoreManagerInner::GetInstance().AlterPin2(slotId, newPin2, oldPin2, response); 244d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] result: %{public}d, remain: %{public}d", slotId, response.result, response.remain); 245d95e75fdSopenharmony_ci if (result == TELEPHONY_SUCCESS) { 246d95e75fdSopenharmony_ci std::shared_ptr<CellularCallHandler> ccHandler = GetMMIHandler(slotId); 247d95e75fdSopenharmony_ci if (ccHandler == nullptr) { 248d95e75fdSopenharmony_ci TELEPHONY_LOGE("ccHandler is null"); 249d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 250d95e75fdSopenharmony_ci } 251d95e75fdSopenharmony_ci std::shared_ptr<PinPukResponse> pinResData = std::make_shared<PinPukResponse>(); 252d95e75fdSopenharmony_ci pinResData->result = response.result; 253d95e75fdSopenharmony_ci pinResData->remain = response.remain; 254d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer msgEvent = 255d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(MMIHandlerId::EVENT_SET_UNLOCK_PIN_PUK_ID, pinResData, 0); 256d95e75fdSopenharmony_ci if (msgEvent == nullptr) { 257d95e75fdSopenharmony_ci TELEPHONY_LOGE("msgEvent is null"); 258d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 259d95e75fdSopenharmony_ci } 260d95e75fdSopenharmony_ci bool ret = ccHandler->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); 261d95e75fdSopenharmony_ci if (!ret) { 262d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] SendEvent failed! status update failed", slotId); 263d95e75fdSopenharmony_ci return TELEPHONY_ERR_FAIL; 264d95e75fdSopenharmony_ci } 265d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 266d95e75fdSopenharmony_ci } 267d95e75fdSopenharmony_ci return TELEPHONY_ERROR; 268d95e75fdSopenharmony_ci} 269d95e75fdSopenharmony_ci 270d95e75fdSopenharmony_ciint32_t SupplementRequestCs::UnlockPuk2(int32_t slotId, std::string newPin2, std::string puk2) 271d95e75fdSopenharmony_ci{ 272d95e75fdSopenharmony_ci TELEPHONY_LOGD("[slot%{public}d] entry", slotId); 273d95e75fdSopenharmony_ci LockStatusResponse response = { UNLOCK_FAIL, TELEPHONY_ERROR }; 274d95e75fdSopenharmony_ci int32_t result = CoreManagerInner::GetInstance().UnlockPuk2(slotId, newPin2, puk2, response); 275d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] result: %{public}d, remain: %{public}d", slotId, response.result, response.remain); 276d95e75fdSopenharmony_ci if (result == TELEPHONY_SUCCESS) { 277d95e75fdSopenharmony_ci std::shared_ptr<CellularCallHandler> ccHandler = GetMMIHandler(slotId); 278d95e75fdSopenharmony_ci if (ccHandler == nullptr) { 279d95e75fdSopenharmony_ci TELEPHONY_LOGE("ccHandler is null"); 280d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 281d95e75fdSopenharmony_ci } 282d95e75fdSopenharmony_ci std::shared_ptr<PinPukResponse> pinResData = std::make_shared<PinPukResponse>(); 283d95e75fdSopenharmony_ci pinResData->result = response.result; 284d95e75fdSopenharmony_ci pinResData->remain = response.remain; 285d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Pointer msgEvent = 286d95e75fdSopenharmony_ci AppExecFwk::InnerEvent::Get(MMIHandlerId::EVENT_SET_UNLOCK_PIN_PUK_ID, pinResData, 0); 287d95e75fdSopenharmony_ci if (msgEvent == nullptr) { 288d95e75fdSopenharmony_ci TELEPHONY_LOGE("msgEvent is null"); 289d95e75fdSopenharmony_ci return TELEPHONY_ERR_LOCAL_PTR_NULL; 290d95e75fdSopenharmony_ci } 291d95e75fdSopenharmony_ci bool ret = ccHandler->SendEvent(msgEvent, 0, AppExecFwk::EventQueue::Priority::IMMEDIATE); 292d95e75fdSopenharmony_ci if (!ret) { 293d95e75fdSopenharmony_ci TELEPHONY_LOGE("[slot%{public}d] SendEvent failed! status update failed", slotId); 294d95e75fdSopenharmony_ci return TELEPHONY_ERR_FAIL; 295d95e75fdSopenharmony_ci } 296d95e75fdSopenharmony_ci return TELEPHONY_SUCCESS; 297d95e75fdSopenharmony_ci } 298d95e75fdSopenharmony_ci return TELEPHONY_ERROR; 299d95e75fdSopenharmony_ci} 300d95e75fdSopenharmony_ci 301d95e75fdSopenharmony_ciint32_t SupplementRequestCs::CloseUnFinishedUssdRequest(int32_t slotId) 302d95e75fdSopenharmony_ci{ 303d95e75fdSopenharmony_ci TELEPHONY_LOGI("[slot%{public}d] entry", slotId); 304d95e75fdSopenharmony_ci return CoreManagerInner::GetInstance().CloseUnFinishedUssd( 305d95e75fdSopenharmony_ci slotId, RadioEvent::RADIO_CLOSE_UNFINISHED_USSD, GetMMIHandler(slotId)); 306d95e75fdSopenharmony_ci} 307d95e75fdSopenharmony_ci} // namespace Telephony 308d95e75fdSopenharmony_ci} // namespace OHOS 309