• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_cust_wrapper.h"
17 
18 #include <dlfcn.h>
19 #include "telephony_log_wrapper.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 namespace {
24 const std::string TELEPHONY_CUST_WRAPPER_PATH = "libtelephony_cust_api.z.so";
25 } // namespace
26 
TelephonyCustWrapper()27 TelephonyCustWrapper::TelephonyCustWrapper() {}
~TelephonyCustWrapper()28 TelephonyCustWrapper::~TelephonyCustWrapper()
29 {
30     TELEPHONY_LOGI("TelephonyCustWrapper::~TelephonyCustWrapper() start");
31     if (telephonyCustWrapperHandle_ != nullptr) {
32         dlclose(telephonyCustWrapperHandle_);
33         telephonyCustWrapperHandle_ = nullptr;
34     }
35 }
36 
InitTelephonyCustWrapper()37 void TelephonyCustWrapper::InitTelephonyCustWrapper()
38 {
39     TELEPHONY_LOGI("TelephonyCustWrapper::InitTelephonyCustWrapper() start");
40     telephonyCustWrapperHandle_ = dlopen(TELEPHONY_CUST_WRAPPER_PATH.c_str(), RTLD_NOW);
41     if (telephonyCustWrapperHandle_ == nullptr) {
42         TELEPHONY_LOGE("libtelephony_cust_api.z.so was not loaded, error: %{public}s", dlerror());
43         return;
44     }
45     isHideViolenceOrEmcNumbersInCallLog_ = (IS_HIDE_VIOLENCE_OR_EMC_NUMBERS_IN_CALLLOG)dlsym(
46         telephonyCustWrapperHandle_, "IsHideViolenceOrEmcNumbersInCallLog");
47     if (isHideViolenceOrEmcNumbersInCallLog_ == nullptr) {
48         TELEPHONY_LOGE("telephony cust wrapper symbol faild, error: %{public}s", dlerror());
49         return;
50     }
51     isChangeDialNumberToTwEmc_ = (IS_CHANGE_DIAL_NUMBER_TO_TW_EMC)dlsym(
52         telephonyCustWrapperHandle_, "IsChangeDialNumberToTwEmc");
53     if (isChangeDialNumberToTwEmc_ == nullptr) {
54         TELEPHONY_LOGE("telephony cust wrapper change dial num symbol faild, error: %{public}s", dlerror());
55         return;
56     }
57     TELEPHONY_LOGI("telephony cust wrapper init success!");
58 }
59 } // namespace Telephony
60 } // namespace OHOS
61