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  *
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 "touch_screen.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace {
21 constexpr std::string_view TOUCHSCREEN_WRAPPER_PATH = "../../vendor/lib64/chipsetsdk/libhw_touchscreen.default.so";
22 } // namespace
23 
TouchScreen()24 TouchScreen::TouchScreen() {}
~TouchScreen()25 TouchScreen::~TouchScreen()
26 {
27     if (touchScreenHandle_ != nullptr) {
28         dlclose(touchScreenHandle_);
29         touchScreenHandle_ = nullptr;
30         setFeatureConfigHandle_ = nullptr;
31         setAftConfigHandle_ = nullptr;
32     }
33 }
34 
InitTouchScreen()35 void TouchScreen::InitTouchScreen()
36 {
37     touchScreenHandle_ = dlopen(TOUCHSCREEN_WRAPPER_PATH.data(), RTLD_NOW);
38     if (touchScreenHandle_ == nullptr) {
39         RS_LOGE("libhw_touchscreen.default.so was not loaded, error: %{public}s", dlerror());
40         return;
41     }
42 
43     GetHandleBySymbol(setFeatureConfigHandle_, "ts_set_feature_config");
44     GetHandleBySymbol(setAftConfigHandle_, "ts_set_aft_config");
45 }
46 } // namespace Rosen
47 } // namespace OHOS
48