1 /*
2 * Copyright (C) 2024-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 "telephony_ext_wrapper.h"
17 #include <dlfcn.h>
18 #include "telephony_log_wrapper.h"
19
20 namespace OHOS {
21 namespace Telephony {
22 namespace {
23 const std::string TELEPHONY_EXT_WRAPPER_PATH = "libtelephony_ext_service.z.so";
24 } // namespace
25
TelephonyExtWrapper()26 TelephonyExtWrapper::TelephonyExtWrapper() {}
~TelephonyExtWrapper()27 TelephonyExtWrapper::~TelephonyExtWrapper()
28 {
29 TELEPHONY_LOGI("TelephonyExtWrapper::~TelephonyExtWrapper() start");
30 if (handler_ != nullptr) {
31 dlclose(handler_);
32 handler_ = nullptr;
33 }
34 }
35
InitTelephonyExtWrapper()36 void TelephonyExtWrapper::InitTelephonyExtWrapper()
37 {
38 TELEPHONY_LOGI("TelephonyExtWrapper::InitTelephonyExtWrapper() start");
39 InitTelephonyExtWrapperForCellularCall();
40 }
41
InitTelephonyExtWrapperForCellularCall()42 void TelephonyExtWrapper::InitTelephonyExtWrapperForCellularCall()
43 {
44 handler_ = dlopen(TELEPHONY_EXT_WRAPPER_PATH.c_str(), RTLD_NOW);
45 if (handler_ == nullptr) {
46 TELEPHONY_LOGE("libtelephnoy ext service file load failed!");
47 return;
48 }
49 isEmptyMmiResultFiltered_ = (IsEmptyMmiResultFiltered)dlsym(handler_, "IsEmptyMmiResultFiltered");
50 isMmiCode_ = (IsMmiCode)dlsym(handler_, "IsMmiCode");
51 isUssdReleaseMsgFiltered_ = (IsUssdReleaseMsgFiltered)dlsym(handler_, "IsUssdReleaseMsgFiltered");
52 unescapeHtmlCode_ = (UnescapeHtmlCode)dlsym(handler_, "UnescapeHtmlCode");
53 TELEPHONY_LOGI("init success");
54 }
55 } // namespace Telephony
56 } // namespace OHOS