1 /*
2 * Copyright (c) 2023-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 <dlfcn.h>
17 #include "telephony_ext_wrapper.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_LOGD("TelephonyExtWrapper::~TelephonyExtWrapper() start");
30 dlclose(telephonyExtWrapperHandle_);
31 telephonyExtWrapperHandle_ = nullptr;
32 }
33
InitTelephonyExtWrapper()34 void TelephonyExtWrapper::InitTelephonyExtWrapper()
35 {
36 TELEPHONY_LOGD("TelephonyExtWrapper::InitTelephonyExtWrapper() start");
37 telephonyExtWrapperHandle_ = dlopen(TELEPHONY_EXT_WRAPPER_PATH.c_str(), RTLD_NOW);
38 if (telephonyExtWrapperHandle_ == nullptr) {
39 TELEPHONY_LOGE("libtelephony_ext_service.z.so was not loaded, error: %{public}s", dlerror());
40 return;
41 }
42 InitTelephonyExtWrapperForNetWork();
43 InitTelephonyExtWrapperForVoiceMail();
44 TELEPHONY_LOGI("telephony ext wrapper init success");
45 }
46
InitTelephonyExtWrapperForNetWork()47 void TelephonyExtWrapper::InitTelephonyExtWrapperForNetWork()
48 {
49 checkOpcVersionIsUpdate_ = (CHECK_OPC_VERSION_IS_UPDATE)dlsym(telephonyExtWrapperHandle_,
50 "CheckOpcVersionIsUpdate");
51 updateOpcVersion_ = (UPDATE_OPC_VERSION)dlsym(telephonyExtWrapperHandle_, "UpdateOpcVersion");
52 getCellInfoList_ = (GET_CELL_INFO_LIST)dlsym(telephonyExtWrapperHandle_, "GetCellInfoListExt");
53 getRadioTechExt_ = (GET_RADIO_TECH_EXT)dlsym(telephonyExtWrapperHandle_, "GetRadioTechExt");
54 getNrOptionModeExt_ = (GET_NR_OPTION_MODE_EXT)dlsym(telephonyExtWrapperHandle_, "GetNrOptionModeExt");
55 getNrOptionModeExtend_ = (GET_NR_OPTION_MODE_EXTEND)dlsym(telephonyExtWrapperHandle_, "GetNrOptionModeExtend");
56 getPreferredNetworkExt_ = (GET_PREFERRED_NETWORK_EXT)dlsym(telephonyExtWrapperHandle_, "GetPreferredNetworkExt");
57 isNrSupportedNative_ = (IS_NR_SUPPORTED_NATIVE)dlsym(telephonyExtWrapperHandle_, "IsNrSupportedNativeExt");
58 getSignalInfoListExt_ = (GET_SIGNAL_INFO_LIST_EXT)dlsym(telephonyExtWrapperHandle_, "GetSignalInfoListExt");
59 getNetworkCapabilityExt_ = (GET_NETWORK_CAPABILITY_EXT)dlsym(telephonyExtWrapperHandle_, "GetNetworkCapabilityExt");
60 onGetNetworkSearchInformationExt_ = (ON_GET_NETWORK_SEARCH_INFORMATION_EXT)dlsym(telephonyExtWrapperHandle_,
61 "OnGetNetworkSearchInformationExt");
62 getNetworkStatusExt_ = (GET_NETWORK_STATUS_EXT)dlsym(telephonyExtWrapperHandle_, "GetNetworkStatusExt");
63 if (checkOpcVersionIsUpdate_ == nullptr || updateOpcVersion_ == nullptr || getCellInfoList_ == nullptr ||
64 getRadioTechExt_ == nullptr || getNrOptionModeExt_ == nullptr || getSignalInfoListExt_ == nullptr ||
65 getNetworkCapabilityExt_ == nullptr || onGetNetworkSearchInformationExt_ == nullptr ||
66 getNetworkStatusExt_ == nullptr || isNrSupportedNative_ == nullptr ||
67 getNrOptionModeExtend_ == nullptr || getPreferredNetworkExt_ == nullptr) {
68 TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
69 }
70 updateCountryCodeExt_ = (UPDATE_COUNTRY_CODE_EXT)dlsym(telephonyExtWrapperHandle_, "UpdateCountryCodeExt");
71 updateTimeZoneOffsetExt_ =
72 (UPDATE_TIME_ZONE_OFFSET_EXT)dlsym(telephonyExtWrapperHandle_, "UpdateTimeZoneOffsetExt");
73 if (updateCountryCodeExt_ == nullptr || updateTimeZoneOffsetExt_ == nullptr) {
74 TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
75 }
76 }
77
InitTelephonyExtWrapperForVoiceMail()78 void TelephonyExtWrapper::InitTelephonyExtWrapperForVoiceMail()
79 {
80 getVoiceMailIccidParameter_ = (GET_VOICE_MAIL_ICCID_PARAMETER)dlsym(telephonyExtWrapperHandle_,
81 "GetVoiceMailIccidParameter");
82 setVoiceMailIccidParameter_ = (SET_VOICE_MAIL_ICCID_PARAMETER)dlsym(telephonyExtWrapperHandle_,
83 "SetVoiceMailIccidParameter");
84 initVoiceMailManagerExt_ = (INIT_VOICE_MAIL_MANAGER_EXT)dlsym(telephonyExtWrapperHandle_,
85 "InitVoiceMailManagerExt");
86 deinitVoiceMailManagerExt_ = (DEINIT_VOICE_MAIL_MANAGER_EXT)dlsym(telephonyExtWrapperHandle_,
87 "DeinitVoiceMailManagerExt");
88 resetVoiceMailLoadedFlagExt_ = (RESET_VOICE_MAIL_LOADED_FLAG_EXT)dlsym(telephonyExtWrapperHandle_,
89 "ResetVoiceMailLoadedFlagExt");
90 setVoiceMailOnSimExt_ = (SET_VOICE_MAIL_ON_SIM_EXT)dlsym(telephonyExtWrapperHandle_,
91 "SetVoiceMailOnSimExt");
92 getVoiceMailFixedExt_ = (GET_VOICE_MAIL_FIXED_EXT)dlsym(telephonyExtWrapperHandle_,
93 "GetVoiceMailFixedExt");
94 getVoiceMailNumberExt_ = (GET_VOICE_MAIL_NUMBER_EXT)dlsym(telephonyExtWrapperHandle_,
95 "GetVoiceMailNumberExt");
96 getVoiceMailTagExt_ = (GET_VOICE_MAIL_TAG_EXT)dlsym(telephonyExtWrapperHandle_,
97 "GetVoiceMailTagExt");
98 resetVoiceMailManagerExt_ = (RESET_VOICE_MAIL_MANAGER_EXT)dlsym(telephonyExtWrapperHandle_,
99 "ResetVoiceMailManagerExt");
100 getNetworkStatusExt_ = (GET_NETWORK_STATUS_EXT)dlsym(telephonyExtWrapperHandle_, "GetNetworkStatusExt");
101 if (getVoiceMailIccidParameter_ == nullptr || setVoiceMailIccidParameter_ == nullptr ||
102 initVoiceMailManagerExt_ == nullptr || deinitVoiceMailManagerExt_ == nullptr ||
103 resetVoiceMailLoadedFlagExt_ == nullptr || setVoiceMailOnSimExt_ == nullptr ||
104 getVoiceMailFixedExt_ == nullptr || getVoiceMailNumberExt_ == nullptr ||
105 getVoiceMailTagExt_ == nullptr || resetVoiceMailManagerExt_ == nullptr ||
106 getNetworkStatusExt_ == nullptr) {
107 TELEPHONY_LOGE("telephony ext wrapper symbol failed, error: %{public}s", dlerror());
108 return;
109 }
110 }
111
112
113 } // namespace Telephony
114 } // namespace OHOS
115