• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_downloadable_profiles_callback.h"
17 
18 #include "napi_esim.h"
19 #include "telephony_errors.h"
20 #include "telephony_log_wrapper.h"
21 
22 namespace OHOS {
23 namespace Telephony {
GetDownloadableProfilesResultCallback(AsyncDefaultProfileList * context)24 GetDownloadableProfilesResultCallback::GetDownloadableProfilesResultCallback(
25     AsyncDefaultProfileList *context) : asyncContext_(context) {}
26 
OnGetDownloadableProfiles(const GetDownloadableProfilesResult & result,const int32_t errorCode)27 void GetDownloadableProfilesResultCallback::OnGetDownloadableProfiles(
28     const GetDownloadableProfilesResult &result, const int32_t errorCode)
29 {
30     if (asyncContext_ == nullptr) {
31         TELEPHONY_LOGE("asyncContext null");
32         return;
33     }
34     std::unique_lock<std::mutex> callbackLock(asyncContext_->asyncContext.callbackMutex);
35     asyncContext_->asyncContext.context.resolved = (errorCode == TELEPHONY_ERR_SUCCESS);
36     if (asyncContext_->asyncContext.context.resolved) {
37         asyncContext_->result = result;
38     } else {
39         asyncContext_->asyncContext.context.errorCode = TELEPHONY_ERR_RIL_CMD_FAIL;
40         TELEPHONY_LOGE("errorCode = %{public}d", errorCode);
41     }
42     asyncContext_->asyncContext.isCallbackEnd = true;
43     asyncContext_->asyncContext.cv.notify_all();
44 }
45 } // namespace Telephony
46 } // namespace OHOS