1 /*
2 * Copyright (c) 2023 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 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15 #include <dlfcn.h>
16 #include "telephony_ext_utils_wrapper.h"
17 #include "telephony_log_wrapper.h"
18
19 namespace OHOS {
20 namespace Telephony {
21 namespace {
22 const std::string TELEPHONY_EXT_UTILS_WRAPPER_PATH = "libtelephony_ext_service.z.so";
23 } // namespace
24
TelephonyExtUtilsWrapper()25 TelephonyExtUtilsWrapper::TelephonyExtUtilsWrapper() {}
~TelephonyExtUtilsWrapper()26 TelephonyExtUtilsWrapper::~TelephonyExtUtilsWrapper()
27 {
28 TELEPHONY_LOGD("TelephonyExtUtilsWrapper::~TelephonyExtUtilsWrapper() start");
29 dlclose(telephonyExtUtilsWrapperHandle_);
30 telephonyExtUtilsWrapperHandle_ = nullptr;
31 }
InitTelephonyExtUtilsWrapper()32 void TelephonyExtUtilsWrapper::InitTelephonyExtUtilsWrapper()
33 {
34 TELEPHONY_LOGD("TelephonyExtUtilsWrapper::InitTelephonyExtUtilsWrapper() start");
35 telephonyExtUtilsWrapperHandle_ = dlopen(TELEPHONY_EXT_UTILS_WRAPPER_PATH.c_str(), RTLD_NOW);
36 if (telephonyExtUtilsWrapperHandle_ == nullptr) {
37 TELEPHONY_LOGE("libtelephony_ext_service.z.so was not loaded, error: %{public}s", dlerror());
38 return;
39 }
40 isNrSupported_ = (IS_NR_SUPPORTED)dlsym(telephonyExtUtilsWrapperHandle_, "IsNrSupportedExt");
41 if (isNrSupported_ == nullptr) {
42 TELEPHONY_LOGE("telephony ext utils wrapper symbol failed, error: %{public}s", dlerror());
43 return;
44 }
45 TELEPHONY_LOGI("telephony ext utils wrapper init success");
46 }
47 } // namespace Telephony
48 } // namespace OHOS
49