1 /* 2 * Copyright (C) 2024 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 "get_euicc_info_callback.h" 17 18 #include "napi_esim.h" 19 #include "telephony_errors.h" 20 #include "telephony_log_wrapper.h" 21 #include <codecvt> 22 #include <locale> 23 24 namespace OHOS { 25 namespace Telephony { GetEuiccInformationCallback(AsyncEuiccInfo * context)26GetEuiccInformationCallback::GetEuiccInformationCallback(AsyncEuiccInfo *context) : asyncContext_(context) 27 {} 28 OnGetEuiccInfo(const EuiccInfo & result,const int32_t errorCode)29void GetEuiccInformationCallback::OnGetEuiccInfo(const EuiccInfo &result, const int32_t errorCode) 30 { 31 if (asyncContext_ == nullptr) { 32 TELEPHONY_LOGI("asyncContext null"); 33 return; 34 } 35 std::unique_lock<std::mutex> callbackLock(asyncContext_->asyncContext.callbackMutex); 36 asyncContext_->asyncContext.context.resolved = (errorCode == TELEPHONY_ERR_SUCCESS); 37 if (asyncContext_->asyncContext.context.resolved) { 38 asyncContext_->result = result; 39 } else { 40 asyncContext_->asyncContext.context.errorCode = TELEPHONY_ERR_RIL_CMD_FAIL; 41 } 42 TELEPHONY_LOGI("OnGetEuiccInfo errorCode = %{public}d", errorCode); 43 asyncContext_->asyncContext.isCallbackEnd = true; 44 asyncContext_->asyncContext.cv.notify_all(); 45 } 46 } // namespace Telephony 47 } // namespace OHOS